#include "omc_simulation_settings.h"
#include "SimCodeUtil.h"
#define _OMC_LIT0_data "abs"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT0,3,_OMC_LIT0_data);
#define _OMC_LIT0 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT0)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT1,1.0);
#define _OMC_LIT1 MMC_REFREALLIT(_OMC_LIT_STRUCT1)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT2,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT1}};
#define _OMC_LIT2 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT2)
#define _OMC_LIT3_data "sqrt"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT3,4,_OMC_LIT3_data);
#define _OMC_LIT3 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT3)
#define _OMC_LIT4_data "sinh"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT4,4,_OMC_LIT4_data);
#define _OMC_LIT4 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT4)
#define _OMC_LIT5_data "cosh"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT5,4,_OMC_LIT5_data);
#define _OMC_LIT5 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT5)
#define _OMC_LIT6_data "tanh"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT6,4,_OMC_LIT6_data);
#define _OMC_LIT6 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT6)
#define _OMC_LIT7_data "exp"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT7,3,_OMC_LIT7_data);
#define _OMC_LIT7 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT7)
#define _OMC_LIT8_data "log"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT8,3,_OMC_LIT8_data);
#define _OMC_LIT8 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT8)
#define _OMC_LIT9_data "log10"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT9,5,_OMC_LIT9_data);
#define _OMC_LIT9 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT9)
#define _OMC_LIT10_data "sign"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT10,4,_OMC_LIT10_data);
#define _OMC_LIT10 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT10)
#define _OMC_LIT11_data "div"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT11,3,_OMC_LIT11_data);
#define _OMC_LIT11 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT11)
#define _OMC_LIT12_data "mod"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT12,3,_OMC_LIT12_data);
#define _OMC_LIT12 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT12)
#define _OMC_LIT13_data "rem"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT13,3,_OMC_LIT13_data);
#define _OMC_LIT13 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT13)
#define _OMC_LIT14_data "ceil"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT14,4,_OMC_LIT14_data);
#define _OMC_LIT14 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT14)
#define _OMC_LIT15_data "floor"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT15,5,_OMC_LIT15_data);
#define _OMC_LIT15 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT15)
#define _OMC_LIT16_data "sin"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT16,3,_OMC_LIT16_data);
#define _OMC_LIT16 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT16)
#define _OMC_LIT17_data "cos"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT17,3,_OMC_LIT17_data);
#define _OMC_LIT17 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT17)
#define _OMC_LIT18_data "tan"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT18,3,_OMC_LIT18_data);
#define _OMC_LIT18 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT18)
#define _OMC_LIT19_data "asin"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT19,4,_OMC_LIT19_data);
#define _OMC_LIT19 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT19)
#define _OMC_LIT20_data "acos"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT20,4,_OMC_LIT20_data);
#define _OMC_LIT20 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT20)
#define _OMC_LIT21_data "atan"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT21,4,_OMC_LIT21_data);
#define _OMC_LIT21 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT21)
#define _OMC_LIT22_data "cmake"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT22,5,_OMC_LIT22_data);
#define _OMC_LIT22 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT22)
#define _OMC_LIT23_data "systemCall_cmakeVersion.log"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT23,27,_OMC_LIT23_data);
#define _OMC_LIT23 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT23)
#define _OMC_LIT24_data " --version"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT24,10,_OMC_LIT24_data);
#define _OMC_LIT24 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT24)
#define _OMC_LIT25_data "Failed to get version from "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT25,27,_OMC_LIT25_data);
#define _OMC_LIT25 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT25)
#define _OMC_LIT26_data "/projects/OpenModelica-session2/OMCompiler/Compiler/SimCode/SimCodeUtil.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT26,74,_OMC_LIT26_data);
#define _OMC_LIT26 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT26)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT27_6,1.782113391e9);
#define _OMC_LIT27_6 MMC_REFREALLIT(_OMC_LIT_STRUCT27_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT27,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15651)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15651)),MMC_IMMEDIATE(MMC_TAGFIXNUM(86)),_OMC_LIT27_6}};
#define _OMC_LIT27 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT27)
#define _OMC_LIT28_data "[0-9]+\\.[0-9]+\\.[0-9]+"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT28,22,_OMC_LIT28_data);
#define _OMC_LIT28 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT28)
#define _OMC_LIT29_data "Failed to read semantic version from "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT29,37,_OMC_LIT29_data);
#define _OMC_LIT29 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT29)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT30_6,1.782113391e9);
#define _OMC_LIT30_6 MMC_REFREALLIT(_OMC_LIT_STRUCT30_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT30,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15664)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15664)),MMC_IMMEDIATE(MMC_TAGFIXNUM(96)),_OMC_LIT30_6}};
#define _OMC_LIT30 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT30)
#define _OMC_LIT31_data ""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT31,0,_OMC_LIT31_data);
#define _OMC_LIT31 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT31)
#define _OMC_LIT32_data "\n                                               "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT32,48,_OMC_LIT32_data);
#define _OMC_LIT32 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT32)
#define _OMC_LIT33_data "\""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT33,1,_OMC_LIT33_data);
#define _OMC_LIT33 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT33)
#define _OMC_LIT34_data "\"-I"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT34,3,_OMC_LIT34_data);
#define _OMC_LIT34 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT34)
#define _OMC_LIT35_data "s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT35,1,_OMC_LIT35_data);
#define _OMC_LIT35 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT35)
#define _OMC_LIT36_data "cvode"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT36,5,_OMC_LIT36_data);
#define _OMC_LIT36 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT36)
#define _OMC_LIT37_data "\"cvode\""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT37,7,_OMC_LIT37_data);
#define _OMC_LIT37 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT37)
#define _OMC_LIT38_data "OFF"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT38,3,_OMC_LIT38_data);
#define _OMC_LIT38 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT38)
#define _OMC_LIT39_data "\"\""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT39,2,_OMC_LIT39_data);
#define _OMC_LIT39 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT39)
#define _OMC_LIT40_data "ON"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT40,2,_OMC_LIT40_data);
#define _OMC_LIT40 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT40)
#define _OMC_LIT41_data "/lib/${CMAKE_LIBRARY_ARCHITECTURE}/omc\""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT41,39,_OMC_LIT41_data);
#define _OMC_LIT41 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT41)
#define _OMC_LIT42_data "\"${DOCKER_VOL_DIR}"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT42,18,_OMC_LIT42_data);
#define _OMC_LIT42 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT42)
#define _OMC_LIT43_data "/lib/${CMAKE_LIBRARY_ARCHITECTURE}/omc"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT43,38,_OMC_LIT43_data);
#define _OMC_LIT43 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT43)
#define _OMC_LIT44_data "/bin"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT44,4,_OMC_LIT44_data);
#define _OMC_LIT44 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT44)
#define _OMC_LIT45_data "set(EXTERNAL_LIBDIRECTORIES "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT45,28,_OMC_LIT45_data);
#define _OMC_LIT45 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT45)
#define _OMC_LIT46_data "\n                            "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT46,29,_OMC_LIT46_data);
#define _OMC_LIT46 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT46)
#define _OMC_LIT47_data ")\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT47,2,_OMC_LIT47_data);
#define _OMC_LIT47 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT47)
#define _OMC_LIT48_data "\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT48,1,_OMC_LIT48_data);
#define _OMC_LIT48 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT48)
#define _OMC_LIT49_data "find_library("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT49,13,_OMC_LIT49_data);
#define _OMC_LIT49 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT49)
#define _OMC_LIT50_data "             NAMES "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT50,19,_OMC_LIT50_data);
#define _OMC_LIT50 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT50)
#define _OMC_LIT51_data "             PATHS ${EXTERNAL_LIBDIRECTORIES} NO_DEFAULT_PATH)\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT51,63,_OMC_LIT51_data);
#define _OMC_LIT51 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT51)
#define _OMC_LIT52_data "message(STATUS \"Linking ${"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT52,26,_OMC_LIT52_data);
#define _OMC_LIT52 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT52)
#define _OMC_LIT53_data "}\")"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT53,3,_OMC_LIT53_data);
#define _OMC_LIT53 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT53)
#define _OMC_LIT54_data "target_link_libraries(${FMU_NAME_HASH} PRIVATE ${"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT54,49,_OMC_LIT54_data);
#define _OMC_LIT54 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT54)
#define _OMC_LIT55_data "})"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT55,2,_OMC_LIT55_data);
#define _OMC_LIT55 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT55)
#define _OMC_LIT56_data "list(APPEND RUNTIME_DEPENDS ${"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT56,30,_OMC_LIT56_data);
#define _OMC_LIT56 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT56)
#define _OMC_LIT57_data "\n# Cross-Platform CMAKE_FIND_LIBRARY_SUFFIXES\nif(WIN32)\n  set(CMAKE_FIND_LIBRARY_SUFFIXES \".lib\" \".dll\" \".a\")\nelseif(APPLE)\n  set(CMAKE_FIND_LIBRARY_SUFFIXES \".dylib\" \".a\")\nelse()\n  set(CMAKE_FIND_LIBRARY_SUFFIXES \".so\" \".a\")\nendif()\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT57,234,_OMC_LIT57_data);
#define _OMC_LIT57 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT57)
#define _OMC_LIT58_data "-l"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT58,2,_OMC_LIT58_data);
#define _OMC_LIT58 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT58)
#define _OMC_LIT59_data "\"-L"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT59,3,_OMC_LIT59_data);
#define _OMC_LIT59 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT59)
#define _OMC_LIT60_data ".bat"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT60,4,_OMC_LIT60_data);
#define _OMC_LIT60 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT60)
#define _OMC_LIT61_data ";"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT61,1,_OMC_LIT61_data);
#define _OMC_LIT61 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT61)
#define _OMC_LIT62_data "/bin/"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT62,5,_OMC_LIT62_data);
#define _OMC_LIT62 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT62)
#define _OMC_LIT63_data "@echo off\nSET PATH="
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT63,19,_OMC_LIT63_data);
#define _OMC_LIT63 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT63)
#define _OMC_LIT64_data ";%PATH%;\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT64,9,_OMC_LIT64_data);
#define _OMC_LIT64 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT64)
#define _OMC_LIT65_data "SET ERRORLEVEL=\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT65,16,_OMC_LIT65_data);
#define _OMC_LIT65 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT65)
#define _OMC_LIT66_data "CALL \"%CD%/"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT66,11,_OMC_LIT66_data);
#define _OMC_LIT66 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT66)
#define _OMC_LIT67_data ".exe\" %*\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT67,9,_OMC_LIT67_data);
#define _OMC_LIT67 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT67)
#define _OMC_LIT68_data "SET RESULT=%ERRORLEVEL%\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT68,24,_OMC_LIT68_data);
#define _OMC_LIT68 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT68)
#define _OMC_LIT69_data "EXIT /b %RESULT%\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT69,17,_OMC_LIT69_data);
#define _OMC_LIT69 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT69)
#define _OMC_LIT70_data "SimCodeMain.generateRunnerBatScript failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT70,42,_OMC_LIT70_data);
#define _OMC_LIT70 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT70)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT71_6,1.782113391e9);
#define _OMC_LIT71_6 MMC_REFREALLIT(_OMC_LIT_STRUCT71_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT71,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15497)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(15497)),MMC_IMMEDIATE(MMC_TAGFIXNUM(91)),_OMC_LIT71_6}};
#define _OMC_LIT71 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT71)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT72,1,5) {&ErrorTypes_MessageType_TRANSLATION__desc,}};
#define _OMC_LIT72 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT72)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT73,1,5) {&ErrorTypes_Severity_WARNING__desc,}};
#define _OMC_LIT73 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT73)
#define _OMC_LIT74_data "Could not resolve URI (%s) at compile-time; copying all loaded packages into the FMU"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT74,84,_OMC_LIT74_data);
#define _OMC_LIT74 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT74)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT75,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(597)),_OMC_LIT72,_OMC_LIT73,_OMC_LIT74}};
#define _OMC_LIT75 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT75)
#define _OMC_LIT76_data "OpenModelica_fmuLoadResource"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT76,28,_OMC_LIT76_data);
#define _OMC_LIT76 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT76)
#define _OMC_LIT77_data "OpenModelica_uriToFilename"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT77,26,_OMC_LIT77_data);
#define _OMC_LIT77 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT77)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT78,1,5) {&AvlSetString_Tree_EMPTY__desc,}};
#define _OMC_LIT78 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT78)
#define _OMC_LIT79_data "package.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT79,10,_OMC_LIT79_data);
#define _OMC_LIT79 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT79)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT80,1,5) {&AvlTreeCRToInt_Tree_EMPTY__desc,}};
#define _OMC_LIT80 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT80)
#define _OMC_LIT81_data "_der"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT81,4,_OMC_LIT81_data);
#define _OMC_LIT81 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT81)
#define _OMC_LIT82_data "$"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT82,1,_OMC_LIT82_data);
#define _OMC_LIT82 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT82)
#define _OMC_LIT83_data "cs"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT83,2,_OMC_LIT83_data);
#define _OMC_LIT83 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT83)
#define _OMC_LIT84_data "-1"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT84,2,_OMC_LIT84_data);
#define _OMC_LIT84 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT84)
#define _OMC_LIT85_data "ERROR_localCref2SimVar_failed "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT85,30,_OMC_LIT85_data);
#define _OMC_LIT85 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT85)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT86,2,4) {&DAE_Type_T__REAL__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT86 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT86)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT87,1,3) {&BackendDAE_VarKind_VARIABLE__desc,}};
#define _OMC_LIT87 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT87)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT88,1,3) {&SimCodeVar_AliasVariable_NOALIAS__desc,}};
#define _OMC_LIT88 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT88)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT89,0.0);
#define _OMC_LIT89 MMC_REFREALLIT(_OMC_LIT_STRUCT89)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT90,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT31,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),_OMC_LIT89}};
#define _OMC_LIT90 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT90)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT91,1,4) {&DAE_ComponentPrefix_NOCOMPPRE__desc,}};
#define _OMC_LIT91 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT91)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT92,8,3) {&DAE_ElementSource_SOURCE__desc,_OMC_LIT90,MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT91,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT92 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT92)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT93,1,6) {&SimCodeVar_Causality_LOCAL__desc,}};
#define _OMC_LIT93 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT93)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT94,1,1) {_OMC_LIT93}};
#define _OMC_LIT94 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT94)
#define _OMC_LIT95_data "nfScalarize"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT95,11,_OMC_LIT95_data);
#define _OMC_LIT95 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT95)
#define _OMC_LIT96_data "Run scalarization in NF, default true."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT96,38,_OMC_LIT96_data);
#define _OMC_LIT96 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT96)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT97,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(168)),_OMC_LIT95,MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */)),_OMC_LIT96}};
#define _OMC_LIT97 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT97)
#define _OMC_LIT98_data "ERROR_simVarFromHT_failed "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT98,26,_OMC_LIT98_data);
#define _OMC_LIT98 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT98)
#define _OMC_LIT99_data "ERROR_cref2simvar_failed "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT99,25,_OMC_LIT99_data);
#define _OMC_LIT99 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT99)
#define _OMC_LIT100_data "Tried to generate code that requires the SimCode structure, but this is not set (function context?)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT100,99,_OMC_LIT100_data);
#define _OMC_LIT100 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT100)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT101_6,1.782113391e9);
#define _OMC_LIT101_6 MMC_REFREALLIT(_OMC_LIT_STRUCT101_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT101,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14977)),MMC_IMMEDIATE(MMC_TAGFIXNUM(20)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14977)),MMC_IMMEDIATE(MMC_TAGFIXNUM(159)),_OMC_LIT101_6}};
#define _OMC_LIT101 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT101)
#define _OMC_LIT102_data "Failed to SimCodeUtil.getInputIndex of variable"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT102,47,_OMC_LIT102_data);
#define _OMC_LIT102 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT102)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT103_6,1.782113391e9);
#define _OMC_LIT103_6 MMC_REFREALLIT(_OMC_LIT_STRUCT103_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT103,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14931)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14931)),MMC_IMMEDIATE(MMC_TAGFIXNUM(96)),_OMC_LIT103_6}};
#define _OMC_LIT103 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT103)
#define _OMC_LIT104_data "getNLSysRHS failed\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT104,19,_OMC_LIT104_data);
#define _OMC_LIT104 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT104)
#define _OMC_LIT105_data "$Sensitivities"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT105,14,_OMC_LIT105_data);
#define _OMC_LIT105 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT105)
#define _OMC_LIT106_data "This model has at least one large or nonlinear linear equation system, thus the use of Lapack is prefered.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT106,107,_OMC_LIT106_data);
#define _OMC_LIT106 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT106)
#define _OMC_LIT107_data "This model has no large linear or nonlinear equation system, thus the use of dgesv (OMCompiler/3rdParty/) is prefered.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT107,119,_OMC_LIT107_data);
#define _OMC_LIT107 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT107)
#define _OMC_LIT108_data "dumpdgesv"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT108,9,_OMC_LIT108_data);
#define _OMC_LIT108 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT108)
#define _OMC_LIT109_data "Enables dumping of the information whether DGESV is used to solve linear systems."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT109,81,_OMC_LIT109_data);
#define _OMC_LIT109 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT109)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT110,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(136)),_OMC_LIT108,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT109}};
#define _OMC_LIT110 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT110)
#define _OMC_LIT111_data "getLocalValueReference failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT111,30,_OMC_LIT111_data);
#define _OMC_LIT111 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT111)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT112_6,1.782113391e9);
#define _OMC_LIT112_6 MMC_REFREALLIT(_OMC_LIT_STRUCT112_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT112,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14629)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14629)),MMC_IMMEDIATE(MMC_TAGFIXNUM(77)),_OMC_LIT112_6}};
#define _OMC_LIT112 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT112)
#define _OMC_LIT113_data "ERROR: getLocalValueReference failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT113,36,_OMC_LIT113_data);
#define _OMC_LIT113 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT113)
#define _OMC_LIT114_data "invalid return value from getVariableIndex"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT114,42,_OMC_LIT114_data);
#define _OMC_LIT114 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT114)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT115_6,1.782113391e9);
#define _OMC_LIT115_6 MMC_REFREALLIT(_OMC_LIT_STRUCT115_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT115,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14597)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14597)),MMC_IMMEDIATE(MMC_TAGFIXNUM(87)),_OMC_LIT115_6}};
#define _OMC_LIT115 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT115)
#define _OMC_LIT116_data "$PRE"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT116,4,_OMC_LIT116_data);
#define _OMC_LIT116 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT116)
#define _OMC_LIT117_data "invalid return value from getVarIndexByMapping for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT117,51,_OMC_LIT117_data);
#define _OMC_LIT117 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT117)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT118_6,1.782113391e9);
#define _OMC_LIT118_6 MMC_REFREALLIT(_OMC_LIT_STRUCT118_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT118,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14562)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(14562)),MMC_IMMEDIATE(MMC_TAGFIXNUM(123)),_OMC_LIT118_6}};
#define _OMC_LIT118 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT118)
#define _OMC_LIT119_data "Cpp"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT119,3,_OMC_LIT119_data);
#define _OMC_LIT119 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT119)
#define _OMC_LIT120_data "omsic"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT120,5,_OMC_LIT120_data);
#define _OMC_LIT120 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT120)
#define _OMC_LIT121_data "dependent"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT121,9,_OMC_LIT121_data);
#define _OMC_LIT121 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT121)
#define _OMC_LIT122_data "========================================"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT122,40,_OMC_LIT122_data);
#define _OMC_LIT122 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT122)
#define _OMC_LIT123_data "=====>"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT123,6,_OMC_LIT123_data);
#define _OMC_LIT123 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT123)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT124,1,7) {&SimCodeVar_Variability_CONTINUOUS__desc,}};
#define _OMC_LIT124 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT124)
#define _OMC_LIT125_data "\n FmiInitialUnknownsDependencyList :"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT125,36,_OMC_LIT125_data);
#define _OMC_LIT125 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT125)
#define _OMC_LIT126_data "orderedVariables"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT126,16,_OMC_LIT126_data);
#define _OMC_LIT126 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT126)
#define _OMC_LIT127_data "orderedEquation"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT127,15,_OMC_LIT127_data);
#define _OMC_LIT127 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT127)
#define _OMC_LIT128_data "globalknownVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT128,15,_OMC_LIT128_data);
#define _OMC_LIT128 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT128)
#define _OMC_LIT129_data "SimulationGlobalknownVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT129,25,_OMC_LIT129_data);
#define _OMC_LIT129 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT129)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT130,1,3) {&BackendDAE_EquationKind_BINDING__EQUATION__desc,}};
#define _OMC_LIT130 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT130)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT131,5,3) {&BackendDAE_EvaluationStages_EVALUATION__STAGES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT131 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT131)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT132,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT130,_OMC_LIT131}};
#define _OMC_LIT132 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT132)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT133,1,4) {&BackendDAE_IndexType_NORMAL__desc,}};
#define _OMC_LIT133 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT133)
#define _OMC_LIT134_data "Check Initilization DAE"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT134,23,_OMC_LIT134_data);
#define _OMC_LIT134 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT134)
#define _OMC_LIT135_data "depVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT135,7,_OMC_LIT135_data);
#define _OMC_LIT135 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT135)
#define _OMC_LIT136_data "indepVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT136,9,_OMC_LIT136_data);
#define _OMC_LIT136 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT136)
#define _OMC_LIT137_data "FmiInitialUnknownDependency"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT137,27,_OMC_LIT137_data);
#define _OMC_LIT137 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT137)
#define _OMC_LIT138_data "fmiDerInit_unknownVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT138,22,_OMC_LIT138_data);
#define _OMC_LIT138 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT138)
#define _OMC_LIT139_data "fmiDerInit_knownVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT139,20,_OMC_LIT139_data);
#define _OMC_LIT139 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT139)
#define _OMC_LIT140_data "disableFMIDependency"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT140,20,_OMC_LIT140_data);
#define _OMC_LIT140 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT140)
#define _OMC_LIT141_data "Disables the dependency analysis and generation for FMI 2.0."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT141,60,_OMC_LIT141_data);
#define _OMC_LIT141 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT141)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT142,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(174)),_OMC_LIT140,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT141}};
#define _OMC_LIT142 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT142)
#define _OMC_LIT143_data "FMIDER"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT143,6,_OMC_LIT143_data);
#define _OMC_LIT143 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT143)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT144,2,1) {_OMC_LIT143,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT144 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT144)
#define _OMC_LIT145_data "FMIDERINIT"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT145,10,_OMC_LIT145_data);
#define _OMC_LIT145 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT145)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT146,2,1) {_OMC_LIT145,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT146 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT146)
#define _OMC_LIT147_data "SimCodeUtil.createFMIModelStructure failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT147,42,_OMC_LIT147_data);
#define _OMC_LIT147 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT147)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT148_6,1.782113391e9);
#define _OMC_LIT148_6 MMC_REFREALLIT(_OMC_LIT_STRUCT148_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT148,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(13908)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(13908)),MMC_IMMEDIATE(MMC_TAGFIXNUM(87)),_OMC_LIT148_6}};
#define _OMC_LIT148 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT148)
#define _OMC_LIT149_data "fmiFlags"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT149,8,_OMC_LIT149_data);
#define _OMC_LIT149 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT149)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT150,1,4) {&Flags_FlagVisibility_EXTERNAL__desc,}};
#define _OMC_LIT150 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT150)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT151,2,9) {&Flags_FlagData_STRING__LIST__FLAG__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT151 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT151)
#define _OMC_LIT152_data "Add simulation flags to FMU. Will create <fmiPrefix>_flags.json in resources folder with given flags. Use --fmiFlags or --fmiFlags=none to disable [default]. Use --fmiFlags=default for the default simulation flags. To pass flags use e.g. --fmiFlags=s:cvode,nls:homotopy or --fmiFlags=path/to/yourFlags.json."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT152,307,_OMC_LIT152_data);
#define _OMC_LIT152 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT152)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT153,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(138)),_OMC_LIT149,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT151,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT152}};
#define _OMC_LIT153 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT153)
#define _OMC_LIT154_data ":"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT154,1,_OMC_LIT154_data);
#define _OMC_LIT154 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT154)
#define _OMC_LIT155_data "Can't process flag \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT155,20,_OMC_LIT155_data);
#define _OMC_LIT155 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT155)
#define _OMC_LIT156_data "\".\nSeperate flag name and flag value with \":\".\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT156,47,_OMC_LIT156_data);
#define _OMC_LIT156 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT156)
#define _OMC_LIT157_data "euler"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT157,5,_OMC_LIT157_data);
#define _OMC_LIT157 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT157)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT158,2,0) {_OMC_LIT35,_OMC_LIT157}};
#define _OMC_LIT158 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT158)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT159,2,1) {_OMC_LIT158,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT159 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT159)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT160,2,3) {&SimCode_FmiSimulationFlags_FMI__SIMULATION__FLAGS__desc,_OMC_LIT159}};
#define _OMC_LIT160 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT160)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT161,1,1) {_OMC_LIT160}};
#define _OMC_LIT161 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT161)
#define _OMC_LIT162_data "Adding unknown FMU simulation flag \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT162,36,_OMC_LIT162_data);
#define _OMC_LIT162 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT162)
#define _OMC_LIT163_data "\" ."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT163,3,_OMC_LIT163_data);
#define _OMC_LIT163 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT163)
#define _OMC_LIT164_data "Unknown value \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT164,15,_OMC_LIT164_data);
#define _OMC_LIT164 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT164)
#define _OMC_LIT165_data "\" for flag \"s\"."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT165,15,_OMC_LIT165_data);
#define _OMC_LIT165 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT165)
#define _OMC_LIT166_data "Could not find file \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT166,21,_OMC_LIT166_data);
#define _OMC_LIT166 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT166)
#define _OMC_LIT167_data "\nIgnoring \"--fmiFlags="
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT167,22,_OMC_LIT167_data);
#define _OMC_LIT167 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT167)
#define _OMC_LIT168_data "\" and using default setting.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT168,29,_OMC_LIT168_data);
#define _OMC_LIT168 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT168)
#define _OMC_LIT169_data "."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT169,1,_OMC_LIT169_data);
#define _OMC_LIT169 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT169)
#define _OMC_LIT170_data "json"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT170,4,_OMC_LIT170_data);
#define _OMC_LIT170 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT170)
#define _OMC_LIT171_data "default"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT171,7,_OMC_LIT171_data);
#define _OMC_LIT171 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT171)
#define _OMC_LIT172_data "none"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT172,4,_OMC_LIT172_data);
#define _OMC_LIT172 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT172)
#define _OMC_LIT173_data "equations:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT173,11,_OMC_LIT173_data);
#define _OMC_LIT173 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT173)
#define _OMC_LIT174_data "----------------------\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT174,23,_OMC_LIT174_data);
#define _OMC_LIT174 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT174)
#define _OMC_LIT175_data "inputVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT175,9,_OMC_LIT175_data);
#define _OMC_LIT175 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT175)
#define _OMC_LIT176_data "innerVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT176,9,_OMC_LIT176_data);
#define _OMC_LIT176 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT176)
#define _OMC_LIT177_data "outputVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT177,10,_OMC_LIT177_data);
#define _OMC_LIT177 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT177)
#define _OMC_LIT178_data "numer of all vars: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT178,19,_OMC_LIT178_data);
#define _OMC_LIT178 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT178)
#define _OMC_LIT179_data "Context\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT179,8,_OMC_LIT179_data);
#define _OMC_LIT179 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT179)
#define _OMC_LIT180_data "number of algebraic systems: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT180,29,_OMC_LIT180_data);
#define _OMC_LIT180 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT180)
#define _OMC_LIT181_data "ERROR in dumpOMSIFunc\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT181,22,_OMC_LIT181_data);
#define _OMC_LIT181 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT181)
#define _OMC_LIT182_data "OMSIFunction initialization:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT182,29,_OMC_LIT182_data);
#define _OMC_LIT182 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT182)
#define _OMC_LIT183_data "OMSIFunction simulation:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT183,25,_OMC_LIT183_data);
#define _OMC_LIT183 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT183)
#define _OMC_LIT184_data "): "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT184,3,_OMC_LIT184_data);
#define _OMC_LIT184 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT184)
#define _OMC_LIT185_data " ---> "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT185,6,_OMC_LIT185_data);
#define _OMC_LIT185 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT185)
#define _OMC_LIT186_data ","
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT186,1,_OMC_LIT186_data);
#define _OMC_LIT186 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT186)
#define _OMC_LIT187_data "------------\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT187,13,_OMC_LIT187_data);
#define _OMC_LIT187 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT187)
#define _OMC_LIT188_data "BackendVar ---> SimVar\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT188,23,_OMC_LIT188_data);
#define _OMC_LIT188 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT188)
#define _OMC_LIT189_data "\n------------\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT189,14,_OMC_LIT189_data);
#define _OMC_LIT189 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT189)
#define _OMC_LIT190_data "BackendEquation ---> SimEqSys\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT190,30,_OMC_LIT190_data);
#define _OMC_LIT190 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT190)
#define _OMC_LIT191_data "Idx: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT191,5,_OMC_LIT191_data);
#define _OMC_LIT191 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT191)
#define _OMC_LIT192_data " -- "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT192,4,_OMC_LIT192_data);
#define _OMC_LIT192 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT192)
#define _OMC_LIT193_data "Idx-ScVar-Mapping:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT193,19,_OMC_LIT193_data);
#define _OMC_LIT193 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT193)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT194,2,0) {MMC_REFSTRUCTLIT(mmc_nil),MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT194 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT194)
#define _OMC_LIT195_data "implement SES_RESIDUAL in SimCodeUtil.getSimEqSystemCrefsLHS!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT195,62,_OMC_LIT195_data);
#define _OMC_LIT195 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT195)
#define _OMC_LIT196_data "implement SES_IFEQUATION in SimCodeUtil.getSimEqSystemCrefsLHS!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT196,64,_OMC_LIT196_data);
#define _OMC_LIT196 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT196)
#define _OMC_LIT197_data "implement SES_ALGORITHM in SimCodeUtil.getSimEqSystemCrefsLHS!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT197,63,_OMC_LIT197_data);
#define _OMC_LIT197 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT197)
#define _OMC_LIT198_data "implement SES_INVERSE_ALGORITHM in SimCodeUtil.getSimEqSystemCrefsLHS!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT198,71,_OMC_LIT198_data);
#define _OMC_LIT198 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT198)
#define _OMC_LIT199_data "getSimEqSysForIndex failed!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT199,28,_OMC_LIT199_data);
#define _OMC_LIT199 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT199)
#define _OMC_LIT200_data "invalid option for getSimEqsOfSimVar\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT200,37,_OMC_LIT200_data);
#define _OMC_LIT200 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT200)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT201,2,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(3)),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT201 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT201)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT202,2,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),_OMC_LIT201}};
#define _OMC_LIT202 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT202)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT203,2,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT202}};
#define _OMC_LIT203 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT203)
#define _OMC_LIT204_data "invalid option for getSimVarsInSimEq\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT204,37,_OMC_LIT204_data);
#define _OMC_LIT204 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT204)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT205,1,4) {&SimCode_BackendMapping_NO__MAPPING__desc,}};
#define _OMC_LIT205 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT205)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT206,1,4) {&ErrorTypes_Severity_ERROR__desc,}};
#define _OMC_LIT206 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT206)
#define _OMC_LIT207_data "Internal error %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT207,17,_OMC_LIT207_data);
#define _OMC_LIT207 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT207)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT208,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(63)),_OMC_LIT72,_OMC_LIT206,_OMC_LIT207}};
#define _OMC_LIT208 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT208)
#define _OMC_LIT209_data "GetVarIndexListByMapping: No Element for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT209,41,_OMC_LIT209_data);
#define _OMC_LIT209 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT209)
#define _OMC_LIT210_data " found!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT210,7,_OMC_LIT210_data);
#define _OMC_LIT210 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT210)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT211,1,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT211 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT211)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT212,1,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */))}};
#define _OMC_LIT212 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT212)
#define _OMC_LIT213_data "Ignoring the hideResult annotation on '%s' which could not be evaluated, probably due to missing annotation(Evaluate=true)."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT213,123,_OMC_LIT213_data);
#define _OMC_LIT213 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT213)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT214,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(619)),_OMC_LIT72,_OMC_LIT73,_OMC_LIT213}};
#define _OMC_LIT214 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT214)
#define _OMC_LIT215_data "SimCodeUtil.traverseExpsEqSystem got unknown equation"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT215,53,_OMC_LIT215_data);
#define _OMC_LIT215 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT215)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT216_6,1.782113391e9);
#define _OMC_LIT216_6 MMC_REFREALLIT(_OMC_LIT_STRUCT216_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT216,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(12060)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(12060)),MMC_IMMEDIATE(MMC_TAGFIXNUM(90)),_OMC_LIT216_6}};
#define _OMC_LIT216 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT216)
#define _OMC_LIT217_data "pthreads"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT217,8,_OMC_LIT217_data);
#define _OMC_LIT217 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT217)
#define _OMC_LIT218_data "Experimental: Unused parallelization."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT218,37,_OMC_LIT218_data);
#define _OMC_LIT218 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT218)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT219,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(4)),_OMC_LIT217,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT218}};
#define _OMC_LIT219 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT219)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT220,2,0) {MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT220 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT220)
#define _OMC_LIT221_data " failure in dimensions\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT221,23,_OMC_LIT221_data);
#define _OMC_LIT221 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT221)
#define _OMC_LIT222_data " found derivative for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT222,22,_OMC_LIT222_data);
#define _OMC_LIT222 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT222)
#define _OMC_LIT223_data " in equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT223,13,_OMC_LIT223_data);
#define _OMC_LIT223 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT223)
#define _OMC_LIT224_data " = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT224,3,_OMC_LIT224_data);
#define _OMC_LIT224 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT224)
#define _OMC_LIT225_data "failtrace"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT225,9,_OMC_LIT225_data);
#define _OMC_LIT225 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT225)
#define _OMC_LIT226_data "Sets whether to print a failtrace or not."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT226,41,_OMC_LIT226_data);
#define _OMC_LIT226 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT226)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT227,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT225,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT226}};
#define _OMC_LIT227 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT227)
#define _OMC_LIT228_data " NOT contained in "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT228,18,_OMC_LIT228_data);
#define _OMC_LIT228 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT228)
#define _OMC_LIT229_data "\nFound equation containing "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT229,27,_OMC_LIT229_data);
#define _OMC_LIT229 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT229)
#define _OMC_LIT230_data " Other side: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT230,13,_OMC_LIT230_data);
#define _OMC_LIT230 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT230)
#define _OMC_LIT231_data ", extracted crefs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT231,19,_OMC_LIT231_data);
#define _OMC_LIT231 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT231)
#define _OMC_LIT232_data "der"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT232,3,_OMC_LIT232_data);
#define _OMC_LIT232 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT232)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT233,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT232}};
#define _OMC_LIT233 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT233)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT234,1,7) {&DAE_InlineType_NO__INLINE__desc,}};
#define _OMC_LIT234 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT234)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT235,1,3) {&DAE_TailCall_NO__TAIL__desc,}};
#define _OMC_LIT235 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT235)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT236,9,3) {&DAE_CallAttributes_CALL__ATTR__desc,_OMC_LIT86,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT234,_OMC_LIT235,MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT236 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT236)
#define _OMC_LIT237_data "\nFound  if equation is not supported yet  searching for varibale index\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT237,71,_OMC_LIT237_data);
#define _OMC_LIT237 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT237)
#define _OMC_LIT238_data "\nFound  algorithm is not supported yet  searching for varibale index\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT238,69,_OMC_LIT238_data);
#define _OMC_LIT238 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT238)
#define _OMC_LIT239_data "Found When eq "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT239,14,_OMC_LIT239_data);
#define _OMC_LIT239 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT239)
#define _OMC_LIT240_data " FAILURE IN flattenEqns possible unsupported equation...\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT240,57,_OMC_LIT240_data);
#define _OMC_LIT240 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT240)
#define _OMC_LIT241_data " set variabale der index\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT241,25,_OMC_LIT241_data);
#define _OMC_LIT241 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT241)
#define _OMC_LIT242_data " possible der exp: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT242,19,_OMC_LIT242_data);
#define _OMC_LIT242 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT242)
#define _OMC_LIT243_data ", "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT243,2,_OMC_LIT243_data);
#define _OMC_LIT243 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT243)
#define _OMC_LIT244_data "united variables\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT244,17,_OMC_LIT244_data);
#define _OMC_LIT244 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT244)
#define _OMC_LIT245_data "list fold variables\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT245,20,_OMC_LIT245_data);
#define _OMC_LIT245 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT245)
#define _OMC_LIT246_data " Failure in setVariableDerIndex2\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT246,33,_OMC_LIT246_data);
#define _OMC_LIT246 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT246)
#define _OMC_LIT247_data " set  variabale der index for eqsystem\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT247,39,_OMC_LIT247_data);
#define _OMC_LIT247 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT247)
#define _OMC_LIT248_data " Failure in setVariableDerIndex\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT248,32,_OMC_LIT248_data);
#define _OMC_LIT248 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT248)
#define _OMC_LIT249_data "$Old"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT249,4,_OMC_LIT249_data);
#define _OMC_LIT249 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT249)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT250,1,23) {&BackendDAE_VarKind_ALG__STATE__OLD__desc,}};
#define _OMC_LIT250 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT250)
#define _OMC_LIT251_data "SimCodeUtil.adjustStatesForInlineSolver failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT251,46,_OMC_LIT251_data);
#define _OMC_LIT251 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT251)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT252,2,1) {_OMC_LIT251,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT252 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT252)
#define _OMC_LIT253_data "SimCodeUtil.simEqSystemIndex failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT253,35,_OMC_LIT253_data);
#define _OMC_LIT253 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT253)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT254,2,1) {_OMC_LIT253,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT254 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT254)
#define _OMC_LIT255_data "Unexpected expression (should have been handled earlier, probably in the front-end. Unit/displayUnit expression is not a string literal: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT255,137,_OMC_LIT255_data);
#define _OMC_LIT255 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT255)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT256_6,1.782113391e9);
#define _OMC_LIT256_6 MMC_REFREALLIT(_OMC_LIT_STRUCT256_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT256,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(10426)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(10426)),MMC_IMMEDIATE(MMC_TAGFIXNUM(222)),_OMC_LIT256_6}};
#define _OMC_LIT256 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT256)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT257,1,3) {&Flags_FlagVisibility_INTERNAL__desc,}};
#define _OMC_LIT257 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT257)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT258,2,4) {&Flags_FlagData_BOOL__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT258 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT258)
#define _OMC_LIT259_data "Is true when building an FMU (so the compiler can look for URIs to package as FMI resources)."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT259,93,_OMC_LIT259_data);
#define _OMC_LIT259 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT259)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT260,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(114)),_OMC_LIT31,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT257,_OMC_LIT258,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT259}};
#define _OMC_LIT260 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT260)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT261,2,3) {&DAE_Exp_ICONST__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT261 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT261)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT262,1,1) {_OMC_LIT261}};
#define _OMC_LIT262 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT262)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT263,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT89}};
#define _OMC_LIT263 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT263)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT264,1,1) {_OMC_LIT263}};
#define _OMC_LIT264 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT264)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT265,2,6) {&DAE_Exp_BCONST__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT265 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT265)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT266,1,1) {_OMC_LIT265}};
#define _OMC_LIT266 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT266)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT267,2,5) {&DAE_Exp_SCONST__desc,_OMC_LIT31}};
#define _OMC_LIT267 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT267)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT268,1,1) {_OMC_LIT267}};
#define _OMC_LIT268 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT268)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT269,1,6) {&SimCodeVar_Variability_DISCRETE__desc,}};
#define _OMC_LIT269 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT269)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT270,1,3) {&SimCodeVar_Variability_CONSTANT__desc,}};
#define _OMC_LIT270 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT270)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT271,1,4) {&SimCodeVar_Variability_FIXED__desc,}};
#define _OMC_LIT271 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT271)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT272,1,6) {&SimCodeVar_Initial_CALCULATED__desc,}};
#define _OMC_LIT272 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT272)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT273,1,5) {&SimCodeVar_Initial_APPROX__desc,}};
#define _OMC_LIT273 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT273)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT274,1,4) {&SimCodeVar_Initial_EXACT__desc,}};
#define _OMC_LIT274 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT274)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT275,1,3) {&SimCodeVar_Initial_NONE__INITIAL__desc,}};
#define _OMC_LIT275 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT275)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT276,1,4) {&SimCodeVar_Causality_OUTPUT__desc,}};
#define _OMC_LIT276 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT276)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT277,1,5) {&SimCodeVar_Causality_INPUT__desc,}};
#define _OMC_LIT277 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT277)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT278,1,7) {&SimCodeVar_Causality_PARAMETER__desc,}};
#define _OMC_LIT278 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT278)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT279,1,8) {&SimCodeVar_Causality_CALCULATED__PARAMETER__desc,}};
#define _OMC_LIT279 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT279)
#define _OMC_LIT280_data "absoluteValue"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT280,13,_OMC_LIT280_data);
#define _OMC_LIT280 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT280)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT281,1,6) {&ErrorTypes_MessageType_SYMBOLIC__desc,}};
#define _OMC_LIT281 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT281)
#define _OMC_LIT282_data "Variable %s has attribute stateSelect=StateSelect.never, but was selected as a state"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT282,84,_OMC_LIT282_data);
#define _OMC_LIT282 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT282)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT283,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(593)),_OMC_LIT281,_OMC_LIT206,_OMC_LIT282}};
#define _OMC_LIT283 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT283)
#define _OMC_LIT284_data "Variable %s has attribute stateSelect=StateSelect.always, but can't be selected as a state."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT284,91,_OMC_LIT284_data);
#define _OMC_LIT284 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT284)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT285,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(592)),_OMC_LIT281,_OMC_LIT73,_OMC_LIT284}};
#define _OMC_LIT285 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT285)
#define _OMC_LIT286_data "function createCrefToSimVarHT failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT286,36,_OMC_LIT286_data);
#define _OMC_LIT286 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT286)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT287_6,1.782113391e9);
#define _OMC_LIT287_6 MMC_REFREALLIT(_OMC_LIT_STRUCT287_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT287,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9824)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9824)),MMC_IMMEDIATE(MMC_TAGFIXNUM(81)),_OMC_LIT287_6}};
#define _OMC_LIT287 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT287)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT288,1,4) {&SimCode_BaseUnit_NOBASEUNIT__desc,}};
#define _OMC_LIT288 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT288)
static _index_t _OMC_LIT289_dims[1] = {30};
static const modelica_integer _OMC_LIT289_data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
#if (defined(__clang__)  && __clang_major__ >= 17) || (defined(__GNUC__) && __GNUC__ >= 8)
static integer_array const _OMC_LIT289 = {
  1, _OMC_LIT289_dims, (void*) _OMC_LIT289_data, (modelica_boolean) 0
};
#else
/* handle joke compilers */
#define _OMC_LIT289 (base_array_t){1, _OMC_LIT289_dims, (void*) _OMC_LIT289_data, (modelica_boolean) 0}
#endif
#define _OMC_LIT290_data "Failed to update indexes of simvars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT290,35,_OMC_LIT290_data);
#define _OMC_LIT290 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT290)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT291_6,1.782113391e9);
#define _OMC_LIT291_6 MMC_REFREALLIT(_OMC_LIT_STRUCT291_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT291,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9516)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9516)),MMC_IMMEDIATE(MMC_TAGFIXNUM(86)),_OMC_LIT291_6}};
#define _OMC_LIT291 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT291)
#define _OMC_LIT292_data "\n\n*********************\n* SimCode Equations *\n*********************\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT292,69,_OMC_LIT292_data);
#define _OMC_LIT292 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT292)
#define _OMC_LIT293_data "\nallEquations:\n========================================\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT293,57,_OMC_LIT293_data);
#define _OMC_LIT293 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT293)
#define _OMC_LIT294_data "========================================\n\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT294,43,_OMC_LIT294_data);
#define _OMC_LIT294 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT294)
#define _OMC_LIT295_data "\nodeEquations ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT295,15,_OMC_LIT295_data);
#define _OMC_LIT295 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT295)
#define _OMC_LIT296_data " systems):\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT296,11,_OMC_LIT296_data);
#define _OMC_LIT296 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT296)
#define _OMC_LIT297_data "\nalgebraicEquations ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT297,21,_OMC_LIT297_data);
#define _OMC_LIT297 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT297)
#define _OMC_LIT298_data "clockPartitions ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT298,17,_OMC_LIT298_data);
#define _OMC_LIT298 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT298)
#define _OMC_LIT299_data " systems):\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT299,12,_OMC_LIT299_data);
#define _OMC_LIT299 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT299)
#define _OMC_LIT300_data "\ninitialEquations: ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT300,20,_OMC_LIT300_data);
#define _OMC_LIT300 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT300)
#define _OMC_LIT301_data "\ninitialEquations_lambda0: ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT301,28,_OMC_LIT301_data);
#define _OMC_LIT301 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT301)
#define _OMC_LIT302_data "\ninlineEquations: ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT302,19,_OMC_LIT302_data);
#define _OMC_LIT302 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT302)
#define _OMC_LIT303_data " systems)\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT303,10,_OMC_LIT303_data);
#define _OMC_LIT303 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT303)
#define _OMC_LIT304_data "symSolver"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT304,9,_OMC_LIT304_data);
#define _OMC_LIT304 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT304)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT305,2,0) {_OMC_LIT172,MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT305 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT305)
#define _OMC_LIT306_data "impEuler"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT306,8,_OMC_LIT306_data);
#define _OMC_LIT306 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT306)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT307,2,0) {_OMC_LIT306,MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT307 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT307)
#define _OMC_LIT308_data "expEuler"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT308,8,_OMC_LIT308_data);
#define _OMC_LIT308 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT308)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT309,2,0) {_OMC_LIT308,MMC_IMMEDIATE(MMC_TAGFIXNUM(2))}};
#define _OMC_LIT309 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT309)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT310,2,1) {_OMC_LIT309,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT310 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT310)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT311,2,1) {_OMC_LIT307,_OMC_LIT310}};
#define _OMC_LIT311 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT311)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT312,2,1) {_OMC_LIT305,_OMC_LIT311}};
#define _OMC_LIT312 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT312)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT313,3,10) {&Flags_FlagData_ENUM__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),_OMC_LIT312}};
#define _OMC_LIT313 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT313)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT314,2,1) {_OMC_LIT308,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT314 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT314)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT315,2,1) {_OMC_LIT306,_OMC_LIT314}};
#define _OMC_LIT315 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT315)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT316,2,1) {_OMC_LIT172,_OMC_LIT315}};
#define _OMC_LIT316 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT316)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT317,2,3) {&Flags_ValidOptions_STRING__OPTION__desc,_OMC_LIT316}};
#define _OMC_LIT317 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT317)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT318,1,1) {_OMC_LIT317}};
#define _OMC_LIT318 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT318)
#define _OMC_LIT319_data "Activates symbolic implicit solver (original system is not changed)."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT319,68,_OMC_LIT319_data);
#define _OMC_LIT319 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT319)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT320,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(61)),_OMC_LIT304,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT313,_OMC_LIT318,_OMC_LIT319}};
#define _OMC_LIT320 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT320)
#define _OMC_LIT321_data "\nremovedInitialEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT321,67,_OMC_LIT321_data);
#define _OMC_LIT321 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT321)
#define _OMC_LIT322_data "\nstartValueEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT322,63,_OMC_LIT322_data);
#define _OMC_LIT322 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT322)
#define _OMC_LIT323_data "\nnominalValueEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT323,65,_OMC_LIT323_data);
#define _OMC_LIT323 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT323)
#define _OMC_LIT324_data "\nminValueEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT324,61,_OMC_LIT324_data);
#define _OMC_LIT324 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT324)
#define _OMC_LIT325_data "\nmaxValueEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT325,61,_OMC_LIT325_data);
#define _OMC_LIT325 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT325)
#define _OMC_LIT326_data "\nparameterEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT326,62,_OMC_LIT326_data);
#define _OMC_LIT326 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT326)
#define _OMC_LIT327_data "\nremovedEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT327,60,_OMC_LIT327_data);
#define _OMC_LIT327 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT327)
#define _OMC_LIT328_data "\nalgorithmAndEquationAsserts:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT328,71,_OMC_LIT328_data);
#define _OMC_LIT328 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT328)
#define _OMC_LIT329_data "\nequationsForZeroCrossings:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT329,69,_OMC_LIT329_data);
#define _OMC_LIT329 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT329)
#define _OMC_LIT330_data "\ngeneric calls:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT330,57,_OMC_LIT330_data);
#define _OMC_LIT330 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT330)
#define _OMC_LIT331_data "\njacobianEquations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT331,61,_OMC_LIT331_data);
#define _OMC_LIT331 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT331)
#define _OMC_LIT332_data "\njacobianMatrices:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT332,60,_OMC_LIT332_data);
#define _OMC_LIT332 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT332)
#define _OMC_LIT333_data "\nmodelInfo:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT333,53,_OMC_LIT333_data);
#define _OMC_LIT333 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT333)
#define _OMC_LIT334_data "\ndaeMode:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT334,51,_OMC_LIT334_data);
#define _OMC_LIT334 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT334)
#define _OMC_LIT335_data "residual Equations:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT335,61,_OMC_LIT335_data);
#define _OMC_LIT335 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT335)
#define _OMC_LIT336_data "residualVars("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT336,13,_OMC_LIT336_data);
#define _OMC_LIT336 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT336)
#define _OMC_LIT337_data ")"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT337,1,_OMC_LIT337_data);
#define _OMC_LIT337 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT337)
#define _OMC_LIT338_data "algebraicDAEVars("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT338,17,_OMC_LIT338_data);
#define _OMC_LIT338 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT338)
#define _OMC_LIT339_data "auxVars("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT339,8,_OMC_LIT339_data);
#define _OMC_LIT339 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT339)
#define _OMC_LIT340_data "Sparsity Pattern:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT340,59,_OMC_LIT340_data);
#define _OMC_LIT340 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT340)
#define _OMC_LIT341_data "Sparsity Pattern Transposed:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT341,70,_OMC_LIT341_data);
#define _OMC_LIT341 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT341)
#define _OMC_LIT342_data "SubPartition Vars:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT342,60,_OMC_LIT342_data);
#define _OMC_LIT342 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT342)
#define _OMC_LIT343_data "partition equations:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT343,21,_OMC_LIT343_data);
#define _OMC_LIT343 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT343)
#define _OMC_LIT344_data "removedEquations equations:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT344,28,_OMC_LIT344_data);
#define _OMC_LIT344 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT344)
#define _OMC_LIT345_data "SubClock:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT345,10,_OMC_LIT345_data);
#define _OMC_LIT345 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT345)
#define _OMC_LIT346_data "Hold Events: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT346,13,_OMC_LIT346_data);
#define _OMC_LIT346 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT346)
#define _OMC_LIT347_data "true"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT347,4,_OMC_LIT347_data);
#define _OMC_LIT347 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT347)
#define _OMC_LIT348_data "false"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT348,5,_OMC_LIT348_data);
#define _OMC_LIT348 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT348)
#define _OMC_LIT349_data " "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT349,1,_OMC_LIT349_data);
#define _OMC_LIT349 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT349)
#define _OMC_LIT350_data " (PREVIOUS)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT350,11,_OMC_LIT350_data);
#define _OMC_LIT350 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT350)
#define _OMC_LIT351_data "BaseClock:\n========================================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT351,52,_OMC_LIT351_data);
#define _OMC_LIT351 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT351)
#define _OMC_LIT352_data "\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT352,2,_OMC_LIT352_data);
#define _OMC_LIT352 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT352)
#define _OMC_LIT353_data "external object info"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT353,20,_OMC_LIT353_data);
#define _OMC_LIT353 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT353)
#define _OMC_LIT354_data "external object aliase ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT354,24,_OMC_LIT354_data);
#define _OMC_LIT354 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT354)
#define _OMC_LIT355_data "	Jacobian idx: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT355,15,_OMC_LIT355_data);
#define _OMC_LIT355 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT355)
#define _OMC_LIT356_data "\n	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT356,2,_OMC_LIT356_data);
#define _OMC_LIT356 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT356)
#define _OMC_LIT357_data "columnVars("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT357,11,_OMC_LIT357_data);
#define _OMC_LIT357 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT357)
#define _OMC_LIT358_data "\nsymbolic directional derivative:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT358,34,_OMC_LIT358_data);
#define _OMC_LIT358 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT358)
#define _OMC_LIT359_data "["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT359,1,_OMC_LIT359_data);
#define _OMC_LIT359 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT359)
#define _OMC_LIT360_data "]"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT360,1,_OMC_LIT360_data);
#define _OMC_LIT360 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT360)
#define _OMC_LIT361_data "reinit("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT361,7,_OMC_LIT361_data);
#define _OMC_LIT361 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT361)
#define _OMC_LIT362_data ") ["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT362,3,_OMC_LIT362_data);
#define _OMC_LIT362 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT362)
#define _OMC_LIT363_data "assert("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT363,7,_OMC_LIT363_data);
#define _OMC_LIT363 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT363)
#define _OMC_LIT364_data "terminate("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT364,10,_OMC_LIT364_data);
#define _OMC_LIT364 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT364)
#define _OMC_LIT365_data " ["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT365,2,_OMC_LIT365_data);
#define _OMC_LIT365 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT365)
#define _OMC_LIT366_data "no simJac"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT366,9,_OMC_LIT366_data);
#define _OMC_LIT366 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT366)
#define _OMC_LIT367_data "] ->"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT367,4,_OMC_LIT367_data);
#define _OMC_LIT367 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT367)
#define _OMC_LIT368_data "	simJac:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT368,9,_OMC_LIT368_data);
#define _OMC_LIT368 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT368)
#define _OMC_LIT369_data "\n	simJac:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT369,10,_OMC_LIT369_data);
#define _OMC_LIT369 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT369)
#define _OMC_LIT370_data "\ncasual set:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT370,13,_OMC_LIT370_data);
#define _OMC_LIT370 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT370)
#define _OMC_LIT371_data ": "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT371,2,_OMC_LIT371_data);
#define _OMC_LIT371 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT371)
#define _OMC_LIT372_data " (LINEAR) index:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT372,16,_OMC_LIT372_data);
#define _OMC_LIT372 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT372)
#define _OMC_LIT373_data " jacobian: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT373,11,_OMC_LIT373_data);
#define _OMC_LIT373 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT373)
#define _OMC_LIT374_data "	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT374,1,_OMC_LIT374_data);
#define _OMC_LIT374 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT374)
#define _OMC_LIT375_data " (NONLINEAR) index:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT375,19,_OMC_LIT375_data);
#define _OMC_LIT375 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT375)
#define _OMC_LIT376_data "		crefs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT376,9,_OMC_LIT376_data);
#define _OMC_LIT376 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT376)
#define _OMC_LIT377_data " , "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT377,3,_OMC_LIT377_data);
#define _OMC_LIT377 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT377)
#define _OMC_LIT378_data " (RESIDUAL)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT378,11,_OMC_LIT378_data);
#define _OMC_LIT378 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT378)
#define _OMC_LIT379_data " (FOR_RESIDUAL)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT379,15,_OMC_LIT379_data);
#define _OMC_LIT379 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT379)
#define _OMC_LIT380_data " (GENERIC_RESIDUAL)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT380,19,_OMC_LIT380_data);
#define _OMC_LIT380 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT380)
#define _OMC_LIT381_data "="
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT381,1,_OMC_LIT381_data);
#define _OMC_LIT381 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT381)
#define _OMC_LIT382_data " [constraints: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT382,15,_OMC_LIT382_data);
#define _OMC_LIT382 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT382)
#define _OMC_LIT383_data " (IF)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT383,5,_OMC_LIT383_data);
#define _OMC_LIT383 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT383)
#define _OMC_LIT384_data "	variables:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT384,12,_OMC_LIT384_data);
#define _OMC_LIT384 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT384)
#define _OMC_LIT385_data "\n	b-vector:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT385,12,_OMC_LIT385_data);
#define _OMC_LIT385 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT385)
#define _OMC_LIT386_data "strict set:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT386,12,_OMC_LIT386_data);
#define _OMC_LIT386 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT386)
#define _OMC_LIT387_data "	variables:\n	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT387,13,_OMC_LIT387_data);
#define _OMC_LIT387 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT387)
#define _OMC_LIT388_data "	\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT388,2,_OMC_LIT388_data);
#define _OMC_LIT388 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT388)
#define _OMC_LIT389_data "crefs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT389,7,_OMC_LIT389_data);
#define _OMC_LIT389 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT389)
#define _OMC_LIT390_data " (MIXED) index:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT390,15,_OMC_LIT390_data);
#define _OMC_LIT390 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT390)
#define _OMC_LIT391_data " WHEN:( "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT391,8,_OMC_LIT391_data);
#define _OMC_LIT391 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT391)
#define _OMC_LIT392_data " ) then: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT392,9,_OMC_LIT392_data);
#define _OMC_LIT392 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT392)
#define _OMC_LIT393_data " ELSEWHEN: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT393,11,_OMC_LIT393_data);
#define _OMC_LIT393 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT393)
#define _OMC_LIT394_data " FOR-LOOP: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT394,11,_OMC_LIT394_data);
#define _OMC_LIT394 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT394)
#define _OMC_LIT395_data " for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT395,5,_OMC_LIT395_data);
#define _OMC_LIT395 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT395)
#define _OMC_LIT396_data " in ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT396,5,_OMC_LIT396_data);
#define _OMC_LIT396 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT396)
#define _OMC_LIT397_data ") loop\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT397,7,_OMC_LIT397_data);
#define _OMC_LIT397 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT397)
#define _OMC_LIT398_data "]\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT398,2,_OMC_LIT398_data);
#define _OMC_LIT398 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT398)
#define _OMC_LIT399_data "end for;"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT399,8,_OMC_LIT399_data);
#define _OMC_LIT399 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT399)
#define _OMC_LIT400_data " FOR-EQUATION: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT400,15,_OMC_LIT400_data);
#define _OMC_LIT400 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT400)
#define _OMC_LIT401_data ": alias of "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT401,11,_OMC_LIT401_data);
#define _OMC_LIT401 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT401)
#define _OMC_LIT402_data " (ALGEBRAIC_SYSTEM) algSysIndex: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT402,33,_OMC_LIT402_data);
#define _OMC_LIT402 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT402)
#define _OMC_LIT403_data "	partOfMixed system: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT403,21,_OMC_LIT403_data);
#define _OMC_LIT403 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT403)
#define _OMC_LIT404_data ", tornSystem: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT404,14,_OMC_LIT404_data);
#define _OMC_LIT404 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT404)
#define _OMC_LIT405_data ", linearSystem: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT405,16,_OMC_LIT405_data);
#define _OMC_LIT405 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT405)
#define _OMC_LIT406_data " (SES_RESIZABLE_ASSIGN) "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT406,24,_OMC_LIT406_data);
#define _OMC_LIT406 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT406)
#define _OMC_LIT407_data " call index: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT407,13,_OMC_LIT407_data);
#define _OMC_LIT407 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT407)
#define _OMC_LIT408_data " (SES_GENERIC_ASSIGN) "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT408,22,_OMC_LIT408_data);
#define _OMC_LIT408 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT408)
#define _OMC_LIT409_data "	indices: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT409,10,_OMC_LIT409_data);
#define _OMC_LIT409 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT409)
#define _OMC_LIT410_data "{"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT410,1,_OMC_LIT410_data);
#define _OMC_LIT410 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT410)
#define _OMC_LIT411_data "}"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT411,1,_OMC_LIT411_data);
#define _OMC_LIT411 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT411)
#define _OMC_LIT412_data " (SES_ENTWINED_ASSIGN)\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT412,23,_OMC_LIT412_data);
#define _OMC_LIT412 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT412)
#define _OMC_LIT413_data "	call order: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT413,13,_OMC_LIT413_data);
#define _OMC_LIT413 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT413)
#define _OMC_LIT414_data "SOMETHING DIFFERENT\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT414,20,_OMC_LIT414_data);
#define _OMC_LIT414 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT414)
#define _OMC_LIT415_data "Function: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT415,10,_OMC_LIT415_data);
#define _OMC_LIT415 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT415)
#define _OMC_LIT416_data "	outVars: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT416,10,_OMC_LIT416_data);
#define _OMC_LIT416 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT416)
#define _OMC_LIT417_data "\n	functionArguments: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT417,21,_OMC_LIT417_data);
#define _OMC_LIT417 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT417)
#define _OMC_LIT418_data "\n	variableDeclarations: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT418,24,_OMC_LIT418_data);
#define _OMC_LIT418 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT418)
#define _OMC_LIT419_data "Parallel Function: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT419,19,_OMC_LIT419_data);
#define _OMC_LIT419 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT419)
#define _OMC_LIT420_data "Kernel Function: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT420,17,_OMC_LIT420_data);
#define _OMC_LIT420 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT420)
#define _OMC_LIT421_data "External Function: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT421,19,_OMC_LIT421_data);
#define _OMC_LIT421 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT421)
#define _OMC_LIT422_data "Record: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT422,8,_OMC_LIT422_data);
#define _OMC_LIT422 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT422)
#define _OMC_LIT423_data "	funArgs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT423,10,_OMC_LIT423_data);
#define _OMC_LIT423 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT423)
#define _OMC_LIT424_data "\n	locals: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT424,10,_OMC_LIT424_data);
#define _OMC_LIT424 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT424)
#define _OMC_LIT425_data "stateVars ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT425,11,_OMC_LIT425_data);
#define _OMC_LIT425 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT425)
#define _OMC_LIT426_data "derivativeVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT426,14,_OMC_LIT426_data);
#define _OMC_LIT426 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT426)
#define _OMC_LIT427_data "algVars ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT427,9,_OMC_LIT427_data);
#define _OMC_LIT427 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT427)
#define _OMC_LIT428_data "discreteAlgVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT428,15,_OMC_LIT428_data);
#define _OMC_LIT428 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT428)
#define _OMC_LIT429_data "intAlgVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT429,10,_OMC_LIT429_data);
#define _OMC_LIT429 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT429)
#define _OMC_LIT430_data "boolAlgVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT430,11,_OMC_LIT430_data);
#define _OMC_LIT430 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT430)
#define _OMC_LIT431_data "aliasVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT431,9,_OMC_LIT431_data);
#define _OMC_LIT431 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT431)
#define _OMC_LIT432_data "intAliasVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT432,12,_OMC_LIT432_data);
#define _OMC_LIT432 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT432)
#define _OMC_LIT433_data "paramVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT433,9,_OMC_LIT433_data);
#define _OMC_LIT433 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT433)
#define _OMC_LIT434_data "intParamVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT434,12,_OMC_LIT434_data);
#define _OMC_LIT434 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT434)
#define _OMC_LIT435_data "boolParamVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT435,13,_OMC_LIT435_data);
#define _OMC_LIT435 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT435)
#define _OMC_LIT436_data "extObjVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT436,10,_OMC_LIT436_data);
#define _OMC_LIT436 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT436)
#define _OMC_LIT437_data "constVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT437,9,_OMC_LIT437_data);
#define _OMC_LIT437 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT437)
#define _OMC_LIT438_data "intConstVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT438,12,_OMC_LIT438_data);
#define _OMC_LIT438 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT438)
#define _OMC_LIT439_data "stringConstVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT439,15,_OMC_LIT439_data);
#define _OMC_LIT439 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT439)
#define _OMC_LIT440_data "functions:\n-----------\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT440,24,_OMC_LIT440_data);
#define _OMC_LIT440 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT440)
#define _OMC_LIT441_data " ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT441,2,_OMC_LIT441_data);
#define _OMC_LIT441 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT441)
#define _OMC_LIT442_data ") "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT442,2,_OMC_LIT442_data);
#define _OMC_LIT442 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT442)
#define _OMC_LIT443_data "<func> "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT443,7,_OMC_LIT443_data);
#define _OMC_LIT443 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT443)
#define _OMC_LIT444_data "<unknown>"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT444,9,_OMC_LIT444_data);
#define _OMC_LIT444 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT444)
#define _OMC_LIT445_data "\n----------------------\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT445,24,_OMC_LIT445_data);
#define _OMC_LIT445 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT445)
#define _OMC_LIT446_data "index:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT446,6,_OMC_LIT446_data);
#define _OMC_LIT446 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT446)
#define _OMC_LIT447_data " (no alias) "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT447,12,_OMC_LIT447_data);
#define _OMC_LIT447 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT447)
#define _OMC_LIT448_data " (alias: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT448,9,_OMC_LIT448_data);
#define _OMC_LIT448 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT448)
#define _OMC_LIT449_data " (negated alias: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT449,17,_OMC_LIT449_data);
#define _OMC_LIT449 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT449)
#define _OMC_LIT450_data " protected "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT450,11,_OMC_LIT450_data);
#define _OMC_LIT450 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT450)
#define _OMC_LIT451_data " hideResult "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT451,12,_OMC_LIT451_data);
#define _OMC_LIT451 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT451)
#define _OMC_LIT452_data " initial: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT452,10,_OMC_LIT452_data);
#define _OMC_LIT452 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT452)
#define _OMC_LIT453_data "	arrCref:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT453,9,_OMC_LIT453_data);
#define _OMC_LIT453 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT453)
#define _OMC_LIT454_data "	no arrCref"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT454,11,_OMC_LIT454_data);
#define _OMC_LIT454 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT454)
#define _OMC_LIT455_data " index:("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT455,8,_OMC_LIT455_data);
#define _OMC_LIT455 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT455)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT456,1,5) {&BackendDAE_VarKind_STATE__DER__desc,}};
#define _OMC_LIT456 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT456)
#define _OMC_LIT457_data "der("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT457,4,_OMC_LIT457_data);
#define _OMC_LIT457 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT457)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT458,9,3) {&NFUnit_Unit_UNIT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),_OMC_LIT1}};
#define _OMC_LIT458 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT458)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT459,1,1) {_OMC_LIT124}};
#define _OMC_LIT459 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT459)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT460,1,1) {_OMC_LIT272}};
#define _OMC_LIT460 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT460)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT461,1,1) {_OMC_LIT273}};
#define _OMC_LIT461 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT461)
#define _OMC_LIT462_data "fmiFilter"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT462,9,_OMC_LIT462_data);
#define _OMC_LIT462 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT462)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT463,2,0) {_OMC_LIT172,MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT463 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT463)
#define _OMC_LIT464_data "internal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT464,8,_OMC_LIT464_data);
#define _OMC_LIT464 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT464)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT465,2,0) {_OMC_LIT464,MMC_IMMEDIATE(MMC_TAGFIXNUM(2))}};
#define _OMC_LIT465 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT465)
#define _OMC_LIT466_data "protected"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT466,9,_OMC_LIT466_data);
#define _OMC_LIT466 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT466)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT467,2,0) {_OMC_LIT466,MMC_IMMEDIATE(MMC_TAGFIXNUM(3))}};
#define _OMC_LIT467 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT467)
#define _OMC_LIT468_data "blackBox"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT468,8,_OMC_LIT468_data);
#define _OMC_LIT468 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT468)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT469,2,0) {_OMC_LIT468,MMC_IMMEDIATE(MMC_TAGFIXNUM(4))}};
#define _OMC_LIT469 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT469)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT470,2,1) {_OMC_LIT469,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT470 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT470)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT471,2,1) {_OMC_LIT467,_OMC_LIT470}};
#define _OMC_LIT471 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT471)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT472,2,1) {_OMC_LIT465,_OMC_LIT471}};
#define _OMC_LIT472 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT472)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT473,2,1) {_OMC_LIT463,_OMC_LIT472}};
#define _OMC_LIT473 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT473)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT474,3,10) {&Flags_FlagData_ENUM__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(3)),_OMC_LIT473}};
#define _OMC_LIT474 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT474)
#define _OMC_LIT475_data "All variables are exposed, even variables introduced by the symbolic transformations. This is mainly for debugging purposes."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT475,124,_OMC_LIT475_data);
#define _OMC_LIT475 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT475)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT476,2,0) {_OMC_LIT172,_OMC_LIT475}};
#define _OMC_LIT476 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT476)
#define _OMC_LIT477_data "All model variables are exposed, including protected ones. Variables introduced by the symbolic transformations are filtered out, with minor exceptions, e.g. for state sets."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT477,173,_OMC_LIT477_data);
#define _OMC_LIT477 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT477)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT478,2,0) {_OMC_LIT464,_OMC_LIT477}};
#define _OMC_LIT478 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT478)
#define _OMC_LIT479_data "All public model variables are exposed. Internal and protected variables are filtered out, with small exceptions, e.g. for state sets."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT479,134,_OMC_LIT479_data);
#define _OMC_LIT479 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT479)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT480,2,0) {_OMC_LIT466,_OMC_LIT479}};
#define _OMC_LIT480 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT480)
#define _OMC_LIT481_data "Only the interface is exposed. All other variables are hidden or exposed with concealed names."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT481,94,_OMC_LIT481_data);
#define _OMC_LIT481 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT481)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT482,2,0) {_OMC_LIT468,_OMC_LIT481}};
#define _OMC_LIT482 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT482)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT483,2,1) {_OMC_LIT482,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT483 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT483)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT484,2,1) {_OMC_LIT480,_OMC_LIT483}};
#define _OMC_LIT484 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT484)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT485,2,1) {_OMC_LIT478,_OMC_LIT484}};
#define _OMC_LIT485 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT485)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT486,2,1) {_OMC_LIT476,_OMC_LIT485}};
#define _OMC_LIT486 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT486)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT487,2,4) {&Flags_ValidOptions_STRING__DESC__OPTION__desc,_OMC_LIT486}};
#define _OMC_LIT487 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT487)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT488,1,1) {_OMC_LIT487}};
#define _OMC_LIT488 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT488)
#define _OMC_LIT489_data "Specifies which model variables are exposed by the modelDescription.xml"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT489,71,_OMC_LIT489_data);
#define _OMC_LIT489 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT489)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT490,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(136)),_OMC_LIT462,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT474,_OMC_LIT488,_OMC_LIT489}};
#define _OMC_LIT490 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT490)
#define _OMC_LIT491_data "Failed to SimCodeUtil.extractVarFromVar of input variable"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT491,57,_OMC_LIT491_data);
#define _OMC_LIT491 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT491)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT492_6,1.782113391e9);
#define _OMC_LIT492_6 MMC_REFREALLIT(_OMC_LIT_STRUCT492_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT492,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8639)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8639)),MMC_IMMEDIATE(MMC_TAGFIXNUM(108)),_OMC_LIT492_6}};
#define _OMC_LIT492 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT492)
#define _OMC_LIT493_data "Failed to find the correct SimVar list for Var: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT493,48,_OMC_LIT493_data);
#define _OMC_LIT493 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT493)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT494_6,1.782113391e9);
#define _OMC_LIT494_6 MMC_REFREALLIT(_OMC_LIT_STRUCT494_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT494,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8730)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8730)),MMC_IMMEDIATE(MMC_TAGFIXNUM(126)),_OMC_LIT494_6}};
#define _OMC_LIT494 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT494)
#define _OMC_LIT495_data "Failed to find SimVar list for Var: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT495,36,_OMC_LIT495_data);
#define _OMC_LIT495 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT495)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT496_6,1.782113391e9);
#define _OMC_LIT496_6 MMC_REFREALLIT(_OMC_LIT_STRUCT496_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT496,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8714)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8714)),MMC_IMMEDIATE(MMC_TAGFIXNUM(116)),_OMC_LIT496_6}};
#define _OMC_LIT496 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT496)
#define _OMC_LIT497_data "Unknown value detected for --fmiFilter"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT497,38,_OMC_LIT497_data);
#define _OMC_LIT497 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT497)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT498_6,1.782113391e9);
#define _OMC_LIT498_6 MMC_REFREALLIT(_OMC_LIT_STRUCT498_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT498,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8589)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(8589)),MMC_IMMEDIATE(MMC_TAGFIXNUM(83)),_OMC_LIT498_6}};
#define _OMC_LIT498 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT498)
#define _OMC_LIT499_data "if "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT499,3,_OMC_LIT499_data);
#define _OMC_LIT499 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT499)
#define _OMC_LIT500_data " then\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT500,6,_OMC_LIT500_data);
#define _OMC_LIT500 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT500)
#define _OMC_LIT501_data "else\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT501,5,_OMC_LIT501_data);
#define _OMC_LIT501 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT501)
#define _OMC_LIT502_data "  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT502,2,_OMC_LIT502_data);
#define _OMC_LIT502 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT502)
#define _OMC_LIT503_data "end if;"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT503,7,_OMC_LIT503_data);
#define _OMC_LIT503 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT503)
#define _OMC_LIT504_data "\nend if;"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT504,8,_OMC_LIT504_data);
#define _OMC_LIT504 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT504)
#define _OMC_LIT505_data "single generic call "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT505,20,_OMC_LIT505_data);
#define _OMC_LIT505 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT505)
#define _OMC_LIT506_data "\n  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT506,3,_OMC_LIT506_data);
#define _OMC_LIT506 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT506)
#define _OMC_LIT507_data "if generic call "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT507,16,_OMC_LIT507_data);
#define _OMC_LIT507 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT507)
#define _OMC_LIT508_data "when generic call "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT508,18,_OMC_LIT508_data);
#define _OMC_LIT508 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT508)
#define _OMC_LIT509_data "force-fmi-attributes"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT509,20,_OMC_LIT509_data);
#define _OMC_LIT509 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT509)
#define _OMC_LIT510_data "Force to export all fmi attributes to the modelDescription.xml, including those which have default values"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT510,105,_OMC_LIT510_data);
#define _OMC_LIT510 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT510)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT511,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(180)),_OMC_LIT509,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT510}};
#define _OMC_LIT511 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT511)
#define _OMC_LIT512_data "exact"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT512,5,_OMC_LIT512_data);
#define _OMC_LIT512 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT512)
#define _OMC_LIT513_data "approx"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT513,6,_OMC_LIT513_data);
#define _OMC_LIT513 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT513)
#define _OMC_LIT514_data "calculated"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT514,10,_OMC_LIT514_data);
#define _OMC_LIT514 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT514)
#define _OMC_LIT515_data "disableStartCalc"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT515,16,_OMC_LIT515_data);
#define _OMC_LIT515 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT515)
#define _OMC_LIT516_data "Deactivates the pre-calculation of start values during compile-time."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT516,68,_OMC_LIT516_data);
#define _OMC_LIT516 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT516)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT517,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(120)),_OMC_LIT515,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT516}};
#define _OMC_LIT517 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT517)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT518,2,6) {&DAE_Exp_BCONST__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */))}};
#define _OMC_LIT518 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT518)
#define _OMC_LIT519_data "time"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT519,4,_OMC_LIT519_data);
#define _OMC_LIT519 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT519)
#define _OMC_LIT520_data "sample"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT520,6,_OMC_LIT520_data);
#define _OMC_LIT520 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT520)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT521,1,3) {&BackendDAE_BaseClockPartitionKind_UNKNOWN__PARTITION__desc,}};
#define _OMC_LIT521 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT521)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT522,1,4) {&Absyn_Msg_NO__MSG__desc,}};
#define _OMC_LIT522 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT522)
#define _OMC_LIT523_data "version"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT523,7,_OMC_LIT523_data);
#define _OMC_LIT523 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT523)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT524,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT523}};
#define _OMC_LIT524 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT524)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT525,1,1) {_OMC_LIT31}};
#define _OMC_LIT525 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT525)
#define _OMC_LIT526_data "__OpenModelica_author"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT526,21,_OMC_LIT526_data);
#define _OMC_LIT526 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT526)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT527,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT526}};
#define _OMC_LIT527 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT527)
#define _OMC_LIT528_data "__OpenModelica_license"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT528,22,_OMC_LIT528_data);
#define _OMC_LIT528 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT528)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT529,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT528}};
#define _OMC_LIT529 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT529)
#define _OMC_LIT530_data "__OpenModelica_copyright"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT530,24,_OMC_LIT530_data);
#define _OMC_LIT530 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT530)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT531,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT530}};
#define _OMC_LIT531 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT531)
#define _OMC_LIT532_data "createModelInfo failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT532,22,_OMC_LIT532_data);
#define _OMC_LIT532 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT532)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT533_6,1.782113391e9);
#define _OMC_LIT533_6 MMC_REFREALLIT(_OMC_LIT_STRUCT533_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT533,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7688)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7688)),MMC_IMMEDIATE(MMC_TAGFIXNUM(67)),_OMC_LIT533_6}};
#define _OMC_LIT533 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT533)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT534,1,9) {&BackendDAE_EquationKind_UNKNOWN__EQUATION__KIND__desc,}};
#define _OMC_LIT534 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT534)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT535,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT534,_OMC_LIT131}};
#define _OMC_LIT535 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT535)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT536,1,5) {&BackendDAE_EquationKind_INITIAL__EQUATION__desc,}};
#define _OMC_LIT536 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT536)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT537,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT536,_OMC_LIT131}};
#define _OMC_LIT537 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT537)
#define _OMC_LIT538_data "\nparameters in order ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT538,22,_OMC_LIT538_data);
#define _OMC_LIT538 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT538)
#define _OMC_LIT539_data "paramdlowdump"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT539,13,_OMC_LIT539_data);
#define _OMC_LIT539 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT539)
#define _OMC_LIT540_data "Enables dumping of the parameters in the order they are calculated."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT540,67,_OMC_LIT540_data);
#define _OMC_LIT540 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT540)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT541,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(57)),_OMC_LIT539,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT540}};
#define _OMC_LIT541 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT541)
#define _OMC_LIT542_data "function createMaxValueEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT542,39,_OMC_LIT542_data);
#define _OMC_LIT542 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT542)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT543_6,1.782113391e9);
#define _OMC_LIT543_6 MMC_REFREALLIT(_OMC_LIT_STRUCT543_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT543,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7350)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7350)),MMC_IMMEDIATE(MMC_TAGFIXNUM(86)),_OMC_LIT543_6}};
#define _OMC_LIT543 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT543)
#define _OMC_LIT544_data "function createMinValueEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT544,39,_OMC_LIT544_data);
#define _OMC_LIT544 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT544)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT545_6,1.782113391e9);
#define _OMC_LIT545_6 MMC_REFREALLIT(_OMC_LIT_STRUCT545_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT545,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7324)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7324)),MMC_IMMEDIATE(MMC_TAGFIXNUM(86)),_OMC_LIT545_6}};
#define _OMC_LIT545 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT545)
#define _OMC_LIT546_data "function createNominalValueEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT546,43,_OMC_LIT546_data);
#define _OMC_LIT546 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT546)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT547_6,1.782113391e9);
#define _OMC_LIT547_6 MMC_REFREALLIT(_OMC_LIT_STRUCT547_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT547,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7298)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7298)),MMC_IMMEDIATE(MMC_TAGFIXNUM(90)),_OMC_LIT547_6}};
#define _OMC_LIT547 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT547)
#define _OMC_LIT548_data "function createValueEquationsShared failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT548,42,_OMC_LIT548_data);
#define _OMC_LIT548 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT548)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT549_6,1.782113391e9);
#define _OMC_LIT549_6 MMC_REFREALLIT(_OMC_LIT_STRUCT549_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT549,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7272)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7272)),MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT549_6}};
#define _OMC_LIT549 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT549)
#define _OMC_LIT550_data "function createStartValueEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT550,41,_OMC_LIT550_data);
#define _OMC_LIT550 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT550)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT551_6,1.782113391e9);
#define _OMC_LIT551_6 MMC_REFREALLIT(_OMC_LIT_STRUCT551_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT551,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7239)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7239)),MMC_IMMEDIATE(MMC_TAGFIXNUM(88)),_OMC_LIT551_6}};
#define _OMC_LIT551 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT551)
#define _OMC_LIT552_data "function dlowEqToSimEqSystem failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT552,36,_OMC_LIT552_data);
#define _OMC_LIT552 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT552)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT553_6,1.782113391e9);
#define _OMC_LIT553_6 MMC_REFREALLIT(_OMC_LIT_STRUCT553_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT553,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7193)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7193)),MMC_IMMEDIATE(MMC_TAGFIXNUM(85)),_OMC_LIT553_6}};
#define _OMC_LIT553 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT553)
#define _OMC_LIT554_data "Inverse Algorithm needs to be solved for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT554,41,_OMC_LIT554_data);
#define _OMC_LIT554 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT554)
#define _OMC_LIT555_data " in\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT555,4,_OMC_LIT555_data);
#define _OMC_LIT555 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT555)
#define _OMC_LIT556_data "Discrete variables are not supported yet."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT556,41,_OMC_LIT556_data);
#define _OMC_LIT556 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT556)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT557_6,1.782113391e9);
#define _OMC_LIT557_6 MMC_REFREALLIT(_OMC_LIT_STRUCT557_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT557,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7014)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7014)),MMC_IMMEDIATE(MMC_TAGFIXNUM(164)),_OMC_LIT557_6}};
#define _OMC_LIT557 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT557)
#define _OMC_LIT558_data "function createSingleAlgorithmCode failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT558,41,_OMC_LIT558_data);
#define _OMC_LIT558 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT558)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT559_6,1.782113391e9);
#define _OMC_LIT559_6 MMC_REFREALLIT(_OMC_LIT_STRUCT559_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT559,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7019)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7019)),MMC_IMMEDIATE(MMC_TAGFIXNUM(88)),_OMC_LIT559_6}};
#define _OMC_LIT559 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT559)
#define _OMC_LIT560_data "$TMP_"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT560,5,_OMC_LIT560_data);
#define _OMC_LIT560 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT560)
#define _OMC_LIT561_data "solving array equation: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT561,24,_OMC_LIT561_data);
#define _OMC_LIT561 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT561)
#define _OMC_LIT562_data "\nfor variable: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT562,15,_OMC_LIT562_data);
#define _OMC_LIT562 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT562)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT563_6,1.782113391e9);
#define _OMC_LIT563_6 MMC_REFREALLIT(_OMC_LIT_STRUCT563_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT563,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6907)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6907)),MMC_IMMEDIATE(MMC_TAGFIXNUM(48)),_OMC_LIT563_6}};
#define _OMC_LIT563 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT563)
#define _OMC_LIT564_data "$stateSelectionSet"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT564,18,_OMC_LIT564_data);
#define _OMC_LIT564 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT564)
#define _OMC_LIT565_data "$initialStateSelect"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT565,19,_OMC_LIT565_data);
#define _OMC_LIT565 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT565)
#define _OMC_LIT566_data "_"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT566,1,_OMC_LIT566_data);
#define _OMC_LIT566 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT566)
#define _OMC_LIT567_data "function createSingleComplexEqnCode2 failed for: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT567,49,_OMC_LIT567_data);
#define _OMC_LIT567 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT567)
#define _OMC_LIT568_data " solve for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT568,11,_OMC_LIT568_data);
#define _OMC_LIT568 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT568)
#define _OMC_LIT569_data "No support of solving not real variables with a non-linear solver. Equation:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT569,77,_OMC_LIT569_data);
#define _OMC_LIT569 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT569)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT570_6,1.782113391e9);
#define _OMC_LIT570_6 MMC_REFREALLIT(_OMC_LIT_STRUCT570_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT570,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6453)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6453)),MMC_IMMEDIATE(MMC_TAGFIXNUM(46)),_OMC_LIT570_6}};
#define _OMC_LIT570 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT570)
#define _OMC_LIT571_data "complex equations currently only supported on form v = functioncall(...). Equation: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT571,84,_OMC_LIT571_data);
#define _OMC_LIT571 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT571)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT572_6,1.782113391e9);
#define _OMC_LIT572_6 MMC_REFREALLIT(_OMC_LIT_STRUCT572_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT572,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6468)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6468)),MMC_IMMEDIATE(MMC_TAGFIXNUM(46)),_OMC_LIT572_6}};
#define _OMC_LIT572 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT572)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT573,1,6) {&BackendDAE_BackendDAEType_ARRAYSYSTEM__desc,}};
#define _OMC_LIT573 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT573)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT574,1,4) {&BackendDAE_IndexReduction_NO__INDEX__REDUCTION__desc,}};
#define _OMC_LIT574 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT574)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT575,1,3) {&BackendDAE_EquationConstraints_ALLOW__UNDERCONSTRAINED__desc,}};
#define _OMC_LIT575 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT575)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT576,2,0) {_OMC_LIT574,_OMC_LIT575}};
#define _OMC_LIT576 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT576)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT577,1,1) {_OMC_LIT576}};
#define _OMC_LIT577 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT577)
#define _OMC_LIT578_data "SimCodeUtil.createEquationfromList failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT578,42,_OMC_LIT578_data);
#define _OMC_LIT578 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT578)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT579_6,1.782113391e9);
#define _OMC_LIT579_6 MMC_REFREALLIT(_OMC_LIT_STRUCT579_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT579,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6368)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6368)),MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT579_6}};
#define _OMC_LIT579 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT579)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT580_6,1.782113391e9);
#define _OMC_LIT580_6 MMC_REFREALLIT(_OMC_LIT_STRUCT580_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT580,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6290)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6290)),MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT580_6}};
#define _OMC_LIT580 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT580)
#define _OMC_LIT581_data "SimCodeUtil.createSingleIfEqnCode failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT581,41,_OMC_LIT581_data);
#define _OMC_LIT581 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT581)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT582_6,1.782113391e9);
#define _OMC_LIT582_6 MMC_REFREALLIT(_OMC_LIT_STRUCT582_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT582,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6249)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6249)),MMC_IMMEDIATE(MMC_TAGFIXNUM(88)),_OMC_LIT582_6}};
#define _OMC_LIT582 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT582)
#define _OMC_LIT583_data "function createSingleWhenEqnCode failed. When equations currently only supported on form v = ..."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT583,96,_OMC_LIT583_data);
#define _OMC_LIT583 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT583)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT584_6,1.782113391e9);
#define _OMC_LIT584_6 MMC_REFREALLIT(_OMC_LIT_STRUCT584_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT584,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6167)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6167)),MMC_IMMEDIATE(MMC_TAGFIXNUM(145)),_OMC_LIT584_6}};
#define _OMC_LIT584 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT584)
#define _OMC_LIT585_data "function extractDiscreteModelVars failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT585,40,_OMC_LIT585_data);
#define _OMC_LIT585 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT585)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT586_6,1.782113391e9);
#define _OMC_LIT586_6 MMC_REFREALLIT(_OMC_LIT_STRUCT586_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT586,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6050)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6050)),MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT586_6}};
#define _OMC_LIT586 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT586)
#define _OMC_LIT587_data "function createAlgorithmAndEquationAsserts failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT587,49,_OMC_LIT587_data);
#define _OMC_LIT587 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT587)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT588_6,1.782113391e9);
#define _OMC_LIT588_6 MMC_REFREALLIT(_OMC_LIT_STRUCT588_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT588,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6004)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(6004)),MMC_IMMEDIATE(MMC_TAGFIXNUM(98)),_OMC_LIT588_6}};
#define _OMC_LIT588 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT588)
#define _OMC_LIT589_data "function extractDelayedExpressions failed: initialPoints and initialValues of spatialDistribution are not of the same size."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT589,123,_OMC_LIT589_data);
#define _OMC_LIT589 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT589)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT590_6,1.782113391e9);
#define _OMC_LIT590_6 MMC_REFREALLIT(_OMC_LIT_STRUCT590_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT590,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5908)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5908)),MMC_IMMEDIATE(MMC_TAGFIXNUM(174)),_OMC_LIT590_6}};
#define _OMC_LIT590 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT590)
#define _OMC_LIT591_data "spatialDistribution"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT591,19,_OMC_LIT591_data);
#define _OMC_LIT591 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT591)
#define _OMC_LIT592_data "delay"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT592,5,_OMC_LIT592_data);
#define _OMC_LIT592 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT592)
#define _OMC_LIT593_data "function extractDelayedExpressions failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT593,41,_OMC_LIT593_data);
#define _OMC_LIT593 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT593)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT594_6,1.782113391e9);
#define _OMC_LIT594_6 MMC_REFREALLIT(_OMC_LIT_STRUCT594_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT594,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5837)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5837)),MMC_IMMEDIATE(MMC_TAGFIXNUM(90)),_OMC_LIT594_6}};
#define _OMC_LIT594 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT594)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT595,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT592}};
#define _OMC_LIT595 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT595)
#define _OMC_LIT596_data "create sparse pattern for algebraic loop time: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT596,47,_OMC_LIT596_data);
#define _OMC_LIT596 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT596)
#define _OMC_LIT597_data "---+++ SparsePattern +++---"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT597,27,_OMC_LIT597_data);
#define _OMC_LIT597 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT597)
#define _OMC_LIT598_data "symjacdumpverbose"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT598,17,_OMC_LIT598_data);
#define _OMC_LIT598 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT598)
#define _OMC_LIT599_data "Dumps information in verbose mode about symbolic Jacobians."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT599,59,_OMC_LIT599_data);
#define _OMC_LIT599 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT599)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT600,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(46)),_OMC_LIT598,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT599}};
#define _OMC_LIT600 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT600)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT601,1,15) {&BackendDAE_VarKind_SEED__VAR__desc,}};
#define _OMC_LIT601 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT601)
#define _OMC_LIT602_data "\n---+++ seedVars variables +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT602,34,_OMC_LIT602_data);
#define _OMC_LIT602 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT602)
#define _OMC_LIT603_data "\n---+++ indexVars variables +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT603,35,_OMC_LIT603_data);
#define _OMC_LIT603 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT603)
#define _OMC_LIT604_data "created sparse pattern for algebraic loop time: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT604,48,_OMC_LIT604_data);
#define _OMC_LIT604 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT604)
#define _OMC_LIT605_data "analytical Jacobians -> creating SimCode equations for Matrix "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT605,62,_OMC_LIT605_data);
#define _OMC_LIT605 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT605)
#define _OMC_LIT606_data " time: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT606,7,_OMC_LIT606_data);
#define _OMC_LIT606 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT606)
#define _OMC_LIT607_data "analytical Jacobians -> created all SimCode equations for Matrix "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT607,65,_OMC_LIT607_data);
#define _OMC_LIT607 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT607)
#define _OMC_LIT608_data "dummyVar"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT608,8,_OMC_LIT608_data);
#define _OMC_LIT608 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT608)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT609,1,14) {&BackendDAE_VarKind_JAC__TMP__VAR__desc,}};
#define _OMC_LIT609 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT609)
#define _OMC_LIT610_data "\n---+++ all column variables +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT610,36,_OMC_LIT610_data);
#define _OMC_LIT610 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT610)
#define _OMC_LIT611_data "analytical Jacobians -> create all SimCode vars for Matrix "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT611,59,_OMC_LIT611_data);
#define _OMC_LIT611 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT611)
#define _OMC_LIT612_data "analytical Jacobians -> transformed to SimCode for Matrix "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT612,58,_OMC_LIT612_data);
#define _OMC_LIT612 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT612)
#define _OMC_LIT613_data "\nJacobian OMSIFunction"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT613,22,_OMC_LIT613_data);
#define _OMC_LIT613 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT613)
#define _OMC_LIT614_data "\nLocal jacobian hash table:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT614,28,_OMC_LIT614_data);
#define _OMC_LIT614 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT614)
#define _OMC_LIT615_data "function createSymbolicSimulationJacobian failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT615,49,_OMC_LIT615_data);
#define _OMC_LIT615 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT615)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT616_6,1.782113391e9);
#define _OMC_LIT616_6 MMC_REFREALLIT(_OMC_LIT_STRUCT616_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT616,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5758)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5758)),MMC_IMMEDIATE(MMC_TAGFIXNUM(59)),_OMC_LIT616_6}};
#define _OMC_LIT616 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT616)
#define _OMC_LIT617_data "symjacdump"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT617,10,_OMC_LIT617_data);
#define _OMC_LIT617 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT617)
#define _OMC_LIT618_data "Dumps information about symbolic Jacobians."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT618,43,_OMC_LIT618_data);
#define _OMC_LIT618 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT618)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT619,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(45)),_OMC_LIT617,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT618}};
#define _OMC_LIT619 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT619)
#define _OMC_LIT620_data "Row   "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT620,6,_OMC_LIT620_data);
#define _OMC_LIT620 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT620)
#define _OMC_LIT621_data "Cols: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT621,6,_OMC_LIT621_data);
#define _OMC_LIT621 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT621)
#define _OMC_LIT622_data "\nindex :"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT622,8,_OMC_LIT622_data);
#define _OMC_LIT622 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT622)
#define _OMC_LIT623_data "=>"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT623,2,_OMC_LIT623_data);
#define _OMC_LIT623 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT623)
#define _OMC_LIT624_data "\n*********"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT624,10,_OMC_LIT624_data);
#define _OMC_LIT624 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT624)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT625,1,3) {&SimCodeVar_Causality_NONECAUS__desc,}};
#define _OMC_LIT625 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT625)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT626,1,1) {_OMC_LIT625}};
#define _OMC_LIT626 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT626)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT627,1,13) {&BackendDAE_VarKind_JAC__VAR__desc,}};
#define _OMC_LIT627 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT627)
#define _OMC_LIT628_data "function createAllDiffedSimVars failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT628,38,_OMC_LIT628_data);
#define _OMC_LIT628 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT628)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT629_6,1.782113391e9);
#define _OMC_LIT629_6 MMC_REFREALLIT(_OMC_LIT_STRUCT629_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT629,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5322)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5322)),MMC_IMMEDIATE(MMC_TAGFIXNUM(85)),_OMC_LIT629_6}};
#define _OMC_LIT629 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT629)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT630,16,3) {&SimCode_JacobianMatrix_JAC__MATRIX__desc,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT31,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(-1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT630 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT630)
#define _OMC_LIT631_data "Start sparse pattern without analytical Jacobians\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT631,50,_OMC_LIT631_data);
#define _OMC_LIT631 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT631)
#define _OMC_LIT632_data "diffCrefs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT632,11,_OMC_LIT632_data);
#define _OMC_LIT632 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT632)
#define _OMC_LIT633_data "\n---+++  seedVars +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT633,25,_OMC_LIT633_data);
#define _OMC_LIT633 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT633)
#define _OMC_LIT634_data "diffedCrefs: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT634,13,_OMC_LIT634_data);
#define _OMC_LIT634 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT634)
#define _OMC_LIT635_data "\n---+++  indexVars +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT635,26,_OMC_LIT635_data);
#define _OMC_LIT635 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT635)
#define _OMC_LIT636_data "\n---+++  sparse pattern vars +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT636,36,_OMC_LIT636_data);
#define _OMC_LIT636 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT636)
#define _OMC_LIT637_data "\n---+++  sparse pattern transpose +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT637,41,_OMC_LIT637_data);
#define _OMC_LIT637 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT637)
#define _OMC_LIT638_data "\n---+++ second columnVars +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT638,33,_OMC_LIT638_data);
#define _OMC_LIT638 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT638)
#define _OMC_LIT639_data "analytical Jacobians -> create column variables for matrix "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT639,59,_OMC_LIT639_data);
#define _OMC_LIT639 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT639)
#define _OMC_LIT640_data "\n---+++  columnVars +++---\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT640,27,_OMC_LIT640_data);
#define _OMC_LIT640 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT640)
#define _OMC_LIT641_data "Generation of symbolic matrix SimCode (SimCodeUtil.createSymbolicJacobianssSimCode) failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT641,90,_OMC_LIT641_data);
#define _OMC_LIT641 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT641)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT642_6,1.782113391e9);
#define _OMC_LIT642_6 MMC_REFREALLIT(_OMC_LIT_STRUCT642_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT642,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5236)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5236)),MMC_IMMEDIATE(MMC_TAGFIXNUM(139)),_OMC_LIT642_6}};
#define _OMC_LIT642 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT642)
#define _OMC_LIT643_data "A"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT643,1,_OMC_LIT643_data);
#define _OMC_LIT643 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT643)
#define _OMC_LIT644_data "B"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT644,1,_OMC_LIT644_data);
#define _OMC_LIT644 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT644)
#define _OMC_LIT645_data "C"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT645,1,_OMC_LIT645_data);
#define _OMC_LIT645 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT645)
#define _OMC_LIT646_data "D"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT646,1,_OMC_LIT646_data);
#define _OMC_LIT646 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT646)
#define _OMC_LIT647_data "F"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT647,1,_OMC_LIT647_data);
#define _OMC_LIT647 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT647)
#define _OMC_LIT648_data "H"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT648,1,_OMC_LIT648_data);
#define _OMC_LIT648 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT648)
#define _OMC_LIT649_data "ADJ"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT649,3,_OMC_LIT649_data);
#define _OMC_LIT649 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT649)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT650,2,1) {_OMC_LIT649,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT650 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT650)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT651,2,1) {_OMC_LIT648,_OMC_LIT650}};
#define _OMC_LIT651 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT651)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT652,2,1) {_OMC_LIT647,_OMC_LIT651}};
#define _OMC_LIT652 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT652)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT653,2,1) {_OMC_LIT646,_OMC_LIT652}};
#define _OMC_LIT653 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT653)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT654,2,1) {_OMC_LIT645,_OMC_LIT653}};
#define _OMC_LIT654 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT654)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT655,2,1) {_OMC_LIT644,_OMC_LIT654}};
#define _OMC_LIT655 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT655)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT656,2,1) {_OMC_LIT643,_OMC_LIT655}};
#define _OMC_LIT656 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT656)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT657,2,1) {_OMC_LIT646,_OMC_LIT651}};
#define _OMC_LIT657 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT657)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT658,2,1) {_OMC_LIT645,_OMC_LIT657}};
#define _OMC_LIT658 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT658)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT659,2,1) {_OMC_LIT644,_OMC_LIT658}};
#define _OMC_LIT659 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT659)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT660,2,1) {_OMC_LIT643,_OMC_LIT659}};
#define _OMC_LIT660 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT660)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT661,2,1) {_OMC_LIT646,_OMC_LIT650}};
#define _OMC_LIT661 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT661)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT662,2,1) {_OMC_LIT645,_OMC_LIT661}};
#define _OMC_LIT662 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT662)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT663,2,1) {_OMC_LIT644,_OMC_LIT662}};
#define _OMC_LIT663 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT663)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT664,2,1) {_OMC_LIT643,_OMC_LIT663}};
#define _OMC_LIT664 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT664)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT665_6,1.782113391e9);
#define _OMC_LIT665_6 MMC_REFREALLIT(_OMC_LIT_STRUCT665_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT665,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4863)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4863)),MMC_IMMEDIATE(MMC_TAGFIXNUM(61)),_OMC_LIT665_6}};
#define _OMC_LIT665 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT665)
#define _OMC_LIT666_data "function createStateSetsSets failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT666,36,_OMC_LIT666_data);
#define _OMC_LIT666 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT666)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT667_6,1.782113391e9);
#define _OMC_LIT667_6 MMC_REFREALLIT(_OMC_LIT_STRUCT667_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT667,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4687)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4687)),MMC_IMMEDIATE(MMC_TAGFIXNUM(59)),_OMC_LIT667_6}};
#define _OMC_LIT667 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT667)
#define _OMC_LIT668_data "indexReductionMethod"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT668,20,_OMC_LIT668_data);
#define _OMC_LIT668 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT668)
#define _OMC_LIT669_data "dynamicStateSelection"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT669,21,_OMC_LIT669_data);
#define _OMC_LIT669 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT669)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT670,2,8) {&Flags_FlagData_STRING__FLAG__desc,_OMC_LIT669}};
#define _OMC_LIT670 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT670)
#define _OMC_LIT671_data "Skip index reduction"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT671,20,_OMC_LIT671_data);
#define _OMC_LIT671 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT671)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT672,2,0) {_OMC_LIT172,_OMC_LIT671}};
#define _OMC_LIT672 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT672)
#define _OMC_LIT673_data "uode"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT673,4,_OMC_LIT673_data);
#define _OMC_LIT673 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT673)
#define _OMC_LIT674_data "Use the underlying ODE without the constraints."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT674,47,_OMC_LIT674_data);
#define _OMC_LIT674 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT674)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT675,2,0) {_OMC_LIT673,_OMC_LIT674}};
#define _OMC_LIT675 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT675)
#define _OMC_LIT676_data "Simple index reduction method, select (dynamic) dummy states based on analysis of the system."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT676,93,_OMC_LIT676_data);
#define _OMC_LIT676 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT676)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT677,2,0) {_OMC_LIT669,_OMC_LIT676}};
#define _OMC_LIT677 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT677)
#define _OMC_LIT678_data "dummyDerivatives"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT678,16,_OMC_LIT678_data);
#define _OMC_LIT678 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT678)
#define _OMC_LIT679_data "Simple index reduction method, select (static) dummy states based on heuristic."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT679,79,_OMC_LIT679_data);
#define _OMC_LIT679 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT679)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT680,2,0) {_OMC_LIT678,_OMC_LIT679}};
#define _OMC_LIT680 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT680)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT681,2,1) {_OMC_LIT680,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT681 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT681)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT682,2,1) {_OMC_LIT677,_OMC_LIT681}};
#define _OMC_LIT682 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT682)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT683,2,1) {_OMC_LIT675,_OMC_LIT682}};
#define _OMC_LIT683 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT683)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT684,2,1) {_OMC_LIT672,_OMC_LIT683}};
#define _OMC_LIT684 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT684)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT685,2,4) {&Flags_ValidOptions_STRING__DESC__OPTION__desc,_OMC_LIT684}};
#define _OMC_LIT685 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT685)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT686,1,1) {_OMC_LIT685}};
#define _OMC_LIT686 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT686)
#define _OMC_LIT687_data "Sets the index reduction method to use. See --help=optmodules for more info."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT687,76,_OMC_LIT687_data);
#define _OMC_LIT687 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT687)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT688,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(15)),_OMC_LIT668,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT670,_OMC_LIT686,_OMC_LIT687}};
#define _OMC_LIT688 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT688)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT689,1,27) {&BackendDAE_VarKind_LOOP__SOLVED__desc,}};
#define _OMC_LIT689 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT689)
#define _OMC_LIT690_data "- "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT690,2,_OMC_LIT690_data);
#define _OMC_LIT690 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT690)
#define _OMC_LIT691_data " could not resolved for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT691,24,_OMC_LIT691_data);
#define _OMC_LIT691 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT691)
#define _OMC_LIT692_data " in SimCodeUtil.generateSingleEquation"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT692,38,_OMC_LIT692_data);
#define _OMC_LIT692 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT692)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT693_6,1.782113391e9);
#define _OMC_LIT693_6 MMC_REFREALLIT(_OMC_LIT_STRUCT693_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT693,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4437)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4438)),MMC_IMMEDIATE(MMC_TAGFIXNUM(123)),_OMC_LIT693_6}};
#define _OMC_LIT693 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT693)
#define _OMC_LIT694_data "Else when equation not implemented in SimCodeUtil.generateSingleEquation"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT694,72,_OMC_LIT694_data);
#define _OMC_LIT694 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT694)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT695_6,1.782113391e9);
#define _OMC_LIT695_6 MMC_REFREALLIT(_OMC_LIT_STRUCT695_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT695,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4447)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4447)),MMC_IMMEDIATE(MMC_TAGFIXNUM(121)),_OMC_LIT695_6}};
#define _OMC_LIT695 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT695)
#define _OMC_LIT696_data " not implemented SimCodeUtil.generateSingleEquation"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT696,51,_OMC_LIT696_data);
#define _OMC_LIT696 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT696)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT697_6,1.782113391e9);
#define _OMC_LIT697_6 MMC_REFREALLIT(_OMC_LIT_STRUCT697_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT697,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4471)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4471)),MMC_IMMEDIATE(MMC_TAGFIXNUM(111)),_OMC_LIT697_6}};
#define _OMC_LIT697 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT697)
#define _OMC_LIT698_data "A torn linear system has no symbolic jacobian and currently there are no means to solve that numerically. Please compile with the module \"calculateStrongComponentJacobians\" to provide symbolic jacobians for torn linear systems."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT698,227,_OMC_LIT698_data);
#define _OMC_LIT698 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT698)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT699,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(289)),_OMC_LIT281,_OMC_LIT206,_OMC_LIT698}};
#define _OMC_LIT699 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT699)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT700,1,26) {&BackendDAE_VarKind_LOOP__ITERATION__desc,}};
#define _OMC_LIT700 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT700)
#define _OMC_LIT701_data "Function SimCodeUtil.generateEquationsForComponentsAlgSystem:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT701,62,_OMC_LIT701_data);
#define _OMC_LIT701 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT701)
#define _OMC_LIT702_data "AlgSystem loopIterationVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT702,27,_OMC_LIT702_data);
#define _OMC_LIT702 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT702)
#define _OMC_LIT703_data "AlgSystem loopSolvedVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT703,24,_OMC_LIT703_data);
#define _OMC_LIT703 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT703)
#define _OMC_LIT704_data "\nEquation system omsiFunction"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT704,29,_OMC_LIT704_data);
#define _OMC_LIT704 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT704)
#define _OMC_LIT705_data " - case for component "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT705,22,_OMC_LIT705_data);
#define _OMC_LIT705 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT705)
#define _OMC_LIT706_data " not implemented in SimCodeUtil.createAllEquationOMSI"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT706,53,_OMC_LIT706_data);
#define _OMC_LIT706 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT706)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT707_6,1.782113391e9);
#define _OMC_LIT707_6 MMC_REFREALLIT(_OMC_LIT_STRUCT707_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT707,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4329)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4329)),MMC_IMMEDIATE(MMC_TAGFIXNUM(166)),_OMC_LIT707_6}};
#define _OMC_LIT707 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT707)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT708,2,12) {&SimCodeFunction_Context_OMSI__CONTEXT__desc,MMC_REFSTRUCTLIT(mmc_none)}};
#define _OMC_LIT708 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT708)
#define _OMC_LIT709_data "InputVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT709,9,_OMC_LIT709_data);
#define _OMC_LIT709 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT709)
#define _OMC_LIT710_data "InnerVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT710,9,_OMC_LIT710_data);
#define _OMC_LIT710 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT710)
#define _OMC_LIT711_data "OutputVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT711,10,_OMC_LIT711_data);
#define _OMC_LIT711 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT711)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT712,8,3) {&SimCode_OMSIFunction_OMSI__FUNCTION__desc,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),_OMC_LIT708,MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT712 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT712)
#define _OMC_LIT713_data "The matching information is missing in function createAllEquationOMSI!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT713,70,_OMC_LIT713_data);
#define _OMC_LIT713 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT713)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT714_6,1.782113391e9);
#define _OMC_LIT714_6 MMC_REFREALLIT(_OMC_LIT_STRUCT714_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT714,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4093)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(4093)),MMC_IMMEDIATE(MMC_TAGFIXNUM(117)),_OMC_LIT714_6}};
#define _OMC_LIT714 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT714)
#define _OMC_LIT715_data "SimCodeUtil.createTornSystemInnerEqns1 failed for\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT715,50,_OMC_LIT715_data);
#define _OMC_LIT715 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT715)
#define _OMC_LIT716_data "Eqn: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT716,5,_OMC_LIT716_data);
#define _OMC_LIT716 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT716)
#define _OMC_LIT717_data " Vars: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT717,7,_OMC_LIT717_data);
#define _OMC_LIT717 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT717)
#define _OMC_LIT718_data " ;\n  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT718,5,_OMC_LIT718_data);
#define _OMC_LIT718 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT718)
#define _OMC_LIT719_data "\n[\n  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT719,5,_OMC_LIT719_data);
#define _OMC_LIT719 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT719)
#define _OMC_LIT720_data "\n]\n  *\n[\n  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT720,11,_OMC_LIT720_data);
#define _OMC_LIT720 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT720)
#define _OMC_LIT721_data "\n]\n  =\n[\n  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT721,11,_OMC_LIT721_data);
#define _OMC_LIT721 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT721)
#define _OMC_LIT722_data "\n]"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT722,2,_OMC_LIT722_data);
#define _OMC_LIT722 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT722)
#define _OMC_LIT723_data "The linear system: %1\n might be structurally or numerically singular for variable %3 since U(%2,%2) = 0.0. It might be hard to solve. Compilation continues anyway."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT723,163,_OMC_LIT723_data);
#define _OMC_LIT723 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT723)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT724,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(181)),_OMC_LIT281,_OMC_LIT73,_OMC_LIT723}};
#define _OMC_LIT724 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT724)
#define _OMC_LIT725_data " ; "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT725,3,_OMC_LIT725_data);
#define _OMC_LIT725 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT725)
#define _OMC_LIT726_data "] * ["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT726,5,_OMC_LIT726_data);
#define _OMC_LIT726 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT726)
#define _OMC_LIT727_data "] = ["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT727,5,_OMC_LIT727_data);
#define _OMC_LIT727 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT727)
#define _OMC_LIT728_data "Linear solver (%s) returned invalid input for linear system %s."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT728,63,_OMC_LIT728_data);
#define _OMC_LIT728 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT728)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT729,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(180)),_OMC_LIT281,_OMC_LIT206,_OMC_LIT728}};
#define _OMC_LIT729 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT729)
#define _OMC_LIT730_data "LAPACK/dgesv"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT730,12,_OMC_LIT730_data);
#define _OMC_LIT730 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT730)
#define _OMC_LIT731_data "function createOdeSystem2 create linear system(const jacobian).\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT731,64,_OMC_LIT731_data);
#define _OMC_LIT731 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT731)
#define _OMC_LIT732_data "function createOdeSystem2 create linear system with jacobian.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT732,62,_OMC_LIT732_data);
#define _OMC_LIT732 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT732)
#define _OMC_LIT733_data "function createOdeSystem2 create non-linear system with jacobian."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT733,65,_OMC_LIT733_data);
#define _OMC_LIT733 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT733)
#define _OMC_LIT734_data "function createOdeSystem2 create non-linear system without jacobian."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT734,68,_OMC_LIT734_data);
#define _OMC_LIT734 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT734)
#define _OMC_LIT735_data "createOdeSystem2 failed for "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT735,28,_OMC_LIT735_data);
#define _OMC_LIT735 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT735)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT736_6,1.782113391e9);
#define _OMC_LIT736_6 MMC_REFREALLIT(_OMC_LIT_STRUCT736_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT736,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3648)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3648)),MMC_IMMEDIATE(MMC_TAGFIXNUM(48)),_OMC_LIT736_6}};
#define _OMC_LIT736 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT736)
#define _OMC_LIT737_data "function createOdeSystem create continuous system.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT737,51,_OMC_LIT737_data);
#define _OMC_LIT737 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT737)
#define _OMC_LIT738_data "BIPARITEGRPAH_LS_"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT738,17,_OMC_LIT738_data);
#define _OMC_LIT738 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT738)
#define _OMC_LIT739_data "graphml"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT739,7,_OMC_LIT739_data);
#define _OMC_LIT739 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT739)
#define _OMC_LIT740_data "Dumps .graphml files for the bipartite graph after Index Reduction and a task graph for the SCCs. Can be displayed with yEd. "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT740,125,_OMC_LIT740_data);
#define _OMC_LIT740 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT740)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT741,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(116)),_OMC_LIT739,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT740}};
#define _OMC_LIT741 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT741)
#define _OMC_LIT742_data "BIPARITEGRPAH_TS_"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT742,17,_OMC_LIT742_data);
#define _OMC_LIT742 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT742)
#define _OMC_LIT743_data "function createOdeSystem failed for component "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT743,46,_OMC_LIT743_data);
#define _OMC_LIT743 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT743)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT744_6,1.782113391e9);
#define _OMC_LIT744_6 MMC_REFREALLIT(_OMC_LIT_STRUCT744_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT744,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3536)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3536)),MMC_IMMEDIATE(MMC_TAGFIXNUM(50)),_OMC_LIT744_6}};
#define _OMC_LIT744 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT744)
#define _OMC_LIT745_data "SimCodeUtil.makeSolved failed!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT745,30,_OMC_LIT745_data);
#define _OMC_LIT745 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT745)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT746_6,1.782113391e9);
#define _OMC_LIT746_6 MMC_REFREALLIT(_OMC_LIT_STRUCT746_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT746,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3431)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3431)),MMC_IMMEDIATE(MMC_TAGFIXNUM(75)),_OMC_LIT746_6}};
#define _OMC_LIT746 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT746)
#define _OMC_LIT747_data "SimCodeUtil.makeSES_SIMPLE_ASSIGNwithArray failed because expression "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT747,69,_OMC_LIT747_data);
#define _OMC_LIT747 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT747)
#define _OMC_LIT748_data " could not be scalarized."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT748,25,_OMC_LIT748_data);
#define _OMC_LIT748 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT748)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT749_6,1.782113391e9);
#define _OMC_LIT749_6 MMC_REFREALLIT(_OMC_LIT_STRUCT749_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT749,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3394)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3395)),MMC_IMMEDIATE(MMC_TAGFIXNUM(93)),_OMC_LIT749_6}};
#define _OMC_LIT749 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT749)
#define _OMC_LIT750_data "SimCodeUtil.makeSES_SIMPLE_ASSIGN failed for: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT750,46,_OMC_LIT750_data);
#define _OMC_LIT750 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT750)
#define _OMC_LIT751_data "The language feature %s is not supported. Suggested workaround: %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT751,66,_OMC_LIT751_data);
#define _OMC_LIT751 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT751)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT752,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(35)),_OMC_LIT72,_OMC_LIT206,_OMC_LIT751}};
#define _OMC_LIT752 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT752)
#define _OMC_LIT753_data "non-linear equations within when-equations"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT753,42,_OMC_LIT753_data);
#define _OMC_LIT753 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT753)
#define _OMC_LIT754_data "Perform non-linear operations outside the when-equation (this is slower, but works)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT754,83,_OMC_LIT754_data);
#define _OMC_LIT754 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT754)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT755,2,1) {_OMC_LIT754,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT755 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT755)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT756,2,1) {_OMC_LIT753,_OMC_LIT755}};
#define _OMC_LIT756 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT756)
#define _OMC_LIT757_data "function createNonlinearResidualEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT757,48,_OMC_LIT757_data);
#define _OMC_LIT757 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT757)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT758,2,1) {_OMC_LIT757,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT758 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT758)
#define _OMC_LIT759_data "SimCodeUtil.createTmpCrefExpsForComplexEqnSys_work: fail for"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT759,60,_OMC_LIT759_data);
#define _OMC_LIT759 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT759)
#define _OMC_LIT760_data "function createNonlinearResidualEquationsComplex failed for: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT760,61,_OMC_LIT760_data);
#define _OMC_LIT760 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT760)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT761_6,1.782113391e9);
#define _OMC_LIT761_6 MMC_REFREALLIT(_OMC_LIT_STRUCT761_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT761,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2751)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2751)),MMC_IMMEDIATE(MMC_TAGFIXNUM(46)),_OMC_LIT761_6}};
#define _OMC_LIT761 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT761)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT762,2,3) {&DAE_Type_T__INTEGER__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT762 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT762)
#define _OMC_LIT763_data "solving FOR_EQUATION body: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT763,27,_OMC_LIT763_data);
#define _OMC_LIT763 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT763)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT764_6,1.782113391e9);
#define _OMC_LIT764_6 MMC_REFREALLIT(_OMC_LIT_STRUCT764_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT764,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2357)),MMC_IMMEDIATE(MMC_TAGFIXNUM(13)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2357)),MMC_IMMEDIATE(MMC_TAGFIXNUM(199)),_OMC_LIT764_6}};
#define _OMC_LIT764 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT764)
#define _OMC_LIT765_data "This has not been implemented yet.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT765,35,_OMC_LIT765_data);
#define _OMC_LIT765 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT765)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT766_6,1.782113391e9);
#define _OMC_LIT766_6 MMC_REFREALLIT(_OMC_LIT_STRUCT766_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT766,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2445)),MMC_IMMEDIATE(MMC_TAGFIXNUM(13)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2445)),MMC_IMMEDIATE(MMC_TAGFIXNUM(58)),_OMC_LIT766_6}};
#define _OMC_LIT766 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT766)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT767,1,11) {&DAE_Type_T__UNKNOWN__desc,}};
#define _OMC_LIT767 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT767)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT768,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT31,_OMC_LIT767,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT768 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT768)
#define _OMC_LIT769_data "Single Equation with constraint:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT769,33,_OMC_LIT769_data);
#define _OMC_LIT769 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT769)
#define _OMC_LIT770_data "Constraints:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT770,12,_OMC_LIT770_data);
#define _OMC_LIT770 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT770)
#define _OMC_LIT771_data "tearingdump"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT771,11,_OMC_LIT771_data);
#define _OMC_LIT771 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT771)
#define _OMC_LIT772_data "Dumps tearing information."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT772,26,_OMC_LIT772_data);
#define _OMC_LIT772 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT772)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT773,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(44)),_OMC_LIT771,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT772}};
#define _OMC_LIT773 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT773)
#define _OMC_LIT774_data "tearingdumpV"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT774,12,_OMC_LIT774_data);
#define _OMC_LIT774 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT774)
#define _OMC_LIT775_data "Dumps verbose tearing information."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT775,34,_OMC_LIT775_data);
#define _OMC_LIT775 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT775)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT776,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT774,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT775}};
#define _OMC_LIT776 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT776)
#define _OMC_LIT777_data "createEquation failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT777,21,_OMC_LIT777_data);
#define _OMC_LIT777 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT777)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT778_6,1.782113391e9);
#define _OMC_LIT778_6 MMC_REFREALLIT(_OMC_LIT_STRUCT778_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT778,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2078)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2078)),MMC_IMMEDIATE(MMC_TAGFIXNUM(70)),_OMC_LIT778_6}};
#define _OMC_LIT778 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT778)
#define _OMC_LIT779_data "Proceed component: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT779,19,_OMC_LIT779_data);
#define _OMC_LIT779 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT779)
#define _OMC_LIT780_data "Equations:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT780,10,_OMC_LIT780_data);
#define _OMC_LIT780 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT780)
#define _OMC_LIT781_data "Variables:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT781,10,_OMC_LIT781_data);
#define _OMC_LIT781 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT781)
#define _OMC_LIT782_data "function createEquationsForSystem1 failed for component "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT782,56,_OMC_LIT782_data);
#define _OMC_LIT782 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT782)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT783_6,1.782113391e9);
#define _OMC_LIT783_6 MMC_REFREALLIT(_OMC_LIT_STRUCT783_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT783,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1914)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1914)),MMC_IMMEDIATE(MMC_TAGFIXNUM(54)),_OMC_LIT783_6}};
#define _OMC_LIT783 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT783)
#define _OMC_LIT784_data "bltmatrixdump"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT784,13,_OMC_LIT784_data);
#define _OMC_LIT784 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT784)
#define _OMC_LIT785_data "Dumps the blt matrix in html file. IE seems to be very good in displaying large matrices."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT785,89,_OMC_LIT785_data);
#define _OMC_LIT785 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT785)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT786,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(153)),_OMC_LIT784,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT785}};
#define _OMC_LIT786 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT786)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT787,1,3) {&BackendDAE_IndexType_ABSOLUTE__desc,}};
#define _OMC_LIT787 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT787)
#define _OMC_LIT788_data "SimCodeUtil.createEquationsForSystems failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT788,44,_OMC_LIT788_data);
#define _OMC_LIT788 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT788)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT789_6,1.782113391e9);
#define _OMC_LIT789_6 MMC_REFREALLIT(_OMC_LIT_STRUCT789_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT789,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1565)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1565)),MMC_IMMEDIATE(MMC_TAGFIXNUM(72)),_OMC_LIT789_6}};
#define _OMC_LIT789 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT789)
#define _OMC_LIT790_data "SimCodeUtil.translateClockedEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT790,44,_OMC_LIT790_data);
#define _OMC_LIT790 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT790)
#define _OMC_LIT791_data "Backend phase and start with SimCode phase"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT791,42,_OMC_LIT791_data);
#define _OMC_LIT791 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT791)
#define _OMC_LIT792_data "visxml"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT792,6,_OMC_LIT792_data);
#define _OMC_LIT792 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT792)
#define _OMC_LIT793_data "Outputs a xml-file that contains information for visualization."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT793,63,_OMC_LIT793_data);
#define _OMC_LIT793 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT793)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT794,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(122)),_OMC_LIT792,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT793}};
#define _OMC_LIT794 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT794)
#define _OMC_LIT795_data "iterationVars"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT795,13,_OMC_LIT795_data);
#define _OMC_LIT795 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT795)
#define _OMC_LIT796_data "Shows a list of all iteration variables."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT796,40,_OMC_LIT796_data);
#define _OMC_LIT796 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT796)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT797,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(101)),_OMC_LIT795,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT796}};
#define _OMC_LIT797 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT797)
#define _OMC_LIT798_data "simCode: created initialization part"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT798,36,_OMC_LIT798_data);
#define _OMC_LIT798 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT798)
#define _OMC_LIT799_data "simCode: created event and clocks part"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT799,38,_OMC_LIT799_data);
#define _OMC_LIT799 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT799)
#define _OMC_LIT800_data "simCode: created simulation system equations"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT800,44,_OMC_LIT800_data);
#define _OMC_LIT800 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT800)
#define _OMC_LIT801_data "simCode: created of all other equations (e.g. parameter, nominal, assert, etc)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT801,78,_OMC_LIT801_data);
#define _OMC_LIT801 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT801)
#define _OMC_LIT802_data "generateLabeledSimCode"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT802,22,_OMC_LIT802_data);
#define _OMC_LIT802 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT802)
#define _OMC_LIT803_data "Turns on labeled SimCode generation for reduction algorithms."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT803,61,_OMC_LIT803_data);
#define _OMC_LIT803 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT803)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT804,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(32)),_OMC_LIT802,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT258,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT803}};
#define _OMC_LIT804 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT804)
#define _OMC_LIT805_data "labeledReduction"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT805,16,_OMC_LIT805_data);
#define _OMC_LIT805 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT805)
#define _OMC_LIT806_data "Turns on labeling and reduce terms to do whole process of reduction."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT806,68,_OMC_LIT806_data);
#define _OMC_LIT806 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT806)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT807,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(110)),_OMC_LIT805,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT257,_OMC_LIT258,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT806}};
#define _OMC_LIT807 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT807)
#define _OMC_LIT808_data "reduceTerms"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT808,11,_OMC_LIT808_data);
#define _OMC_LIT808 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT808)
#define _OMC_LIT809_data "Turns on reducing terms for reduction algorithms."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT809,49,_OMC_LIT809_data);
#define _OMC_LIT809 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT809)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT810,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(33)),_OMC_LIT808,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT258,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT809}};
#define _OMC_LIT810 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT810)
#define _OMC_LIT811_data "backendReduceDAE"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT811,16,_OMC_LIT811_data);
#define _OMC_LIT811 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT811)
#define _OMC_LIT812_data "Prints all Reduce DAE debug information."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT812,40,_OMC_LIT812_data);
#define _OMC_LIT812 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT812)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT813,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(161)),_OMC_LIT811,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT812}};
#define _OMC_LIT813 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT813)
#define _OMC_LIT814_data "List of iteration variables("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT814,28,_OMC_LIT814_data);
#define _OMC_LIT814 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT814)
#define _OMC_LIT815_data "):"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT815,2,_OMC_LIT815_data);
#define _OMC_LIT815 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT815)
#define _OMC_LIT816_data "\n=============================\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT816,31,_OMC_LIT816_data);
#define _OMC_LIT816 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT816)
#define _OMC_LIT817_data "No iteration variables found.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT817,30,_OMC_LIT817_data);
#define _OMC_LIT817 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT817)
#define _OMC_LIT818_data "_iterationVars.txt"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT818,18,_OMC_LIT818_data);
#define _OMC_LIT818 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT818)
#define _OMC_LIT819_data "simCode: created linear, non-linear and system jacobian parts"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT819,61,_OMC_LIT819_data);
#define _OMC_LIT819 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT819)
#define _OMC_LIT820_data "*** SimCode -> generate cref2simVar hashtable: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT820,47,_OMC_LIT820_data);
#define _OMC_LIT820 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT820)
#define _OMC_LIT821_data "execHash"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT821,8,_OMC_LIT821_data);
#define _OMC_LIT821 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT821)
#define _OMC_LIT822_data "Measures the time it takes to hash all simcode variables before code generation."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT822,80,_OMC_LIT822_data);
#define _OMC_LIT822 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT822)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT823,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(56)),_OMC_LIT821,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT822}};
#define _OMC_LIT823 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT823)
#define _OMC_LIT824_data "*** SimCode -> generate cref2simVar hashtable done!: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT824,53,_OMC_LIT824_data);
#define _OMC_LIT824 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT824)
#define _OMC_LIT825_data "__OMC_DT"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT825,8,_OMC_LIT825_data);
#define _OMC_LIT825 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT825)
#define _OMC_LIT826_data "calculateSensitivities"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT826,22,_OMC_LIT826_data);
#define _OMC_LIT826 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT826)
#define _OMC_LIT827_data "Generates sensitivities variables and matrices."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT827,47,_OMC_LIT827_data);
#define _OMC_LIT827 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT827)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT828,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(92)),_OMC_LIT826,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT150,_OMC_LIT258,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT827}};
#define _OMC_LIT828 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT828)
#define _OMC_LIT829_data "simCode: some other stuff during SimCode phase"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT829,46,_OMC_LIT829_data);
#define _OMC_LIT829 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT829)
#define _OMC_LIT830_data "simCode: alias equations"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT830,24,_OMC_LIT830_data);
#define _OMC_LIT830 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT830)
#define _OMC_LIT831_data ".fmutmp/sources/"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT831,16,_OMC_LIT831_data);
#define _OMC_LIT831 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT831)
#define _OMC_LIT832_data ".fmutmp"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT832,7,_OMC_LIT832_data);
#define _OMC_LIT832 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT832)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT833,3,3) {&HpcOmSimCode_HpcOmData_HPCOMDATA__desc,MMC_REFSTRUCTLIT(mmc_none),MMC_REFSTRUCTLIT(mmc_none)}};
#define _OMC_LIT833 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT833)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT834,5,3) {&SimCode_PartitionData_PARTITIONDATA__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(-1)),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT834 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT834)
#define _OMC_LIT835_data "simCode: all other stuff during SimCode phase"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT835,45,_OMC_LIT835_data);
#define _OMC_LIT835 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT835)
#define _OMC_LIT836_data "dumpSimCode"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT836,11,_OMC_LIT836_data);
#define _OMC_LIT836 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT836)
#define _OMC_LIT837_data "Dumps the simCode model used for code generation."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT837,49,_OMC_LIT837_data);
#define _OMC_LIT837 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT837)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT838,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(75)),_OMC_LIT836,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT837}};
#define _OMC_LIT838 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT838)
#define _OMC_LIT839_data "function createSimCode failed [Transformation from optimised DAE to simulation code structure failed]"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT839,101,_OMC_LIT839_data);
#define _OMC_LIT839 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT839)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT840_6,1.782113391e9);
#define _OMC_LIT840_6 MMC_REFREALLIT(_OMC_LIT_STRUCT840_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT840,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT26,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(837)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(837)),MMC_IMMEDIATE(MMC_TAGFIXNUM(146)),_OMC_LIT840_6}};
#define _OMC_LIT840 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT840)
#include "util/modelica.h"

#include "SimCodeUtil_includes.h"


/* default, do not make protected functions static */
#if !defined(PROTECTED_FUNCTION_STATIC)
#define PROTECTED_FUNCTION_STATIC
#endif
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol(threadData_t *threadData, modelica_string _istring);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol,2,0) {(void*) boxptr_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol,0}};
#define boxvar_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEq(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feq, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEq,2,0) {(void*) boxptr_SimCodeUtil_aliasSimEq,0}};
#define boxvar_SimCodeUtil_aliasSimEq MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEq)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEqs(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEqs,2,0) {(void*) boxptr_SimCodeUtil_aliasSimEqs,0}};
#define boxvar_SimCodeUtil_aliasSimEqs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEqs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEqSystems(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEqSystems,2,0) {(void*) boxptr_SimCodeUtil_aliasSimEqSystems,0}};
#define boxvar_SimCodeUtil_aliasSimEqSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_aliasSimEqSystems)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_findResources(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fe, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype _unknownUri, modelica_metatype *out_tree);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_findResources,2,0) {(void*) boxptr_SimCodeUtil_findResources,0}};
#define boxvar_SimCodeUtil_findResources MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_findResources)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getResources(threadData_t *threadData, modelica_metatype _classes, modelica_metatype _dlow1, modelica_metatype _dlow2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getResources,2,0) {(void*) boxptr_SimCodeUtil_getResources,0}};
#define boxvar_SimCodeUtil_getResources MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getResources)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getValueReferenceMapping2(threadData_t *threadData, modelica_metatype _vars, modelica_integer __omcQ_24in_5Fi, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype *out_tree);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getValueReferenceMapping2(threadData_t *threadData, modelica_metatype _vars, modelica_metatype __omcQ_24in_5Fi, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype *out_tree);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getValueReferenceMapping2,2,0) {(void*) boxptr_SimCodeUtil_getValueReferenceMapping2,0}};
#define boxvar_SimCodeUtil_getValueReferenceMapping2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getValueReferenceMapping2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getValueReferenceMapping(threadData_t *threadData, modelica_metatype _modelInfo);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getValueReferenceMapping,2,0) {(void*) boxptr_SimCodeUtil_getValueReferenceMapping,0}};
#define boxvar_SimCodeUtil_getValueReferenceMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getValueReferenceMapping)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_crefSimCodeIndexGreaterThan(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _simCode);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_crefSimCodeIndexGreaterThan(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _simCode);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_crefSimCodeIndexGreaterThan,2,0) {(void*) boxptr_SimCodeUtil_crefSimCodeIndexGreaterThan,0}};
#define boxvar_SimCodeUtil_crefSimCodeIndexGreaterThan MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_crefSimCodeIndexGreaterThan)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData_t *threadData, modelica_metatype _eqn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData_t *threadData, modelica_metatype _eqn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumContinuousEquationsSingleEq,2,0) {(void*) boxptr_SimCodeUtil_getNumContinuousEquationsSingleEq,0}};
#define boxvar_SimCodeUtil_getNumContinuousEquationsSingleEq MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumContinuousEquationsSingleEq)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_simvarGraterThan(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _v2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_simvarGraterThan(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _v2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_simvarGraterThan,2,0) {(void*) boxptr_SimCodeUtil_simvarGraterThan,0}};
#define boxvar_SimCodeUtil_simvarGraterThan MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_simvarGraterThan)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_lhsGreaterThan(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2, modelica_metatype _simCode);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_lhsGreaterThan(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2, modelica_metatype _simCode);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_lhsGreaterThan,2,0) {(void*) boxptr_SimCodeUtil_lhsGreaterThan,0}};
#define boxvar_SimCodeUtil_lhsGreaterThan MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_lhsGreaterThan)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_computeDependenciesHelper(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype _unknowns, modelica_metatype _res);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_computeDependenciesHelper,2,0) {(void*) boxptr_SimCodeUtil_computeDependenciesHelper,0}};
#define boxvar_SimCodeUtil_computeDependenciesHelper MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_computeDependenciesHelper)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getNLSysRHS(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype _res);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNLSysRHS,2,0) {(void*) boxptr_SimCodeUtil_getNLSysRHS,0}};
#define boxvar_SimCodeUtil_getNLSysRHS MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNLSysRHS)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSimVarsForSensitivities(threadData_t *threadData, modelica_metatype _inStateSimVars, modelica_metatype _inParamSimVars, modelica_integer _nFixedParameters, modelica_integer *out_countSensitivityParams);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSimVarsForSensitivities(threadData_t *threadData, modelica_metatype _inStateSimVars, modelica_metatype _inParamSimVars, modelica_metatype _nFixedParameters, modelica_metatype *out_countSensitivityParams);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSimVarsForSensitivities,2,0) {(void*) boxptr_SimCodeUtil_createSimVarsForSensitivities,0}};
#define boxvar_SimCodeUtil_createSimVarsForSensitivities MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSimVarsForSensitivities)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_hasLargeEquationSystems1(threadData_t *threadData, modelica_metatype _iComps);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_hasLargeEquationSystems1(threadData_t *threadData, modelica_metatype _iComps);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_hasLargeEquationSystems1,2,0) {(void*) boxptr_SimCodeUtil_hasLargeEquationSystems1,0}};
#define boxvar_SimCodeUtil_hasLargeEquationSystems1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_hasLargeEquationSystems1)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_hasLargeEquationSystems(threadData_t *threadData, modelica_metatype _iDlow, modelica_metatype _iInitDAE);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_hasLargeEquationSystems(threadData_t *threadData, modelica_metatype _iDlow, modelica_metatype _iInitDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_hasLargeEquationSystems,2,0) {(void*) boxptr_SimCodeUtil_hasLargeEquationSystems,0}};
#define boxvar_SimCodeUtil_hasLargeEquationSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_hasLargeEquationSystems)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getHighestDerivationVisit(threadData_t *threadData, modelica_integer _i, modelica_metatype _ders, modelica_metatype _depth);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getHighestDerivationVisit(threadData_t *threadData, modelica_metatype _i, modelica_metatype _ders, modelica_metatype _depth);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHighestDerivationVisit,2,0) {(void*) boxptr_SimCodeUtil_getHighestDerivationVisit,0}};
#define boxvar_SimCodeUtil_getHighestDerivationVisit MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHighestDerivationVisit)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getHighestDerivation(threadData_t *threadData, modelica_metatype _inDAE);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getHighestDerivation(threadData_t *threadData, modelica_metatype _inDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHighestDerivation,2,0) {(void*) boxptr_SimCodeUtil_getHighestDerivation,0}};
#define boxvar_SimCodeUtil_getHighestDerivation MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHighestDerivation)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_getDefaultValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inVarInfo);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDefaultValueReference,2,0) {(void*) boxptr_SimCodeUtil_getDefaultValueReference,0}};
#define boxvar_SimCodeUtil_getDefaultValueReference MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDefaultValueReference)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getScalarVars(threadData_t *threadData, modelica_metatype _inVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getScalarVars,2,0) {(void*) boxptr_SimCodeUtil_getScalarVars,0}};
#define boxvar_SimCodeUtil_getScalarVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getScalarVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_fillScalarElements(threadData_t *threadData, modelica_metatype _eltIn, modelica_metatype _dims, modelica_integer _dimIdx, modelica_metatype _subsIn, modelica_metatype __omcQ_24in_5Felts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillScalarElements(threadData_t *threadData, modelica_metatype _eltIn, modelica_metatype _dims, modelica_metatype _dimIdx, modelica_metatype _subsIn, modelica_metatype __omcQ_24in_5Felts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillScalarElements,2,0) {(void*) boxptr_SimCodeUtil_fillScalarElements,0}};
#define boxvar_SimCodeUtil_fillScalarElements MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillScalarElements)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumScalars(threadData_t *threadData, modelica_metatype _vars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumScalars(threadData_t *threadData, modelica_metatype _vars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumScalars,2,0) {(void*) boxptr_SimCodeUtil_getNumScalars,0}};
#define boxvar_SimCodeUtil_getNumScalars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumScalars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_mergeSparsePatter(threadData_t *threadData, modelica_metatype _inA, modelica_metatype _inB, modelica_metatype _inAccum);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_mergeSparsePatter,2,0) {(void*) boxptr_SimCodeUtil_mergeSparsePatter,0}};
#define boxvar_SimCodeUtil_mergeSparsePatter MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_mergeSparsePatter)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateSparsePatterCref2DerCref(threadData_t *threadData, modelica_metatype _sparsePattern, modelica_metatype _inSimVarHT, modelica_metatype _inAccum, modelica_metatype _inAccum2, modelica_metatype *out_outDerCrefs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateSparsePatterCref2DerCref,2,0) {(void*) boxptr_SimCodeUtil_translateSparsePatterCref2DerCref,0}};
#define boxvar_SimCodeUtil_translateSparsePatterCref2DerCref MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateSparsePatterCref2DerCref)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateSparsePatterInts2FMIUnknown(threadData_t *threadData, modelica_metatype _inSparsePattern, modelica_metatype _inAccum);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateSparsePatterInts2FMIUnknown,2,0) {(void*) boxptr_SimCodeUtil_translateSparsePatterInts2FMIUnknown,0}};
#define boxvar_SimCodeUtil_translateSparsePatterInts2FMIUnknown MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateSparsePatterInts2FMIUnknown)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isFmiUnknown(threadData_t *threadData, modelica_integer _index, modelica_metatype _inFMIUnknown);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isFmiUnknown(threadData_t *threadData, modelica_metatype _index, modelica_metatype _inFMIUnknown);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isFmiUnknown,2,0) {(void*) boxptr_SimCodeUtil_isFmiUnknown,0}};
#define boxvar_SimCodeUtil_isFmiUnknown MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isFmiUnknown)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isOutputSimVar(threadData_t *threadData, modelica_metatype _inVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isOutputSimVar(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isOutputSimVar,2,0) {(void*) boxptr_SimCodeUtil_isOutputSimVar,0}};
#define boxvar_SimCodeUtil_isOutputSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isOutputSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isClockedStateSimVar(threadData_t *threadData, modelica_metatype _inVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isClockedStateSimVar(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isClockedStateSimVar,2,0) {(void*) boxptr_SimCodeUtil_isClockedStateSimVar,0}};
#define boxvar_SimCodeUtil_isClockedStateSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isClockedStateSimVar)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpFmiInitialUnknownsDependencies(threadData_t *threadData, modelica_metatype _sparsePattern, modelica_string _heading);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpFmiInitialUnknownsDependencies,2,0) {(void*) boxptr_SimCodeUtil_dumpFmiInitialUnknownsDependencies,0}};
#define boxvar_SimCodeUtil_dumpFmiInitialUnknownsDependencies MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpFmiInitialUnknownsDependencies)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExactSimVar(threadData_t *threadData, modelica_metatype _simVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExactSimVar(threadData_t *threadData, modelica_metatype _simVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExactSimVar,2,0) {(void*) boxptr_SimCodeUtil_isInitialExactSimVar,0}};
#define boxvar_SimCodeUtil_isInitialExactSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExactSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityInputSimVar(threadData_t *threadData, modelica_metatype _simVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityInputSimVar(threadData_t *threadData, modelica_metatype _simVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityInputSimVar,2,0) {(void*) boxptr_SimCodeUtil_isCausalityInputSimVar,0}};
#define boxvar_SimCodeUtil_isCausalityInputSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityInputSimVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _depVars, modelica_metatype _indepVars, modelica_metatype _initialUnknowns, modelica_metatype _crefSimVarHT, modelica_metatype *out_outindepVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns,2,0) {(void*) boxptr_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns,0}};
#define boxvar_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDependentAndIndepentVarsForJacobian(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _orderedVars, modelica_metatype _crefSimVarHT);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDependentAndIndepentVarsForJacobian,2,0) {(void*) boxptr_SimCodeUtil_getDependentAndIndepentVarsForJacobian,0}};
#define boxvar_SimCodeUtil_getDependentAndIndepentVarsForJacobian MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDependentAndIndepentVarsForJacobian)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiInitialUnknowns(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_metatype _inSimDAE, modelica_metatype _crefSimVarHT, modelica_metatype _initialUnknownList, modelica_metatype *out_fmiDerInit, modelica_metatype *out_sortedUnknownCrefs, modelica_metatype *out_sortedknownCrefs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiInitialUnknowns,2,0) {(void*) boxptr_SimCodeUtil_getFmiInitialUnknowns,0}};
#define boxvar_SimCodeUtil_getFmiInitialUnknowns MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiInitialUnknowns)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExact(threadData_t *threadData, modelica_metatype _initial_);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExact(threadData_t *threadData, modelica_metatype _initial_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExact,2,0) {(void*) boxptr_SimCodeUtil_isInitialExact,0}};
#define boxvar_SimCodeUtil_isInitialExact MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExact)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getCrefFromSimVar(threadData_t *threadData, modelica_metatype _inSimVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCrefFromSimVar,2,0) {(void*) boxptr_SimCodeUtil_getCrefFromSimVar,0}};
#define boxvar_SimCodeUtil_getCrefFromSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCrefFromSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityCalculatedParameterSimVar(threadData_t *threadData, modelica_metatype _inVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityCalculatedParameterSimVar(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityCalculatedParameterSimVar,2,0) {(void*) boxptr_SimCodeUtil_isCausalityCalculatedParameterSimVar,0}};
#define boxvar_SimCodeUtil_isCausalityCalculatedParameterSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityCalculatedParameterSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialApproxOrCalculated(threadData_t *threadData, modelica_metatype _initial_);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialApproxOrCalculated(threadData_t *threadData, modelica_metatype _initial_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialApproxOrCalculated,2,0) {(void*) boxptr_SimCodeUtil_isInitialApproxOrCalculated,0}};
#define boxvar_SimCodeUtil_isInitialApproxOrCalculated MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialApproxOrCalculated)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isStateInitialUnknownSimVar(threadData_t *threadData, modelica_metatype _simVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isStateInitialUnknownSimVar(threadData_t *threadData, modelica_metatype _simVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isStateInitialUnknownSimVar,2,0) {(void*) boxptr_SimCodeUtil_isStateInitialUnknownSimVar,0}};
#define boxvar_SimCodeUtil_isStateInitialUnknownSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isStateInitialUnknownSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData_t *threadData, modelica_metatype _simVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData_t *threadData, modelica_metatype _simVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialApproxOrCalculatedSimVar,2,0) {(void*) boxptr_SimCodeUtil_isInitialApproxOrCalculatedSimVar,0}};
#define boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialApproxOrCalculatedSimVar)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpVarMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_integer _noIn, modelica_integer *out_noOut);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpVarMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_metatype _noIn, modelica_metatype *out_noOut);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVarMappingTuple,2,0) {(void*) boxptr_SimCodeUtil_dumpVarMappingTuple,0}};
#define boxvar_SimCodeUtil_dumpVarMappingTuple MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVarMappingTuple)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpEqMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_integer _noIn, modelica_integer *out_noOut);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpEqMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_metatype _noIn, modelica_metatype *out_noOut);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpEqMappingTuple,2,0) {(void*) boxptr_SimCodeUtil_dumpEqMappingTuple,0}};
#define boxvar_SimCodeUtil_dumpEqMappingTuple MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpEqMappingTuple)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpVarMapping(threadData_t *threadData, modelica_metatype _varMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVarMapping,2,0) {(void*) boxptr_SimCodeUtil_dumpVarMapping,0}};
#define boxvar_SimCodeUtil_dumpVarMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVarMapping)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpEqMapping(threadData_t *threadData, modelica_metatype _eqMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpEqMapping,2,0) {(void*) boxptr_SimCodeUtil_dumpEqMapping,0}};
#define boxvar_SimCodeUtil_dumpEqMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpEqMapping)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpBackendMapping(threadData_t *threadData, modelica_metatype _mapIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpBackendMapping,2,0) {(void*) boxptr_SimCodeUtil_dumpBackendMapping,0}};
#define boxvar_SimCodeUtil_dumpBackendMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpBackendMapping)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_dumpIdxScVarMapping0(threadData_t *threadData, modelica_metatype _iVar, modelica_integer _iIdx);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpIdxScVarMapping0(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _iIdx);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpIdxScVarMapping0,2,0) {(void*) boxptr_SimCodeUtil_dumpIdxScVarMapping0,0}};
#define boxvar_SimCodeUtil_dumpIdxScVarMapping0 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpIdxScVarMapping0)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4(threadData_t *threadData, modelica_metatype _iEqSystemOpt, modelica_metatype _iResList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4,2,0) {(void*) boxptr_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4,0}};
#define boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3,2,0) {(void*) boxptr_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3,0}};
#define boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2,2,0) {(void*) boxptr_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2,0}};
#define boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1,2,0) {(void*) boxptr_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1,0}};
#define boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iMappingWithHighestIdx);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0,2,0) {(void*) boxptr_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0,0}};
#define boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimEqSystemCrefsLHS(threadData_t *threadData, modelica_metatype _simEqSys);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqSystemCrefsLHS,2,0) {(void*) boxptr_SimCodeUtil_getSimEqSystemCrefsLHS,0}};
#define boxvar_SimCodeUtil_getSimEqSystemCrefsLHS MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqSystemCrefsLHS)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findBEqs(threadData_t *threadData, modelica_integer _bEq, modelica_metatype _eqTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findBEqs(threadData_t *threadData, modelica_metatype _bEq, modelica_metatype _eqTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_findBEqs,2,0) {(void*) boxptr_SimCodeUtil_findBEqs,0}};
#define boxvar_SimCodeUtil_findBEqs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_findBEqs)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findSimEqs(threadData_t *threadData, modelica_integer _simEq, modelica_metatype _eqTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findSimEqs(threadData_t *threadData, modelica_metatype _simEq, modelica_metatype _eqTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_findSimEqs,2,0) {(void*) boxptr_SimCodeUtil_findSimEqs,0}};
#define boxvar_SimCodeUtil_findSimEqs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_findSimEqs)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findBackendVar(threadData_t *threadData, modelica_integer _bVar, modelica_metatype _varTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findBackendVar(threadData_t *threadData, modelica_metatype _bVar, modelica_metatype _varTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_findBackendVar,2,0) {(void*) boxptr_SimCodeUtil_findBackendVar,0}};
#define boxvar_SimCodeUtil_findBackendVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_findBackendVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _varTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _varTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_findSimVar,2,0) {(void*) boxptr_SimCodeUtil_findSimVar,0}};
#define boxvar_SimCodeUtil_findSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_findSimVar)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimEqsForBackendEqs(threadData_t *threadData, modelica_integer _bEq, modelica_metatype _map);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimEqsForBackendEqs(threadData_t *threadData, modelica_metatype _bEq, modelica_metatype _map);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqsForBackendEqs,2,0) {(void*) boxptr_SimCodeUtil_getSimEqsForBackendEqs,0}};
#define boxvar_SimCodeUtil_getSimEqsForBackendEqs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqsForBackendEqs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getBackendEqsForSimEq(threadData_t *threadData, modelica_integer _simEq, modelica_metatype _map);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getBackendEqsForSimEq(threadData_t *threadData, modelica_metatype _simEq, modelica_metatype _map);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getBackendEqsForSimEq,2,0) {(void*) boxptr_SimCodeUtil_getBackendEqsForSimEq,0}};
#define boxvar_SimCodeUtil_getBackendEqsForSimEq MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getBackendEqsForSimEq)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimVarForBackendVar(threadData_t *threadData, modelica_integer _bVar, modelica_metatype _map);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimVarForBackendVar(threadData_t *threadData, modelica_metatype _bVar, modelica_metatype _map);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarForBackendVar,2,0) {(void*) boxptr_SimCodeUtil_getSimVarForBackendVar,0}};
#define boxvar_SimCodeUtil_getSimVarForBackendVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarForBackendVar)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getBackendVarForSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _map);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getBackendVarForSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _map);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getBackendVarForSimVar,2,0) {(void*) boxptr_SimCodeUtil_getBackendVarForSimVar,0}};
#define boxvar_SimCodeUtil_getBackendVarForSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getBackendVarForSimVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectReqSimEqs(threadData_t *threadData, modelica_integer _eq, modelica_metatype _tree, modelica_metatype _eqsIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_collectReqSimEqs(threadData_t *threadData, modelica_metatype _eq, modelica_metatype _tree, modelica_metatype _eqsIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectReqSimEqs,2,0) {(void*) boxptr_SimCodeUtil_collectReqSimEqs,0}};
#define boxvar_SimCodeUtil_collectReqSimEqs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectReqSimEqs)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_indexIsEqual(threadData_t *threadData, modelica_integer _idx, modelica_metatype _ses);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_indexIsEqual(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _ses);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_indexIsEqual,2,0) {(void*) boxptr_SimCodeUtil_indexIsEqual,0}};
#define boxvar_SimCodeUtil_indexIsEqual MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_indexIsEqual)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendEqIdcs(threadData_t *threadData, modelica_integer _iCurrentIdx, modelica_metatype _iEqIdx, modelica_metatype _iSccIdc);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendEqIdcs(threadData_t *threadData, modelica_metatype _iCurrentIdx, modelica_metatype _iEqIdx, modelica_metatype _iSccIdc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendEqIdcs,2,0) {(void*) boxptr_SimCodeUtil_appendEqIdcs,0}};
#define boxvar_SimCodeUtil_appendEqIdcs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendEqIdcs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setEqMapping(threadData_t *threadData, modelica_metatype _simEqs, modelica_metatype _bEq, modelica_metatype _mapIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setEqMapping,2,0) {(void*) boxptr_SimCodeUtil_setEqMapping,0}};
#define boxvar_SimCodeUtil_setEqMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setEqMapping)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeVarMapTuple(threadData_t *threadData, modelica_metatype _sVar, modelica_metatype _bVar, modelica_metatype _foldIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeVarMapTuple,2,0) {(void*) boxptr_SimCodeUtil_makeVarMapTuple,0}};
#define boxvar_SimCodeUtil_makeVarMapTuple MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeVarMapTuple)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimVarIndex(threadData_t *threadData, modelica_metatype _var, modelica_metatype _varInfo, modelica_metatype _htStates);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimVarIndex(threadData_t *threadData, modelica_metatype _var, modelica_metatype _varInfo, modelica_metatype _htStates);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarIndex,2,0) {(void*) boxptr_SimCodeUtil_getSimVarIndex,0}};
#define boxvar_SimCodeUtil_getSimVarIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarIndex)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_fillSimVarMapping(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iSimVarMapping, modelica_integer _iVarIdx);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillSimVarMapping(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iSimVarMapping, modelica_metatype _iVarIdx);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillSimVarMapping,2,0) {(void*) boxptr_SimCodeUtil_fillSimVarMapping,0}};
#define boxvar_SimCodeUtil_fillSimVarMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillSimVarMapping)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setBackendVarMapping(threadData_t *threadData, modelica_metatype _dae, modelica_metatype _ht, modelica_metatype _modelInfo, modelica_metatype _bmapIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setBackendVarMapping,2,0) {(void*) boxptr_SimCodeUtil_setBackendVarMapping,0}};
#define boxvar_SimCodeUtil_setBackendVarMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setBackendVarMapping)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpSystMapping(threadData_t *threadData, modelica_metatype _dae, modelica_boolean _isInitial);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpSystMapping(threadData_t *threadData, modelica_metatype _dae, modelica_metatype _isInitial);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpSystMapping,2,0) {(void*) boxptr_SimCodeUtil_setUpSystMapping,0}};
#define boxvar_SimCodeUtil_setUpSystMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpSystMapping)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addIntLst(threadData_t *threadData, modelica_metatype _lstIn, modelica_integer _x);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_addIntLst(threadData_t *threadData, modelica_metatype _lstIn, modelica_metatype _x);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addIntLst,2,0) {(void*) boxptr_SimCodeUtil_addIntLst,0}};
#define boxvar_SimCodeUtil_addIntLst MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addIntLst)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateInMatching(threadData_t *threadData, modelica_integer _idx, modelica_integer _offset, modelica_metatype _matchingAppend, modelica_metatype _matchingIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateInMatching(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _offset, modelica_metatype _matchingAppend, modelica_metatype _matchingIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateInMatching,2,0) {(void*) boxptr_SimCodeUtil_updateInMatching,0}};
#define boxvar_SimCodeUtil_updateInMatching MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateInMatching)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateInAdjacencyMatrix(threadData_t *threadData, modelica_integer _idx, modelica_integer _offset, modelica_metatype _mAppend, modelica_metatype _mIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateInAdjacencyMatrix(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _offset, modelica_metatype _mAppend, modelica_metatype _mIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateInAdjacencyMatrix,2,0) {(void*) boxptr_SimCodeUtil_updateInAdjacencyMatrix,0}};
#define boxvar_SimCodeUtil_updateInAdjacencyMatrix MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateInAdjacencyMatrix)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendAdjacencyMatrices(threadData_t *threadData, modelica_metatype _tplIn, modelica_metatype _foldIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendAdjacencyMatrices,2,0) {(void*) boxptr_SimCodeUtil_appendAdjacencyMatrices,0}};
#define boxvar_SimCodeUtil_appendAdjacencyMatrices MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendAdjacencyMatrices)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_setUpEqTree__Help(threadData_t *threadData, modelica_integer _iVal, modelica_integer _iRef);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpEqTree__Help(threadData_t *threadData, modelica_metatype _iVal, modelica_metatype _iRef);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpEqTree__Help,2,0) {(void*) boxptr_SimCodeUtil_setUpEqTree__Help,0}};
#define boxvar_SimCodeUtil_setUpEqTree__Help MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpEqTree__Help)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpEqTree(threadData_t *threadData, modelica_integer _beq, modelica_metatype _m, modelica_metatype _mt, modelica_metatype _eqMatch, modelica_metatype _varMatch, modelica_metatype _treeIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpEqTree(threadData_t *threadData, modelica_metatype _beq, modelica_metatype _m, modelica_metatype _mt, modelica_metatype _eqMatch, modelica_metatype _varMatch, modelica_metatype _treeIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpEqTree,2,0) {(void*) boxptr_SimCodeUtil_setUpEqTree,0}};
#define boxvar_SimCodeUtil_setUpEqTree MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpEqTree)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpBackendMapping(threadData_t *threadData, modelica_metatype _dae);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpBackendMapping,2,0) {(void*) boxptr_SimCodeUtil_setUpBackendMapping,0}};
#define boxvar_SimCodeUtil_setUpBackendMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setUpBackendMapping)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_enumerationTypeExists(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inType);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_enumerationTypeExists(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inType);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_enumerationTypeExists,2,0) {(void*) boxptr_SimCodeUtil_enumerationTypeExists,0}};
#define boxvar_SimCodeUtil_enumerationTypeExists MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_enumerationTypeExists)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getEnumerationTypesHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inAccumVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getEnumerationTypesHelper,2,0) {(void*) boxptr_SimCodeUtil_getEnumerationTypesHelper,0}};
#define boxvar_SimCodeUtil_getEnumerationTypesHelper MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getEnumerationTypesHelper)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllSCVarMapping1(threadData_t *threadData, modelica_metatype _iSimVarIdxTpl, modelica_metatype _iMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllSCVarMapping1,2,0) {(void*) boxptr_SimCodeUtil_createAllSCVarMapping1,0}};
#define boxvar_SimCodeUtil_createAllSCVarMapping1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllSCVarMapping1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllSCVarMapping0(threadData_t *threadData, modelica_metatype _iSimVar, modelica_integer _iOffset, modelica_metatype __omcQ_24in_5FiMapping, modelica_integer __omcQ_24in_5FhighestIdx, modelica_integer *out_highestIdx);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllSCVarMapping0(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iOffset, modelica_metatype __omcQ_24in_5FiMapping, modelica_metatype __omcQ_24in_5FhighestIdx, modelica_metatype *out_highestIdx);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllSCVarMapping0,2,0) {(void*) boxptr_SimCodeUtil_createAllSCVarMapping0,0}};
#define boxvar_SimCodeUtil_createAllSCVarMapping0 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllSCVarMapping0)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_convertIndexToColumnMajor(threadData_t *threadData, modelica_integer _idx, modelica_metatype _arrayDimensions);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_convertIndexToColumnMajor(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _arrayDimensions);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertIndexToColumnMajor,2,0) {(void*) boxptr_SimCodeUtil_convertIndexToColumnMajor,0}};
#define boxvar_SimCodeUtil_convertIndexToColumnMajor MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertIndexToColumnMajor)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getVarIndexInfosByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_boolean _iColumnMajor, modelica_string _iIndexForUndefinedReferences, modelica_string *out_oConcreteVarIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getVarIndexInfosByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_metatype _iColumnMajor, modelica_metatype _iIndexForUndefinedReferences, modelica_metatype *out_oConcreteVarIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getVarIndexInfosByMapping,2,0) {(void*) boxptr_SimCodeUtil_getVarIndexInfosByMapping,0}};
#define boxvar_SimCodeUtil_getVarIndexInfosByMapping MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getVarIndexInfosByMapping)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getHideResult(threadData_t *threadData, modelica_metatype _hideResultExp, modelica_metatype _name, modelica_metatype _source);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHideResult,2,0) {(void*) boxptr_SimCodeUtil_getHideResult,0}};
#define boxvar_SimCodeUtil_getHideResult MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getHideResult)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_eqSystemWCET(threadData_t *threadData, modelica_metatype _eqs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_eqSystemWCET,2,0) {(void*) boxptr_SimCodeUtil_eqSystemWCET,0}};
#define boxvar_SimCodeUtil_eqSystemWCET MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_eqSystemWCET)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimCodeLiterals(threadData_t *threadData, modelica_metatype _simCode, modelica_metatype _literals);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimCodeLiterals,2,0) {(void*) boxptr_SimCodeUtil_setSimCodeLiterals,0}};
#define boxvar_SimCodeUtil_setSimCodeLiterals MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimCodeLiterals)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystem(threadData_t *threadData, modelica_metatype _eq, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystem,2,0) {(void*) boxptr_SimCodeUtil_traverseExpsEqSystem,0}};
#define boxvar_SimCodeUtil_traverseExpsEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystems(threadData_t *threadData, modelica_metatype _ieqs, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype _acc, modelica_metatype *out_oa);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystems,2,0) {(void*) boxptr_SimCodeUtil_traverseExpsEqSystems,0}};
#define boxvar_SimCodeUtil_traverseExpsEqSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystems)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystemsList(threadData_t *threadData, modelica_metatype _ieqs, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype _acc, modelica_metatype *out_oa);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystemsList,2,0) {(void*) boxptr_SimCodeUtil_traverseExpsEqSystemsList,0}};
#define boxvar_SimCodeUtil_traverseExpsEqSystemsList MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsEqSystemsList)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsSubPartition(threadData_t *threadData, modelica_metatype _subPartition, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsSubPartition,2,0) {(void*) boxptr_SimCodeUtil_traverseExpsSubPartition,0}};
#define boxvar_SimCodeUtil_traverseExpsSubPartition MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsSubPartition)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsPartition(threadData_t *threadData, modelica_metatype _simPartition, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsPartition,2,0) {(void*) boxptr_SimCodeUtil_traverseExpsPartition,0}};
#define boxvar_SimCodeUtil_traverseExpsPartition MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseExpsPartition)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_calcPriority(threadData_t *threadData, modelica_metatype _eqs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_calcPriority,2,0) {(void*) boxptr_SimCodeUtil_calcPriority,0}};
#define boxvar_SimCodeUtil_calcPriority MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_calcPriority)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeEqualLengthLists2(threadData_t *threadData, modelica_metatype _elt, modelica_metatype _iq);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeEqualLengthLists2,2,0) {(void*) boxptr_SimCodeUtil_makeEqualLengthLists2,0}};
#define boxvar_SimCodeUtil_makeEqualLengthLists2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeEqualLengthLists2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeEqualLengthLists(threadData_t *threadData, modelica_metatype _inLst, modelica_integer _i);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeEqualLengthLists(threadData_t *threadData, modelica_metatype _inLst, modelica_metatype _i);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeEqualLengthLists,2,0) {(void*) boxptr_SimCodeUtil_makeEqualLengthLists,0}};
#define boxvar_SimCodeUtil_makeEqualLengthLists MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeEqualLengthLists)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getFileIndexFromFiles(threadData_t *threadData, modelica_string _file, modelica_metatype _files);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getFileIndexFromFiles(threadData_t *threadData, modelica_metatype _file, modelica_metatype _files);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFileIndexFromFiles,2,0) {(void*) boxptr_SimCodeUtil_getFileIndexFromFiles,0}};
#define boxvar_SimCodeUtil_getFileIndexFromFiles MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFileIndexFromFiles)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_greaterFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_greaterFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_greaterFileInfo,2,0) {(void*) boxptr_SimCodeUtil_greaterFileInfo,0}};
#define boxvar_SimCodeUtil_greaterFileInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_greaterFileInfo)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_equalFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_equalFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_equalFileInfo,2,0) {(void*) boxptr_SimCodeUtil_equalFileInfo,0}};
#define boxvar_SimCodeUtil_equalFileInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_equalFileInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromAbsynInfo(threadData_t *threadData, modelica_metatype _inInfo, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromAbsynInfo,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromAbsynInfo,0}};
#define boxvar_SimCodeUtil_getFilesFromAbsynInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromAbsynInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromDAEElementSource(threadData_t *threadData, modelica_metatype _inSource, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromDAEElementSource,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromDAEElementSource,0}};
#define boxvar_SimCodeUtil_getFilesFromDAEElementSource MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromDAEElementSource)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectAllFiles(threadData_t *threadData, modelica_metatype _inSimCode);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectAllFiles,2,0) {(void*) boxptr_SimCodeUtil_collectAllFiles,0}};
#define boxvar_SimCodeUtil_collectAllFiles MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectAllFiles)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromJacobianMatrix(threadData_t *threadData, modelica_metatype _inJacobianMatrices, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromJacobianMatrix,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromJacobianMatrix,0}};
#define boxvar_SimCodeUtil_getFilesFromJacobianMatrix MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromJacobianMatrix)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromJacobianMatrices(threadData_t *threadData, modelica_metatype _inJacobianMatrices, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromJacobianMatrices,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromJacobianMatrices,0}};
#define boxvar_SimCodeUtil_getFilesFromJacobianMatrices MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromJacobianMatrices)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromExtObjInfo(threadData_t *threadData, modelica_metatype _inExtObjInfo, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromExtObjInfo,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromExtObjInfo,0}};
#define boxvar_SimCodeUtil_getFilesFromExtObjInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromExtObjInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromWhenOperators(threadData_t *threadData, modelica_metatype _inWhenOperators, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromWhenOperators,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromWhenOperators,0}};
#define boxvar_SimCodeUtil_getFilesFromWhenOperators MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromWhenOperators)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatements(threadData_t *threadData, modelica_metatype _inStatements, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatements,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromStatements,0}};
#define boxvar_SimCodeUtil_getFilesFromStatements MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatements)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatementsElseWhen(threadData_t *threadData, modelica_metatype _inStatementOpt, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatementsElseWhen,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromStatementsElseWhen,0}};
#define boxvar_SimCodeUtil_getFilesFromStatementsElseWhen MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatementsElseWhen)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatementsElse(threadData_t *threadData, modelica_metatype _inElse, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatementsElse,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromStatementsElse,0}};
#define boxvar_SimCodeUtil_getFilesFromStatementsElse MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromStatementsElse)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystems(threadData_t *threadData, modelica_metatype _inSimEqSystems, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystems,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromSimEqSystems,0}};
#define boxvar_SimCodeUtil_getFilesFromSimEqSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystems)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystem(threadData_t *threadData, modelica_metatype _inSimEqSystem, modelica_metatype _inFiles, modelica_metatype *out_outFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystem,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromSimEqSystem,0}};
#define boxvar_SimCodeUtil_getFilesFromSimEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystemOpt(threadData_t *threadData, modelica_metatype _inSimEqSystemOpt, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystemOpt,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromSimEqSystemOpt,0}};
#define boxvar_SimCodeUtil_getFilesFromSimEqSystemOpt MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimEqSystemOpt)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromFunctions(threadData_t *threadData, modelica_metatype _functions, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromFunctions,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromFunctions,0}};
#define boxvar_SimCodeUtil_getFilesFromFunctions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromFunctions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimVars(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimVars,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromSimVars,0}};
#define boxvar_SimCodeUtil_getFilesFromSimVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimVar(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype _inFiles, modelica_metatype *out_outFiles);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimVar,2,0) {(void*) boxptr_SimCodeUtil_getFilesFromSimVar,0}};
#define boxvar_SimCodeUtil_getFilesFromSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFilesFromSimVar)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_compareSimVarName(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_compareSimVarName(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_compareSimVarName,2,0) {(void*) boxptr_SimCodeUtil_compareSimVarName,0}};
#define boxvar_SimCodeUtil_compareSimVarName MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_compareSimVarName)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_dimensions(threadData_t *threadData, modelica_metatype _dae_low, modelica_integer *out_OutInteger2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dimensions(threadData_t *threadData, modelica_metatype _dae_low, modelica_metatype *out_OutInteger2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimensions,2,0) {(void*) boxptr_SimCodeUtil_dimensions,0}};
#define boxvar_SimCodeUtil_dimensions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimensions)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_calculateVariableDimensions(threadData_t *threadData, modelica_metatype _in_vars, modelica_integer _inNvar1, modelica_integer _inNvar2, modelica_integer *out_OutInteger2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_calculateVariableDimensions(threadData_t *threadData, modelica_metatype _in_vars, modelica_metatype _inNvar1, modelica_metatype _inNvar2, modelica_metatype *out_OutInteger2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_calculateVariableDimensions,2,0) {(void*) boxptr_SimCodeUtil_calculateVariableDimensions,0}};
#define boxvar_SimCodeUtil_calculateVariableDimensions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_calculateVariableDimensions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData_t *threadData, modelica_metatype _inRefs, modelica_metatype _firstOrderInSec);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setFirstOrderInSecondOrderVarIndex,2,0) {(void*) boxptr_SimCodeUtil_setFirstOrderInSecondOrderVarIndex,0}};
#define boxvar_SimCodeUtil_setFirstOrderInSecondOrderVarIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setFirstOrderInSecondOrderVarIndex)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_locateDerAndSerachOtherSide22(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_locateDerAndSerachOtherSide22(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide22,2,0) {(void*) boxptr_SimCodeUtil_locateDerAndSerachOtherSide22,0}};
#define boxvar_SimCodeUtil_locateDerAndSerachOtherSide22 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide22)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_locateDerAndSerachOtherSide2(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_locateDerAndSerachOtherSide2(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide2,2,0) {(void*) boxptr_SimCodeUtil_locateDerAndSerachOtherSide2,0}};
#define boxvar_SimCodeUtil_locateDerAndSerachOtherSide2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData_t *threadData, modelica_metatype _derExp, modelica_metatype _inEqns, modelica_metatype _inEqnsOrg, modelica_metatype *out_sysOrdOneVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide,2,0) {(void*) boxptr_SimCodeUtil_locateDerAndSerachOtherSide,0}};
#define boxvar_SimCodeUtil_locateDerAndSerachOtherSide MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_locateDerAndSerachOtherSide)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeCallDerExp(threadData_t *threadData, modelica_metatype _inVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeCallDerExp,2,0) {(void*) boxptr_SimCodeUtil_makeCallDerExp,0}};
#define boxvar_SimCodeUtil_makeCallDerExp MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeCallDerExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_flattenEqns(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _dlow);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_flattenEqns,2,0) {(void*) boxptr_SimCodeUtil_flattenEqns,0}};
#define boxvar_SimCodeUtil_flattenEqns MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_flattenEqns)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableDerIndex2(threadData_t *threadData, modelica_metatype _inDlow, modelica_metatype _syst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableDerIndex2,2,0) {(void*) boxptr_SimCodeUtil_setVariableDerIndex2,0}};
#define boxvar_SimCodeUtil_setVariableDerIndex2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableDerIndex2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableDerIndex(threadData_t *threadData, modelica_metatype _inDlow, modelica_metatype _inEqSystems);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableDerIndex,2,0) {(void*) boxptr_SimCodeUtil_setVariableDerIndex,0}};
#define boxvar_SimCodeUtil_setVariableDerIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableDerIndex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_adjustStatesForInlineSolver(threadData_t *threadData, modelica_metatype _inStates);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_adjustStatesForInlineSolver,2,0) {(void*) boxptr_SimCodeUtil_adjustStatesForInlineSolver,0}};
#define boxvar_SimCodeUtil_adjustStatesForInlineSolver MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_adjustStatesForInlineSolver)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getNominalValue(threadData_t *threadData, modelica_metatype _daelowVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNominalValue,2,0) {(void*) boxptr_SimCodeUtil_getNominalValue,0}};
#define boxvar_SimCodeUtil_getNominalValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNominalValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getStartValue(threadData_t *threadData, modelica_metatype _daelowVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getStartValue,2,0) {(void*) boxptr_SimCodeUtil_getStartValue,0}};
#define boxvar_SimCodeUtil_getStartValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getStartValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getMinMaxValues(threadData_t *threadData, modelica_metatype _inDAELowVar, modelica_metatype *out_outMaxValue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getMinMaxValues,2,0) {(void*) boxptr_SimCodeUtil_getMinMaxValues,0}};
#define boxvar_SimCodeUtil_getMinMaxValues MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getMinMaxValues)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_extractVarUnitStr(threadData_t *threadData, modelica_metatype _exp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarUnitStr,2,0) {(void*) boxptr_SimCodeUtil_extractVarUnitStr,0}};
#define boxvar_SimCodeUtil_extractVarUnitStr MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarUnitStr)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_extractVarUnit(threadData_t *threadData, modelica_metatype _var_attr, modelica_string *out_displayUnitStr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarUnit,2,0) {(void*) boxptr_SimCodeUtil_extractVarUnit,0}};
#define boxvar_SimCodeUtil_extractVarUnit MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarUnit)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traversingdlowvarToSimvarFold(threadData_t *threadData, modelica_metatype _v, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traversingdlowvarToSimvarFold,2,0) {(void*) boxptr_SimCodeUtil_traversingdlowvarToSimvarFold,0}};
#define boxvar_SimCodeUtil_traversingdlowvarToSimvarFold MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traversingdlowvarToSimvarFold)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateStartValue(threadData_t *threadData, modelica_metatype _var, modelica_metatype __omcQ_24in_5FstartValue, modelica_metatype _initial_, modelica_metatype _causality);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateStartValue,2,0) {(void*) boxptr_SimCodeUtil_updateStartValue,0}};
#define boxvar_SimCodeUtil_updateStartValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateStartValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_startValueIsConstOrDefault(threadData_t *threadData, modelica_metatype _start_value, modelica_metatype _type_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_startValueIsConstOrDefault,2,0) {(void*) boxptr_SimCodeUtil_startValueIsConstOrDefault,0}};
#define boxvar_SimCodeUtil_startValueIsConstOrDefault MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_startValueIsConstOrDefault)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setDefaultStartValue(threadData_t *threadData, modelica_metatype _type_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setDefaultStartValue,2,0) {(void*) boxptr_SimCodeUtil_setDefaultStartValue,0}};
#define boxvar_SimCodeUtil_setDefaultStartValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setDefaultStartValue)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityInput(threadData_t *threadData, modelica_metatype _causality);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityInput(threadData_t *threadData, modelica_metatype _causality);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityInput,2,0) {(void*) boxptr_SimCodeUtil_isCausalityInput,0}};
#define boxvar_SimCodeUtil_isCausalityInput MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isCausalityInput)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExactOrApprox(threadData_t *threadData, modelica_metatype _initial_);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExactOrApprox(threadData_t *threadData, modelica_metatype _initial_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExactOrApprox,2,0) {(void*) boxptr_SimCodeUtil_isInitialExactOrApprox,0}};
#define boxvar_SimCodeUtil_isInitialExactOrApprox MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isInitialExactOrApprox)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getVariabilityAttribute(threadData_t *threadData, modelica_metatype _var);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getVariabilityAttribute,2,0) {(void*) boxptr_SimCodeUtil_getVariabilityAttribute,0}};
#define boxvar_SimCodeUtil_getVariabilityAttribute MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getVariabilityAttribute)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getInitialAttributeHelper(threadData_t *threadData, modelica_metatype _var, modelica_boolean _isFixed, modelica_metatype _iterationVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getInitialAttributeHelper(threadData_t *threadData, modelica_metatype _var, modelica_metatype _isFixed, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getInitialAttributeHelper,2,0) {(void*) boxptr_SimCodeUtil_getInitialAttributeHelper,0}};
#define boxvar_SimCodeUtil_getInitialAttributeHelper MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getInitialAttributeHelper)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_startValueIsConstOrNone(threadData_t *threadData, modelica_metatype _var);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_startValueIsConstOrNone(threadData_t *threadData, modelica_metatype _var);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_startValueIsConstOrNone,2,0) {(void*) boxptr_SimCodeUtil_startValueIsConstOrNone,0}};
#define boxvar_SimCodeUtil_startValueIsConstOrNone MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_startValueIsConstOrNone)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getInitialAttributeHelperForParameters(threadData_t *threadData, modelica_metatype _var, modelica_boolean _isFixed, modelica_metatype _iterationVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getInitialAttributeHelperForParameters(threadData_t *threadData, modelica_metatype _var, modelica_metatype _isFixed, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getInitialAttributeHelperForParameters,2,0) {(void*) boxptr_SimCodeUtil_getInitialAttributeHelperForParameters,0}};
#define boxvar_SimCodeUtil_getInitialAttributeHelperForParameters MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getInitialAttributeHelperForParameters)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setInitialAttribute(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _variability, modelica_metatype _causality, modelica_boolean _isFixed, modelica_metatype _iterationVars, modelica_metatype _aliasvar, modelica_metatype _globalknownVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setInitialAttribute(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _variability, modelica_metatype _causality, modelica_metatype _isFixed, modelica_metatype _iterationVars, modelica_metatype _aliasvar, modelica_metatype _globalknownVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setInitialAttribute,2,0) {(void*) boxptr_SimCodeUtil_setInitialAttribute,0}};
#define boxvar_SimCodeUtil_setInitialAttribute MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setInitialAttribute)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getCausality(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inVars, modelica_boolean _isValueChangeable);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getCausality(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inVars, modelica_metatype _isValueChangeable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCausality,2,0) {(void*) boxptr_SimCodeUtil_getCausality,0}};
#define boxvar_SimCodeUtil_getCausality MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getCausality)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowvarToSimvar(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _optAliasVars, modelica_metatype _inVars, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowvarToSimvar,2,0) {(void*) boxptr_SimCodeUtil_dlowvarToSimvar,0}};
#define boxvar_SimCodeUtil_dlowvarToSimvar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowvarToSimvar)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData_t *threadData, modelica_metatype _absynComment);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote,2,0) {(void*) boxptr_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote,0}};
#define boxvar_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getAliasVar1(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getAliasVar1,2,0) {(void*) boxptr_SimCodeUtil_getAliasVar1,0}};
#define boxvar_SimCodeUtil_getAliasVar1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getAliasVar1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getAliasVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inAliasVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getAliasVar,2,0) {(void*) boxptr_SimCodeUtil_getAliasVar,0}};
#define boxvar_SimCodeUtil_getAliasVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getAliasVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getArraySimVars(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iArrayMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getArraySimVars,2,0) {(void*) boxptr_SimCodeUtil_getArraySimVars,0}};
#define boxvar_SimCodeUtil_getArraySimVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getArraySimVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiUnitDefinitionsHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype __omcQ_24in_5FunitDefinitions, modelica_metatype __omcQ_24in_5FunitNameKeys, modelica_metatype *out_unitNameKeys);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiUnitDefinitionsHelper,2,0) {(void*) boxptr_SimCodeUtil_getFmiUnitDefinitionsHelper,0}};
#define boxvar_SimCodeUtil_getFmiUnitDefinitionsHelper MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiUnitDefinitionsHelper)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiUnitDefinitions(threadData_t *threadData, modelica_metatype _simVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiUnitDefinitions,2,0) {(void*) boxptr_SimCodeUtil_getFmiUnitDefinitions,0}};
#define boxvar_SimCodeUtil_getFmiUnitDefinitions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFmiUnitDefinitions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableIndexHelper2(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype __omcQ_24in_5Ftpl, modelica_metatype *out_tpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableIndexHelper2,2,0) {(void*) boxptr_SimCodeUtil_setVariableIndexHelper2,0}};
#define boxvar_SimCodeUtil_setVariableIndexHelper2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableIndexHelper2)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_setVariableIndex(threadData_t *threadData, modelica_metatype _simVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableIndex,2,0) {(void*) boxptr_SimCodeUtil_setVariableIndex,0}};
#define boxvar_SimCodeUtil_setVariableIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVariableIndex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_rewriteIndexColumnMajor(threadData_t *threadData, modelica_metatype _inVars, modelica_integer __omcQ_24in_5Findex, modelica_integer *out_index);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_rewriteIndexColumnMajor(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype __omcQ_24in_5Findex, modelica_metatype *out_index);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_rewriteIndexColumnMajor,2,0) {(void*) boxptr_SimCodeUtil_rewriteIndexColumnMajor,0}};
#define boxvar_SimCodeUtil_rewriteIndexColumnMajor MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_rewriteIndexColumnMajor)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_fixIndex(threadData_t *threadData, modelica_metatype _simVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_fixIndex,2,0) {(void*) boxptr_SimCodeUtil_fixIndex,0}};
#define boxvar_SimCodeUtil_fixIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_fixIndex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectArrayFirstVars(threadData_t *threadData, modelica_metatype _var, modelica_metatype _iSet);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectArrayFirstVars,2,0) {(void*) boxptr_SimCodeUtil_collectArrayFirstVars,0}};
#define boxvar_SimCodeUtil_collectArrayFirstVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectArrayFirstVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addSimVarArrayCref(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _arrayCref);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addSimVarArrayCref,2,0) {(void*) boxptr_SimCodeUtil_addSimVarArrayCref,0}};
#define boxvar_SimCodeUtil_addSimVarArrayCref MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addSimVarArrayCref)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setArrayElementnoFirst(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _iSet, modelica_metatype *out_oSet);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setArrayElementnoFirst,2,0) {(void*) boxptr_SimCodeUtil_setArrayElementnoFirst,0}};
#define boxvar_SimCodeUtil_setArrayElementnoFirst MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setArrayElementnoFirst)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extendIncompleteArray(threadData_t *threadData, modelica_metatype _simvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extendIncompleteArray,2,0) {(void*) boxptr_SimCodeUtil_extendIncompleteArray,0}};
#define boxvar_SimCodeUtil_extendIncompleteArray MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extendIncompleteArray)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_sortSimvars(threadData_t *threadData, modelica_metatype _simvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortSimvars,2,0) {(void*) boxptr_SimCodeUtil_sortSimvars,0}};
#define boxvar_SimCodeUtil_sortSimvars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortSimvars)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isAliasVar(threadData_t *threadData, modelica_metatype _var);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isAliasVar(threadData_t *threadData, modelica_metatype _var);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isAliasVar,2,0) {(void*) boxptr_SimCodeUtil_isAliasVar,0}};
#define boxvar_SimCodeUtil_isAliasVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isAliasVar)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_subPartitionString(threadData_t *threadData, modelica_metatype _subPart);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_subPartitionString,2,0) {(void*) boxptr_SimCodeUtil_subPartitionString,0}};
#define boxvar_SimCodeUtil_subPartitionString MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_subPartitionString)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_previousString(threadData_t *threadData, modelica_boolean _isPreviousVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_previousString(threadData_t *threadData, modelica_metatype _isPreviousVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_previousString,2,0) {(void*) boxptr_SimCodeUtil_previousString,0}};
#define boxvar_SimCodeUtil_previousString MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_previousString)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpClockPartition(threadData_t *threadData, modelica_metatype _clockPart);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpClockPartition,2,0) {(void*) boxptr_SimCodeUtil_dumpClockPartition,0}};
#define boxvar_SimCodeUtil_dumpClockPartition MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpClockPartition)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extObjInfoString(threadData_t *threadData, modelica_metatype _info);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extObjInfoString,2,0) {(void*) boxptr_SimCodeUtil_extObjInfoString,0}};
#define boxvar_SimCodeUtil_extObjInfoString MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extObjInfoString)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpJacobianMatrix(threadData_t *threadData, modelica_metatype _jacOpt);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpJacobianMatrix,2,0) {(void*) boxptr_SimCodeUtil_dumpJacobianMatrix,0}};
#define boxvar_SimCodeUtil_dumpJacobianMatrix MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpJacobianMatrix)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpJacobianMatrixLst(threadData_t *threadData, modelica_metatype _simjacs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpJacobianMatrixLst,2,0) {(void*) boxptr_SimCodeUtil_dumpJacobianMatrixLst,0}};
#define boxvar_SimCodeUtil_dumpJacobianMatrixLst MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpJacobianMatrixLst)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpWhenOps(threadData_t *threadData, modelica_metatype _whenStmtLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpWhenOps,2,0) {(void*) boxptr_SimCodeUtil_dumpWhenOps,0}};
#define boxvar_SimCodeUtil_dumpWhenOps MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpWhenOps)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSimJac(threadData_t *threadData, modelica_metatype _simJac);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSimJac,2,0) {(void*) boxptr_SimCodeUtil_dumpSimJac,0}};
#define boxvar_SimCodeUtil_dumpSimJac MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSimJac)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpFunctions(threadData_t *threadData, modelica_metatype _functions);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpFunctions,2,0) {(void*) boxptr_SimCodeUtil_dumpFunctions,0}};
#define boxvar_SimCodeUtil_dumpFunctions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpFunctions)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpVariablesString(threadData_t *threadData, modelica_metatype _vars, modelica_string _delimiter);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVariablesString,2,0) {(void*) boxptr_SimCodeUtil_dumpVariablesString,0}};
#define boxvar_SimCodeUtil_dumpVariablesString MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpVariablesString)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_derVarFromStateVar(threadData_t *threadData, modelica_metatype _state, modelica_metatype _timeInterval, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_derVarFromStateVar,2,0) {(void*) boxptr_SimCodeUtil_derVarFromStateVar,0}};
#define boxvar_SimCodeUtil_derVarFromStateVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_derVarFromStateVar)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_addSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_integer _index, modelica_metatype _simVars);
PROTECTED_FUNCTION_STATIC void boxptr_SimCodeUtil_addSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _index, modelica_metatype _simVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addSimVar,2,0) {(void*) boxptr_SimCodeUtil_addSimVar,0}};
#define boxvar_SimCodeUtil_addSimVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addSimVar)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extractVarFromVar2(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _simVars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarFromVar2,2,0) {(void*) boxptr_SimCodeUtil_extractVarFromVar2,0}};
#define boxvar_SimCodeUtil_extractVarFromVar2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarFromVar2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getExportVar(threadData_t *threadData, modelica_metatype _var);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getExportVar,2,0) {(void*) boxptr_SimCodeUtil_getExportVar,0}};
#define boxvar_SimCodeUtil_getExportVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getExportVar)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extractVarFromVar(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _simVars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarFromVar,2,0) {(void*) boxptr_SimCodeUtil_extractVarFromVar,0}};
#define boxvar_SimCodeUtil_extractVarFromVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarFromVar)
PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_simBranchString_simBranchBodyString(threadData_t *threadData, modelica_metatype _tpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_simBranchString_simBranchBodyString,2,0) {(void*) boxptr_SimCodeUtil_simBranchString_simBranchBodyString,0}};
#define boxvar_SimCodeUtil_simBranchString_simBranchBodyString MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_simBranchString_simBranchBodyString)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_extractVarsFromList(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype __omcQ_24in_5FsimVars, modelica_metatype _aliasVars, modelica_metatype _vars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars, modelica_metatype *out_simVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarsFromList,2,0) {(void*) boxptr_SimCodeUtil_extractVarsFromList,0}};
#define boxvar_SimCodeUtil_extractVarsFromList MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractVarsFromList)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVars(threadData_t *threadData, modelica_metatype _inSimDAE, modelica_metatype _inInitDAE, modelica_metatype _tempvars, modelica_metatype *out_unitDefinitions);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVars,2,0) {(void*) boxptr_SimCodeUtil_createVars,0}};
#define boxvar_SimCodeUtil_createVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getStateInfo(threadData_t *threadData, modelica_integer _idx, modelica_metatype _vars, modelica_metatype _stateInfoIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getStateInfo(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _vars, modelica_metatype _stateInfoIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getStateInfo,2,0) {(void*) boxptr_SimCodeUtil_getStateInfo,0}};
#define boxvar_SimCodeUtil_getStateInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getStateInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVarKindForStates(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _kindIn, modelica_metatype *out_kindOut);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVarKindForStates,2,0) {(void*) boxptr_SimCodeUtil_setVarKindForStates,0}};
#define boxvar_SimCodeUtil_setVarKindForStates MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setVarKindForStates)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceCrefWithStartValue(threadData_t *threadData, modelica_metatype _expIn, modelica_metatype _varsIn, modelica_metatype *out_varsOut);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceCrefWithStartValue,2,0) {(void*) boxptr_SimCodeUtil_replaceCrefWithStartValue,0}};
#define boxvar_SimCodeUtil_replaceCrefWithStartValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceCrefWithStartValue)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_artificialVarKind(threadData_t *threadData, modelica_metatype _inVarKind);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_artificialVarKind(threadData_t *threadData, modelica_metatype _inVarKind);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_artificialVarKind,2,0) {(void*) boxptr_SimCodeUtil_artificialVarKind,0}};
#define boxvar_SimCodeUtil_artificialVarKind MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_artificialVarKind)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_preCalculateStartValues1(threadData_t *threadData, modelica_metatype _eqIndexes, modelica_metatype _m, modelica_metatype _mT, modelica_metatype _varMap, modelica_metatype _eqs, modelica_metatype _varsIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_preCalculateStartValues1,2,0) {(void*) boxptr_SimCodeUtil_preCalculateStartValues1,0}};
#define boxvar_SimCodeUtil_preCalculateStartValues1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_preCalculateStartValues1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_preCalculateStartValues(threadData_t *threadData, modelica_metatype _systIn, modelica_metatype _globalKnownVars, modelica_metatype _shared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_preCalculateStartValues,2,0) {(void*) boxptr_SimCodeUtil_preCalculateStartValues,0}};
#define boxvar_SimCodeUtil_preCalculateStartValues MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_preCalculateStartValues)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_evaluateVariableAttributes(threadData_t *threadData, modelica_metatype _attrIn, modelica_metatype _shared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_evaluateVariableAttributes,2,0) {(void*) boxptr_SimCodeUtil_evaluateVariableAttributes,0}};
#define boxvar_SimCodeUtil_evaluateVariableAttributes MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_evaluateVariableAttributes)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_evaluateStartValues(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inShared, modelica_metatype *out_outShared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_evaluateStartValues,2,0) {(void*) boxptr_SimCodeUtil_evaluateStartValues,0}};
#define boxvar_SimCodeUtil_evaluateStartValues MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_evaluateStartValues)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isRealInput(threadData_t *threadData, modelica_metatype _var);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isRealInput(threadData_t *threadData, modelica_metatype _var);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isRealInput,2,0) {(void*) boxptr_SimCodeUtil_isRealInput,0}};
#define boxvar_SimCodeUtil_isRealInput MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isRealInput)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumberOfRealInputs(threadData_t *threadData, modelica_metatype _inputVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumberOfRealInputs(threadData_t *threadData, modelica_metatype _inputVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumberOfRealInputs,2,0) {(void*) boxptr_SimCodeUtil_getNumberOfRealInputs,0}};
#define boxvar_SimCodeUtil_getNumberOfRealInputs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getNumberOfRealInputs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVarInfo(threadData_t *threadData, modelica_metatype _dlow, modelica_integer _nx, modelica_integer _ny, modelica_integer _ndy, modelica_integer _np, modelica_integer _na, modelica_integer _next, modelica_integer _numOutVars, modelica_integer _numInVars, modelica_integer _ny_int, modelica_integer _np_int, modelica_integer _na_int, modelica_integer _ny_bool, modelica_integer _np_bool, modelica_integer _na_bool, modelica_integer _ny_string, modelica_integer _np_string, modelica_integer _na_string, modelica_integer _numStateSets, modelica_integer _numOptimizeConstraints, modelica_integer _numOptimizeFinalConstraints, modelica_integer _numRealInputVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createVarInfo(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _nx, modelica_metatype _ny, modelica_metatype _ndy, modelica_metatype _np, modelica_metatype _na, modelica_metatype _next, modelica_metatype _numOutVars, modelica_metatype _numInVars, modelica_metatype _ny_int, modelica_metatype _np_int, modelica_metatype _na_int, modelica_metatype _ny_bool, modelica_metatype _np_bool, modelica_metatype _na_bool, modelica_metatype _ny_string, modelica_metatype _np_string, modelica_metatype _na_string, modelica_metatype _numStateSets, modelica_metatype _numOptimizeConstraints, modelica_metatype _numOptimizeFinalConstraints, modelica_metatype _numRealInputVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVarInfo,2,0) {(void*) boxptr_SimCodeUtil_createVarInfo,0}};
#define boxvar_SimCodeUtil_createVarInfo MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVarInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVarAsserts(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVarAsserts,2,0) {(void*) boxptr_SimCodeUtil_createVarAsserts,0}};
#define boxvar_SimCodeUtil_createVarAsserts MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createVarAsserts)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createInitialAssignmentsFromStart(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createInitialAssignmentsFromStart,2,0) {(void*) boxptr_SimCodeUtil_createInitialAssignmentsFromStart,0}};
#define boxvar_SimCodeUtil_createInitialAssignmentsFromStart MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createInitialAssignmentsFromStart)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSimEqsForGlobalKnownVars(threadData_t *threadData, modelica_metatype __omcQ_24in_5FglobalKnownVar, modelica_metatype _inTuple, modelica_metatype *out_outTuple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSimEqsForGlobalKnownVars,2,0) {(void*) boxptr_SimCodeUtil_createSimEqsForGlobalKnownVars,0}};
#define boxvar_SimCodeUtil_createSimEqsForGlobalKnownVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSimEqsForGlobalKnownVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolved__fromStartValue(threadData_t *threadData, modelica_metatype _inVar, modelica_integer _inUniqueEqIndex, modelica_integer *out_outUniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolved__fromStartValue(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inUniqueEqIndex, modelica_metatype *out_outUniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolved__fromStartValue,2,0) {(void*) boxptr_SimCodeUtil_makeSolved__fromStartValue,0}};
#define boxvar_SimCodeUtil_makeSolved__fromStartValue MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolved__fromStartValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowAlgToSimEqSystem(threadData_t *threadData, modelica_metatype _inAlg, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dlowAlgToSimEqSystem(threadData_t *threadData, modelica_metatype _inAlg, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowAlgToSimEqSystem,2,0) {(void*) boxptr_SimCodeUtil_dlowAlgToSimEqSystem,0}};
#define boxvar_SimCodeUtil_dlowAlgToSimEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowAlgToSimEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowEqToSimEqSystem(threadData_t *threadData, modelica_metatype _inEquation, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dlowEqToSimEqSystem(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowEqToSimEqSystem,2,0) {(void*) boxptr_SimCodeUtil_dlowEqToSimEqSystem,0}};
#define boxvar_SimCodeUtil_dlowEqToSimEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dlowEqToSimEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseAliasVarsToSimEqSystem(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseAliasVarsToSimEqSystem,2,0) {(void*) boxptr_SimCodeUtil_traverseAliasVarsToSimEqSystem,0}};
#define boxvar_SimCodeUtil_traverseAliasVarsToSimEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseAliasVarsToSimEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseKnVarsToSimEqSystem(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseKnVarsToSimEqSystem,2,0) {(void*) boxptr_SimCodeUtil_traverseKnVarsToSimEqSystem,0}};
#define boxvar_SimCodeUtil_traverseKnVarsToSimEqSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traverseKnVarsToSimEqSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleAlgorithmCode(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _vars, modelica_boolean _skipDiscinAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleAlgorithmCode(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _vars, modelica_metatype _skipDiscinAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleAlgorithmCode,2,0) {(void*) boxptr_SimCodeUtil_createSingleAlgorithmCode,0}};
#define boxvar_SimCodeUtil_createSingleAlgorithmCode MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleAlgorithmCode)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleArrayEqnCode(threadData_t *threadData, modelica_boolean _genDiscrete, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _shared, modelica_metatype *out_noDiscequations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleArrayEqnCode(threadData_t *threadData, modelica_metatype _genDiscrete, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _shared, modelica_metatype *out_noDiscequations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleArrayEqnCode,2,0) {(void*) boxptr_SimCodeUtil_createSingleArrayEqnCode,0}};
#define boxvar_SimCodeUtil_createSingleArrayEqnCode MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleArrayEqnCode)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_createSingleComplexEqnCode3(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _iht, modelica_metatype *out_oht);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode3(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _iht, modelica_metatype *out_oht);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode3,2,0) {(void*) boxptr_SimCodeUtil_createSingleComplexEqnCode3,0}};
#define boxvar_SimCodeUtil_createSingleComplexEqnCode3 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode3)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleComplexEqnCode2(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _inExp3, modelica_metatype _inExp4, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _source, modelica_metatype _eqKind, modelica_metatype _iextra, modelica_boolean _genDiscrete, modelica_metatype _inVars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode2(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _inExp3, modelica_metatype _inExp4, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _source, modelica_metatype _eqKind, modelica_metatype _iextra, modelica_metatype _genDiscrete, modelica_metatype _inVars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode2,2,0) {(void*) boxptr_SimCodeUtil_createSingleComplexEqnCode2,0}};
#define boxvar_SimCodeUtil_createSingleComplexEqnCode2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleComplexEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_boolean _genDiscrete, modelica_metatype _funcTree, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_metatype _genDiscrete, modelica_metatype _funcTree, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode,2,0) {(void*) boxptr_SimCodeUtil_createSingleComplexEqnCode,0}};
#define boxvar_SimCodeUtil_createSingleComplexEqnCode MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleComplexEqnCode)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsIfBranch(threadData_t *threadData, modelica_metatype _inConditions, modelica_metatype _inEquationsLst, modelica_metatype _inVars, modelica_metatype _shared, modelica_boolean _genDiscrete, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsIfBranch(threadData_t *threadData, modelica_metatype _inConditions, modelica_metatype _inEquationsLst, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _genDiscrete, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsIfBranch,2,0) {(void*) boxptr_SimCodeUtil_createEquationsIfBranch,0}};
#define boxvar_SimCodeUtil_createEquationsIfBranch MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsIfBranch)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleIfEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_boolean _genDiscrete, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleIfEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _genDiscrete, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleIfEqnCode,2,0) {(void*) boxptr_SimCodeUtil_createSingleIfEqnCode,0}};
#define boxvar_SimCodeUtil_createSingleIfEqnCode MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleIfEqnCode)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createElseWhenEquation(threadData_t *threadData, modelica_metatype _inElseWhenEquation, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _inElementSource, modelica_metatype _inEqAttr, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createElseWhenEquation(threadData_t *threadData, modelica_metatype _inElseWhenEquation, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _inElementSource, modelica_metatype _inEqAttr, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createElseWhenEquation,2,0) {(void*) boxptr_SimCodeUtil_createElseWhenEquation,0}};
#define boxvar_SimCodeUtil_createElseWhenEquation MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createElseWhenEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleWhenEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleWhenEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleWhenEqnCode,2,0) {(void*) boxptr_SimCodeUtil_createSingleWhenEqnCode,0}};
#define boxvar_SimCodeUtil_createSingleWhenEqnCode MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createSingleWhenEqnCode)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_simJacCSRToCSC(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_simJacCSRToCSC(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_simJacCSRToCSC,2,0) {(void*) boxptr_SimCodeUtil_simJacCSRToCSC,0}};
#define boxvar_SimCodeUtil_simJacCSRToCSC MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_simJacCSRToCSC)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_jacToSimjac(threadData_t *threadData, modelica_metatype _jac, modelica_metatype _v);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_jacToSimjac,2,0) {(void*) boxptr_SimCodeUtil_jacToSimjac,0}};
#define boxvar_SimCodeUtil_jacToSimjac MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_jacToSimjac)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traversingisVarDiscreteCrefFinder(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_traversingisVarDiscreteCrefFinder,2,0) {(void*) boxptr_SimCodeUtil_traversingisVarDiscreteCrefFinder,0}};
#define boxvar_SimCodeUtil_traversingisVarDiscreteCrefFinder MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_traversingisVarDiscreteCrefFinder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAlgorithmAndEquationAsserts(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAlgorithmAndEquationAsserts,2,0) {(void*) boxptr_SimCodeUtil_createAlgorithmAndEquationAsserts,0}};
#define boxvar_SimCodeUtil_createAlgorithmAndEquationAsserts MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAlgorithmAndEquationAsserts)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_extractExtObjInfo2(threadData_t *threadData, modelica_metatype _varLst, modelica_metatype _evars, modelica_metatype *out_aliases);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractExtObjInfo2,2,0) {(void*) boxptr_SimCodeUtil_extractExtObjInfo2,0}};
#define boxvar_SimCodeUtil_extractExtObjInfo2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_extractExtObjInfo2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_orderExtVars(threadData_t *threadData, modelica_metatype _varLstIn, modelica_boolean _isInitial);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_orderExtVars(threadData_t *threadData, modelica_metatype _varLstIn, modelica_metatype _isInitial);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_orderExtVars,2,0) {(void*) boxptr_SimCodeUtil_orderExtVars,0}};
#define boxvar_SimCodeUtil_orderExtVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_orderExtVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateDelayExpressions(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fe, modelica_metatype __omcQ_24in_5Facc, modelica_metatype *out_acc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateDelayExpressions,2,0) {(void*) boxptr_SimCodeUtil_updateDelayExpressions,0}};
#define boxvar_SimCodeUtil_updateDelayExpressions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateDelayExpressions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectDelayExpressions(threadData_t *threadData, modelica_metatype _e, modelica_metatype _acc, modelica_metatype *out_outAcc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectDelayExpressions,2,0) {(void*) boxptr_SimCodeUtil_collectDelayExpressions,0}};
#define boxvar_SimCodeUtil_collectDelayExpressions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectDelayExpressions)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isSimEqSys(threadData_t *threadData, modelica_metatype _simEqSysIn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isSimEqSys(threadData_t *threadData, modelica_metatype _simEqSysIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_isSimEqSys,2,0) {(void*) boxptr_SimCodeUtil_isSimEqSys,0}};
#define boxvar_SimCodeUtil_isSimEqSys MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_isSimEqSys)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createDerivativeMatrix(threadData_t *threadData, modelica_metatype _inJacobian, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createDerivativeMatrix(threadData_t *threadData, modelica_metatype _inJacobian, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createDerivativeMatrix,2,0) {(void*) boxptr_SimCodeUtil_createDerivativeMatrix,0}};
#define boxvar_SimCodeUtil_createDerivativeMatrix MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createDerivativeMatrix)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSparsePattern(threadData_t *threadData, modelica_metatype _sparsePattern);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSparsePattern,2,0) {(void*) boxptr_SimCodeUtil_dumpSparsePattern,0}};
#define boxvar_SimCodeUtil_dumpSparsePattern MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSparsePattern)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSparsePatternInt(threadData_t *threadData, modelica_metatype _sparsePattern);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSparsePatternInt,2,0) {(void*) boxptr_SimCodeUtil_dumpSparsePatternInt,0}};
#define boxvar_SimCodeUtil_dumpSparsePatternInt MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSparsePatternInt)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortColoring(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inColoring);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortColoring,2,0) {(void*) boxptr_SimCodeUtil_sortColoring,0}};
#define boxvar_SimCodeUtil_sortColoring MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortColoring)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortSparsePattern(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inSparsePattern, modelica_boolean _useFMIIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_sortSparsePattern(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inSparsePattern, modelica_metatype _useFMIIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortSparsePattern,2,0) {(void*) boxptr_SimCodeUtil_sortSparsePattern,0}};
#define boxvar_SimCodeUtil_sortSparsePattern MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortSparsePattern)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSortedInitialUnknownCrefs(threadData_t *threadData, modelica_metatype _sortedCrefs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSortedInitialUnknownCrefs,2,0) {(void*) boxptr_SimCodeUtil_dumpSortedInitialUnknownCrefs,0}};
#define boxvar_SimCodeUtil_dumpSortedInitialUnknownCrefs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dumpSortedInitialUnknownCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortInitialUnknowsSimVars(threadData_t *threadData, modelica_metatype _inSimVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortInitialUnknowsSimVars,2,0) {(void*) boxptr_SimCodeUtil_sortInitialUnknowsSimVars,0}};
#define boxvar_SimCodeUtil_sortInitialUnknowsSimVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortInitialUnknowsSimVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData_t *threadData, modelica_metatype _inName, modelica_metatype _inVarKind);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeTmpRealSimCodeVar,2,0) {(void*) boxptr_SimCodeUtil_makeTmpRealSimCodeVar,0}};
#define boxvar_SimCodeUtil_makeTmpRealSimCodeVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeTmpRealSimCodeVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimVarMatrixName(threadData_t *threadData, modelica_metatype __omcQ_24in_5FsimVar, modelica_metatype _optName);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimVarMatrixName,2,0) {(void*) boxptr_SimCodeUtil_setSimVarMatrixName,0}};
#define boxvar_SimCodeUtil_setSimVarMatrixName MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimVarMatrixName)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimVarKind(threadData_t *threadData, modelica_metatype __omcQ_24in_5FsimVar, modelica_metatype _varKind);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimVarKind,2,0) {(void*) boxptr_SimCodeUtil_setSimVarKind,0}};
#define boxvar_SimCodeUtil_setSimVarKind MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSimVarKind)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllDiffedSimVars(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_integer _inResIndex, modelica_integer _inTmpIndex, modelica_string _inMatrixName, modelica_metatype _iVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllDiffedSimVars(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_metatype _inResIndex, modelica_metatype _inTmpIndex, modelica_metatype _inMatrixName, modelica_metatype _iVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllDiffedSimVars,2,0) {(void*) boxptr_SimCodeUtil_createAllDiffedSimVars,0}};
#define boxvar_SimCodeUtil_createAllDiffedSimVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllDiffedSimVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createJacSimVarsColumn(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_integer _inResIndex, modelica_integer _inTmpIndex, modelica_string _inMatrixName, modelica_metatype __omcQ_24in_5FtmpVars, modelica_metatype __omcQ_24in_5FresVars, modelica_metatype *out_resVars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createJacSimVarsColumn(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_metatype _inResIndex, modelica_metatype _inTmpIndex, modelica_metatype _inMatrixName, modelica_metatype __omcQ_24in_5FtmpVars, modelica_metatype __omcQ_24in_5FresVars, modelica_metatype *out_resVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createJacSimVarsColumn,2,0) {(void*) boxptr_SimCodeUtil_createJacSimVarsColumn,0}};
#define boxvar_SimCodeUtil_createJacSimVarsColumn MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createJacSimVarsColumn)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortBackVarWithSimVarsOrder(threadData_t *threadData, modelica_metatype _var, modelica_metatype _vars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortBackVarWithSimVarsOrder,2,0) {(void*) boxptr_SimCodeUtil_sortBackVarWithSimVarsOrder,0}};
#define boxvar_SimCodeUtil_sortBackVarWithSimVarsOrder MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_sortBackVarWithSimVarsOrder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceSeedVarsName(threadData_t *threadData, modelica_metatype _inVars, modelica_string _inMatrixName);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceSeedVarsName,2,0) {(void*) boxptr_SimCodeUtil_replaceSeedVarsName,0}};
#define boxvar_SimCodeUtil_replaceSeedVarsName MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceSeedVarsName)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_checkForEmptyBDAE(threadData_t *threadData, modelica_metatype _inBDAE);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_checkForEmptyBDAE(threadData_t *threadData, modelica_metatype _inBDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_checkForEmptyBDAE,2,0) {(void*) boxptr_SimCodeUtil_checkForEmptyBDAE,0}};
#define boxvar_SimCodeUtil_checkForEmptyBDAE MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_checkForEmptyBDAE)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimEqSystemForJacobians(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_constantEqns, modelica_integer *out_uniqueEqIndex, modelica_metatype *out_tempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimEqSystemForJacobians(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_constantEqns, modelica_metatype *out_uniqueEqIndex, modelica_metatype *out_tempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqSystemForJacobians,2,0) {(void*) boxptr_SimCodeUtil_getSimEqSystemForJacobians,0}};
#define boxvar_SimCodeUtil_getSimEqSystemForJacobians MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimEqSystemForJacobians)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFurtherVars(threadData_t *threadData, modelica_metatype _v, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFurtherVars,2,0) {(void*) boxptr_SimCodeUtil_getFurtherVars,0}};
#define boxvar_SimCodeUtil_getFurtherVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getFurtherVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createStateSetsSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iVars, modelica_metatype _iEqns, modelica_metatype _comps, modelica_metatype _iEquations, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _iNumStateSets, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_integer *out_oNumStateSets);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createStateSetsSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iVars, modelica_metatype _iEqns, modelica_metatype _comps, modelica_metatype _iEquations, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iNumStateSets, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oNumStateSets);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createStateSetsSets,2,0) {(void*) boxptr_SimCodeUtil_createStateSetsSets,0}};
#define boxvar_SimCodeUtil_createStateSetsSets MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createStateSetsSets)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createStateSetsSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createStateSetsSystem,2,0) {(void*) boxptr_SimCodeUtil_createStateSetsSystem,0}};
#define boxvar_SimCodeUtil_createStateSetsSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createStateSetsSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_fillLocalHashTable(threadData_t *threadData, modelica_metatype _varListList, modelica_integer _numberOfElements);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillLocalHashTable(threadData_t *threadData, modelica_metatype _varListList, modelica_metatype _numberOfElements);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillLocalHashTable,2,0) {(void*) boxptr_SimCodeUtil_fillLocalHashTable,0}};
#define boxvar_SimCodeUtil_fillLocalHashTable MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_fillLocalHashTable)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendOMSIFunction(threadData_t *threadData, modelica_metatype __omcQ_24in_5FomsiFunction_5F1, modelica_metatype _omsiFunction_2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendOMSIFunction,2,0) {(void*) boxptr_SimCodeUtil_appendOMSIFunction,0}};
#define boxvar_SimCodeUtil_appendOMSIFunction MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendOMSIFunction)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _syst, modelica_metatype _shared, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_outputVars, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_outputVars, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateInnerEqns,2,0) {(void*) boxptr_SimCodeUtil_generateInnerEqns,0}};
#define boxvar_SimCodeUtil_generateInnerEqns MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateInnerEqns)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateSingleEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _var, modelica_metatype _funcTree, modelica_metatype _timeInterval, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_inputVars, modelica_metatype *out_outputVars, modelica_metatype *out_innerVars, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateSingleEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _var, modelica_metatype _funcTree, modelica_metatype _timeInterval, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_inputVars, modelica_metatype *out_outputVars, modelica_metatype *out_innerVars, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateSingleEquation,2,0) {(void*) boxptr_SimCodeUtil_generateSingleEquation,0}};
#define boxvar_SimCodeUtil_generateSingleEquation MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateSingleEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateEquationsForComponents(threadData_t *threadData, modelica_metatype _components, modelica_metatype _constSyst, modelica_metatype _shared, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateEquationsForComponents(threadData_t *threadData, modelica_metatype _components, modelica_metatype _constSyst, modelica_metatype _shared, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateEquationsForComponents,2,0) {(void*) boxptr_SimCodeUtil_generateEquationsForComponents,0}};
#define boxvar_SimCodeUtil_generateEquationsForComponents MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateEquationsForComponents)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllEquationOMSI(threadData_t *threadData, modelica_metatype _constSysts, modelica_metatype _shared, modelica_metatype _inZeroCrossings, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllEquationOMSI(threadData_t *threadData, modelica_metatype _constSysts, modelica_metatype _shared, modelica_metatype _inZeroCrossings, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllEquationOMSI,2,0) {(void*) boxptr_SimCodeUtil_createAllEquationOMSI,0}};
#define boxvar_SimCodeUtil_createAllEquationOMSI MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createAllEquationOMSI)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystemInnerEqns1(threadData_t *threadData, modelica_metatype _eqn, modelica_integer _eqnindx, modelica_metatype _varindx);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystemInnerEqns1(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _eqnindx, modelica_metatype _varindx);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystemInnerEqns1,2,0) {(void*) boxptr_SimCodeUtil_createTornSystemInnerEqns1,0}};
#define boxvar_SimCodeUtil_createTornSystemInnerEqns1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystemInnerEqns1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystemInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_boolean _skipDiscInAlgorithm, modelica_boolean _genDiscrete, modelica_metatype _isyst, modelica_metatype _ishared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isimequations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_integer *out_nVars, modelica_boolean *out_homotopySupport);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystemInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _genDiscrete, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isimequations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_nVars, modelica_metatype *out_homotopySupport);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystemInnerEqns,2,0) {(void*) boxptr_SimCodeUtil_createTornSystemInnerEqns,0}};
#define boxvar_SimCodeUtil_createTornSystemInnerEqns MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystemInnerEqns)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveInnerEquations1(threadData_t *threadData, modelica_metatype _iExps1, modelica_metatype _iExps2, modelica_metatype _iVars, modelica_metatype _inVars, modelica_metatype _ishared, modelica_metatype _inRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveInnerEquations1,2,0) {(void*) boxptr_SimCodeUtil_solveInnerEquations1,0}};
#define boxvar_SimCodeUtil_solveInnerEquations1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveInnerEquations1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveInnerEquations(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _inEqns, modelica_metatype _inVars, modelica_metatype _ishared, modelica_metatype _inRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveInnerEquations,2,0) {(void*) boxptr_SimCodeUtil_solveInnerEquations,0}};
#define boxvar_SimCodeUtil_solveInnerEquations MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveInnerEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystem(threadData_t *threadData, modelica_boolean _linear, modelica_boolean _skipDiscInAlgorithm, modelica_boolean _genDiscrete, modelica_metatype _strictTearingSet, modelica_metatype _casualTearingSet, modelica_metatype _isyst, modelica_metatype _ishared, modelica_integer _iuniqueEqIndex, modelica_boolean _mixedSystem, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystem(threadData_t *threadData, modelica_metatype _linear, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _genDiscrete, modelica_metatype _strictTearingSet, modelica_metatype _casualTearingSet, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _iuniqueEqIndex, modelica_metatype _mixedSystem, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystem,2,0) {(void*) boxptr_SimCodeUtil_createTornSystem,0}};
#define boxvar_SimCodeUtil_createTornSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTornSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateSolvedEquation(threadData_t *threadData, modelica_metatype _var, modelica_real _val, modelica_metatype _source, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateSolvedEquation(threadData_t *threadData, modelica_metatype _var, modelica_metatype _val, modelica_metatype _source, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateSolvedEquation,2,0) {(void*) boxptr_SimCodeUtil_generateSolvedEquation,0}};
#define boxvar_SimCodeUtil_generateSolvedEquation MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_generateSolvedEquation)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_checkLinearSystem(threadData_t *threadData, modelica_integer _info, modelica_metatype _vars, modelica_metatype _jac, modelica_metatype _rhs);
PROTECTED_FUNCTION_STATIC void boxptr_SimCodeUtil_checkLinearSystem(threadData_t *threadData, modelica_metatype _info, modelica_metatype _vars, modelica_metatype _jac, modelica_metatype _rhs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_checkLinearSystem,2,0) {(void*) boxptr_SimCodeUtil_checkLinearSystem,0}};
#define boxvar_SimCodeUtil_checkLinearSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_checkLinearSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createOdeSystem2(threadData_t *threadData, modelica_boolean _mixedEvent, modelica_metatype _inVars, modelica_metatype _inKnVars, modelica_metatype _inEquationArray, modelica_metatype _inJacobian, modelica_metatype _inJacobianType, modelica_metatype _inFuncs, modelica_metatype _inAllVars, modelica_integer _iuniqueEqIndex, modelica_metatype _iei, modelica_boolean _mixedSystem, modelica_boolean _partOfJac, modelica_metatype _itempvars, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createOdeSystem2(threadData_t *threadData, modelica_metatype _mixedEvent, modelica_metatype _inVars, modelica_metatype _inKnVars, modelica_metatype _inEquationArray, modelica_metatype _inJacobian, modelica_metatype _inJacobianType, modelica_metatype _inFuncs, modelica_metatype _inAllVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _iei, modelica_metatype _mixedSystem, modelica_metatype _partOfJac, modelica_metatype _itempvars, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createOdeSystem2,2,0) {(void*) boxptr_SimCodeUtil_createOdeSystem2,0}};
#define boxvar_SimCodeUtil_createOdeSystem2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createOdeSystem2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createOdeSystem(threadData_t *threadData, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _inComp, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _isccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _iBackendMapping, modelica_metatype *out_noDiscequations_, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oBackendMapping);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createOdeSystem(threadData_t *threadData, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _inComp, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _iBackendMapping, modelica_metatype *out_noDiscequations_, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oBackendMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createOdeSystem,2,0) {(void*) boxptr_SimCodeUtil_createOdeSystem,0}};
#define boxvar_SimCodeUtil_createOdeSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createOdeSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolvedIfBranch(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _ifbranch, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolvedIfBranch(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _ifbranch, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolvedIfBranch,2,0) {(void*) boxptr_SimCodeUtil_makeSolvedIfBranch,0}};
#define boxvar_SimCodeUtil_makeSolvedIfBranch MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolvedIfBranch)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolved(threadData_t *threadData, modelica_metatype _eq, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolved(threadData_t *threadData, modelica_metatype _eq, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolved,2,0) {(void*) boxptr_SimCodeUtil_makeSolved,0}};
#define boxvar_SimCodeUtil_makeSolved MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSolved)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray,2,0) {(void*) boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray,0}};
#define boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__SIMPLE__ASSIGN,2,0) {(void*) boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGN,0}};
#define boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGN MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__SIMPLE__ASSIGN)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__RESIDUAL1(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype *out_idx_tpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__RESIDUAL1,2,0) {(void*) boxptr_SimCodeUtil_makeSES__RESIDUAL1,0}};
#define boxvar_SimCodeUtil_makeSES__RESIDUAL1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__RESIDUAL1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__RESIDUAL(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype *out_idx_tpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__RESIDUAL,2,0) {(void*) boxptr_SimCodeUtil_makeSES__RESIDUAL,0}};
#define boxvar_SimCodeUtil_makeSES__RESIDUAL MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_makeSES__RESIDUAL)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefs(threadData_t *threadData, modelica_metatype _inCrefs, modelica_integer _iuniqueEqIndex, modelica_metatype _inCrefsAcc, modelica_metatype _iRepl, modelica_metatype *out_oRepl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTmpCrefs(threadData_t *threadData, modelica_metatype _inCrefs, modelica_metatype _iuniqueEqIndex, modelica_metatype _inCrefsAcc, modelica_metatype _iRepl, modelica_metatype *out_oRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefs,2,0) {(void*) boxptr_SimCodeUtil_createTmpCrefs,0}};
#define boxvar_SimCodeUtil_createTmpCrefs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dimsToAllIndexes2(threadData_t *threadData, modelica_integer _i, modelica_metatype _iIndex, modelica_metatype _iAllIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dimsToAllIndexes2(threadData_t *threadData, modelica_metatype _i, modelica_metatype _iIndex, modelica_metatype _iAllIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimsToAllIndexes2,2,0) {(void*) boxptr_SimCodeUtil_dimsToAllIndexes2,0}};
#define boxvar_SimCodeUtil_dimsToAllIndexes2 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimsToAllIndexes2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dimsToAllIndexes1(threadData_t *threadData, modelica_metatype _inDims);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimsToAllIndexes1,2,0) {(void*) boxptr_SimCodeUtil_dimsToAllIndexes1,0}};
#define boxvar_SimCodeUtil_dimsToAllIndexes1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_dimsToAllIndexes1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTempVars(threadData_t *threadData, modelica_metatype _varLst, modelica_metatype _inCrefPrefix, modelica_metatype _itempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTempVars,2,0) {(void*) boxptr_SimCodeUtil_createTempVars,0}};
#define boxvar_SimCodeUtil_createTempVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTempVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTempVarsforCrefs(threadData_t *threadData, modelica_metatype _inTmpCrefsLst, modelica_metatype _itempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTempVarsforCrefs,2,0) {(void*) boxptr_SimCodeUtil_createTempVarsforCrefs,0}};
#define boxvar_SimCodeUtil_createTempVarsforCrefs MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTempVarsforCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createArrayTempVar(threadData_t *threadData, modelica_metatype _name, modelica_metatype _dims, modelica_metatype _inTmpCrefsLst, modelica_metatype _itempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createArrayTempVar,2,0) {(void*) boxptr_SimCodeUtil_createArrayTempVar,0}};
#define boxvar_SimCodeUtil_createArrayTempVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createArrayTempVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inCrefPrefix, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype _callCrefs, modelica_metatype __omcQ_24in_5FlhsExpLstRes, modelica_metatype __omcQ_24in_5FrhsExpLstRes, modelica_metatype __omcQ_24in_5FlhsExpLstAss, modelica_metatype __omcQ_24in_5FrhsExpLstAss, modelica_metatype *out_outCrefExp, modelica_metatype *out_lhsExpLstRes, modelica_metatype *out_rhsExpLstRes, modelica_metatype *out_lhsExpLstAss, modelica_metatype *out_rhsExpLstAss);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work,2,0) {(void*) boxptr_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work,0}};
#define boxvar_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys(threadData_t *threadData, modelica_metatype _inExpLst, modelica_metatype _crPrefix, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype _callCrefs, modelica_metatype __omcQ_24in_5FlhsExpLstRes, modelica_metatype __omcQ_24in_5FrhsExpLstRes, modelica_metatype __omcQ_24in_5FlhsExpLstAss, modelica_metatype __omcQ_24in_5FrhsExpLstAss, modelica_metatype *out_outExpList, modelica_metatype *out_lhsExpLstRes, modelica_metatype *out_rhsExpLstRes, modelica_metatype *out_lhsExpLstAss, modelica_metatype *out_rhsExpLstAss);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefExpsForComplexEqnSys,2,0) {(void*) boxptr_SimCodeUtil_createTmpCrefExpsForComplexEqnSys,0}};
#define boxvar_SimCodeUtil_createTmpCrefExpsForComplexEqnSys MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createTmpCrefExpsForComplexEqnSys)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_eqCrefs);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_eqCrefs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createNonlinearResidualEquationsSingleComplex,2,0) {(void*) boxptr_SimCodeUtil_createNonlinearResidualEquationsSingleComplex,0}};
#define boxvar_SimCodeUtil_createNonlinearResidualEquationsSingleComplex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createNonlinearResidualEquationsSingleComplex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createNonlinearResidualEquationsComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype __omcQ_24in_5Ftempvars, modelica_metatype *out_idx_tpl, modelica_metatype *out_tempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createNonlinearResidualEquationsComplex,2,0) {(void*) boxptr_SimCodeUtil_createNonlinearResidualEquationsComplex,0}};
#define boxvar_SimCodeUtil_createNonlinearResidualEquationsComplex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createNonlinearResidualEquationsComplex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveAlgorithmInverse(threadData_t *threadData, modelica_metatype _inStmts, modelica_metatype _inSolveFor);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveAlgorithmInverse,2,0) {(void*) boxptr_SimCodeUtil_solveAlgorithmInverse,0}};
#define boxvar_SimCodeUtil_solveAlgorithmInverse MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_solveAlgorithmInverse)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceIFBrancheswithoutVar(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceIFBrancheswithoutVar,2,0) {(void*) boxptr_SimCodeUtil_replaceIFBrancheswithoutVar,0}};
#define boxvar_SimCodeUtil_replaceIFBrancheswithoutVar MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_replaceIFBrancheswithoutVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationImpl(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _v, modelica_metatype _vars, modelica_metatype _partitionKind, modelica_metatype _shared, modelica_boolean _skipDiscInAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationImpl(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _v, modelica_metatype _vars, modelica_metatype _partitionKind, modelica_metatype _shared, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationImpl,2,0) {(void*) boxptr_SimCodeUtil_createEquationImpl,0}};
#define boxvar_SimCodeUtil_createEquationImpl MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationImpl)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquation(threadData_t *threadData, modelica_integer _eqNum, modelica_integer _varNum, modelica_metatype _syst, modelica_metatype _shared, modelica_boolean _skipDiscInAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquation(threadData_t *threadData, modelica_metatype _eqNum, modelica_metatype _varNum, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquation,2,0) {(void*) boxptr_SimCodeUtil_createEquation,0}};
#define boxvar_SimCodeUtil_createEquation MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_partitionKindToClockIndex(threadData_t *threadData, modelica_metatype _kind);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_partitionKindToClockIndex,2,0) {(void*) boxptr_SimCodeUtil_partitionKindToClockIndex,0}};
#define boxvar_SimCodeUtil_partitionKindToClockIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_partitionKindToClockIndex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addAssertEqn(threadData_t *threadData, modelica_metatype _asserts, modelica_metatype _iequations, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_addAssertEqn(threadData_t *threadData, modelica_metatype _asserts, modelica_metatype _iequations, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addAssertEqn,2,0) {(void*) boxptr_SimCodeUtil_addAssertEqn,0}};
#define boxvar_SimCodeUtil_addAssertEqn MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addAssertEqn)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListIndx(threadData_t *threadData, modelica_metatype _iIntList, modelica_metatype _iMappingArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListIndx,2,0) {(void*) boxptr_SimCodeUtil_convertListIndx,0}};
#define boxvar_SimCodeUtil_convertListIndx MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListIndx)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListMappingToArray1(threadData_t *threadData, modelica_metatype _iMapping, modelica_metatype _iMappingArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListMappingToArray1,2,0) {(void*) boxptr_SimCodeUtil_convertListMappingToArray1,0}};
#define boxvar_SimCodeUtil_convertListMappingToArray1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListMappingToArray1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListMappingToArray(threadData_t *threadData, modelica_metatype _iMapping, modelica_integer _numOfBackendEqs);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_convertListMappingToArray(threadData_t *threadData, modelica_metatype _iMapping, modelica_metatype _numOfBackendEqs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListMappingToArray,2,0) {(void*) boxptr_SimCodeUtil_convertListMappingToArray,0}};
#define boxvar_SimCodeUtil_convertListMappingToArray MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_convertListMappingToArray)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateZeroCrossEqnIndexHelp(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMappingArray, modelica_metatype _iAccum);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateZeroCrossEqnIndexHelp,2,0) {(void*) boxptr_SimCodeUtil_updateZeroCrossEqnIndexHelp,0}};
#define boxvar_SimCodeUtil_updateZeroCrossEqnIndexHelp MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateZeroCrossEqnIndexHelp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateZeroCrossEqnIndex(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMapping, modelica_integer _numEqnsinArray);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateZeroCrossEqnIndex(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMapping, modelica_metatype _numEqnsinArray);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateZeroCrossEqnIndex,2,0) {(void*) boxptr_SimCodeUtil_updateZeroCrossEqnIndex,0}};
#define boxvar_SimCodeUtil_updateZeroCrossEqnIndex MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateZeroCrossEqnIndex)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_whenEquationsIndices(threadData_t *threadData, modelica_metatype _eqns);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_whenEquationsIndices,2,0) {(void*) boxptr_SimCodeUtil_whenEquationsIndices,0}};
#define boxvar_SimCodeUtil_whenEquationsIndices MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_whenEquationsIndices)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_zeroCrossingEquations(threadData_t *threadData, modelica_metatype _inZC);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_zeroCrossingEquations,2,0) {(void*) boxptr_SimCodeUtil_zeroCrossingEquations,0}};
#define boxvar_SimCodeUtil_zeroCrossingEquations MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_zeroCrossingEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_zeroCrossingsEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_zeroCrossingsEquations,2,0) {(void*) boxptr_SimCodeUtil_zeroCrossingsEquations,0}};
#define boxvar_SimCodeUtil_zeroCrossingsEquations MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_zeroCrossingsEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsWork(threadData_t *threadData, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comp, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_noDiscEquations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsWork(threadData_t *threadData, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comp, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_noDiscEquations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsWork,2,0) {(void*) boxptr_SimCodeUtil_createEquationsWork,0}};
#define boxvar_SimCodeUtil_createEquationsWork MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsWork)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquations(threadData_t *threadData, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_noDiscEquations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquations(threadData_t *threadData, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_noDiscEquations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquations,2,0) {(void*) boxptr_SimCodeUtil_createEquations,0}};
#define boxvar_SimCodeUtil_createEquations MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendSccIdxRange(threadData_t *threadData, modelica_integer _iCurrentIdxStart, modelica_integer _iCurrentIdxStop, modelica_integer _iSccIdx, modelica_metatype _iSccIdc);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendSccIdxRange(threadData_t *threadData, modelica_metatype _iCurrentIdxStart, modelica_metatype _iCurrentIdxStop, modelica_metatype _iSccIdx, modelica_metatype _iSccIdc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendSccIdxRange,2,0) {(void*) boxptr_SimCodeUtil_appendSccIdxRange,0}};
#define boxvar_SimCodeUtil_appendSccIdxRange MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendSccIdxRange)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendSccIdx(threadData_t *threadData, modelica_integer _iCurrentIdx, modelica_integer _iSccIdx, modelica_metatype _iSccIdc);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendSccIdx(threadData_t *threadData, modelica_metatype _iCurrentIdx, modelica_metatype _iSccIdx, modelica_metatype _iSccIdc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendSccIdx,2,0) {(void*) boxptr_SimCodeUtil_appendSccIdx,0}};
#define boxvar_SimCodeUtil_appendSccIdx MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_appendSccIdx)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystem1(threadData_t *threadData, modelica_metatype _comp, modelica_metatype _inArg, modelica_metatype _clockIndex, modelica_metatype _inFold);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystem1,2,0) {(void*) boxptr_SimCodeUtil_createEquationsForSystem1,0}};
#define boxvar_SimCodeUtil_createEquationsForSystem1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystem1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addEquationsToLists(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _eqsIdx, modelica_metatype _inOdeEquations, modelica_metatype _inAlgebraicEquations, modelica_metatype _inAllEquations, modelica_metatype _inEquationsforZeroCrossings, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addEquationsToLists,2,0) {(void*) boxptr_SimCodeUtil_addEquationsToLists,0}};
#define boxvar_SimCodeUtil_addEquationsToLists MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addEquationsToLists)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystem(threadData_t *threadData, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _iSccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _iBackendMapping, modelica_boolean _createAlgebraicEquations, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_oBackendMapping);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsForSystem(threadData_t *threadData, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iSccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _iBackendMapping, modelica_metatype _createAlgebraicEquations, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_oBackendMapping);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystem,2,0) {(void*) boxptr_SimCodeUtil_createEquationsForSystem,0}};
#define boxvar_SimCodeUtil_createEquationsForSystem MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystems1(threadData_t *threadData, modelica_metatype _inSyst, modelica_metatype _inArg, modelica_metatype _inFold);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystems1,2,0) {(void*) boxptr_SimCodeUtil_createEquationsForSystems1,0}};
#define boxvar_SimCodeUtil_createEquationsForSystems1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystems1)
PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_createEquationsForSystems(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _shared, modelica_integer _iuniqueEqIndex, modelica_metatype _inAllZeroCrossings, modelica_metatype _itempvars, modelica_integer _iSccOffset, modelica_metatype _iBackendMapping, modelica_boolean _createAlgebraicEquations, modelica_metatype *out_oodeEquations, modelica_metatype *out_oalgebraicEquations, modelica_metatype *out_olocalKnownVars, modelica_metatype *out_oallEquations, modelica_metatype *out_oequationsForZeroCrossings, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_obackendMapping, modelica_integer *out_oSccOffset);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsForSystems(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _shared, modelica_metatype _iuniqueEqIndex, modelica_metatype _inAllZeroCrossings, modelica_metatype _itempvars, modelica_metatype _iSccOffset, modelica_metatype _iBackendMapping, modelica_metatype _createAlgebraicEquations, modelica_metatype *out_oodeEquations, modelica_metatype *out_oalgebraicEquations, modelica_metatype *out_olocalKnownVars, modelica_metatype *out_oallEquations, modelica_metatype *out_oequationsForZeroCrossings, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_obackendMapping, modelica_metatype *out_oSccOffset);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystems,2,0) {(void*) boxptr_SimCodeUtil_createEquationsForSystems,0}};
#define boxvar_SimCodeUtil_createEquationsForSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createEquationsForSystems)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_rewriteJacPartIdx(threadData_t *threadData, modelica_metatype _inJac, modelica_integer _index);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_rewriteJacPartIdx(threadData_t *threadData, modelica_metatype _inJac, modelica_metatype _index);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_rewriteJacPartIdx,2,0) {(void*) boxptr_SimCodeUtil_rewriteJacPartIdx,0}};
#define boxvar_SimCodeUtil_rewriteJacPartIdx MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_rewriteJacPartIdx)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addAlgebraicLoopsClockPartitions(threadData_t *threadData, modelica_metatype _inColockPartition, modelica_metatype _inModelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_outSymJacs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addAlgebraicLoopsClockPartitions,2,0) {(void*) boxptr_SimCodeUtil_addAlgebraicLoopsClockPartitions,0}};
#define boxvar_SimCodeUtil_addAlgebraicLoopsClockPartitions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addAlgebraicLoopsClockPartitions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateLinearSyst(threadData_t *threadData, modelica_metatype __omcQ_24in_5FinSyst, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype __omcQ_24in_5FallSymJacs, modelica_metatype *out_modelInfo, modelica_metatype *out_allSymJacs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateLinearSyst,2,0) {(void*) boxptr_SimCodeUtil_updateLinearSyst,0}};
#define boxvar_SimCodeUtil_updateLinearSyst MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateLinearSyst)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateNonLinearSyst(threadData_t *threadData, modelica_metatype __omcQ_24in_5FinSyst, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype __omcQ_24in_5FallSymJacs, modelica_metatype *out_modelInfo, modelica_metatype *out_allSymJacs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateNonLinearSyst,2,0) {(void*) boxptr_SimCodeUtil_updateNonLinearSyst,0}};
#define boxvar_SimCodeUtil_updateNonLinearSyst MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_updateNonLinearSyst)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSystemIndexMap(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inSysIndexMap);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSystemIndexMap,2,0) {(void*) boxptr_SimCodeUtil_setSystemIndexMap,0}};
#define boxvar_SimCodeUtil_setSystemIndexMap MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_setSystemIndexMap)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSystemIndexMap(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inSysIndexMap);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSystemIndexMap,2,0) {(void*) boxptr_SimCodeUtil_getSystemIndexMap,0}};
#define boxvar_SimCodeUtil_getSystemIndexMap MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSystemIndexMap)
PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_addTempVars(threadData_t *threadData, modelica_metatype _simVars, modelica_metatype _tempVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_addTempVars,2,0) {(void*) boxptr_SimCodeUtil_addTempVars,0}};
#define boxvar_SimCodeUtil_addTempVars MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_addTempVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimVarCompRef(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarCompRef,2,0) {(void*) boxptr_SimCodeUtil_getSimVarCompRef,0}};
#define boxvar_SimCodeUtil_getSimVarCompRef MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getSimVarCompRef)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectClockedVars1(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectClockedVars1,2,0) {(void*) boxptr_SimCodeUtil_collectClockedVars1,0}};
#define boxvar_SimCodeUtil_collectClockedVars1 MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_collectClockedVars1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createClockedSimPartitions(threadData_t *threadData, modelica_metatype _basePartitions, modelica_metatype _subPartitions);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_createClockedSimPartitions,2,0) {(void*) boxptr_SimCodeUtil_createClockedSimPartitions,0}};
#define boxvar_SimCodeUtil_createClockedSimPartitions MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_createClockedSimPartitions)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateClockedEquations(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_integer _iSccOffset, modelica_integer _iuniqueEqIndex, modelica_metatype _iBackendMapping, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_oBackendMapping, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_otempvars);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_translateClockedEquations(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_metatype _iSccOffset, modelica_metatype _iuniqueEqIndex, modelica_metatype _iBackendMapping, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_oBackendMapping, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_otempvars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateClockedEquations,2,0) {(void*) boxptr_SimCodeUtil_translateClockedEquations,0}};
#define boxvar_SimCodeUtil_translateClockedEquations MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_translateClockedEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getParamAsserts(threadData_t *threadData, modelica_metatype _eqIn, modelica_metatype _vars, modelica_metatype _tplIn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_getParamAsserts,2,0) {(void*) boxptr_SimCodeUtil_getParamAsserts,0}};
#define boxvar_SimCodeUtil_getParamAsserts MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_getParamAsserts)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_expandEntwined(threadData_t *threadData, modelica_metatype _eq);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_expandEntwined,2,0) {(void*) boxptr_SimCodeUtil_expandEntwined,0}};
#define boxvar_SimCodeUtil_expandEntwined MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_expandEntwined)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_compareEqSystems(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_compareEqSystems(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_SimCodeUtil_compareEqSystems,2,0) {(void*) boxptr_SimCodeUtil_compareEqSystems,0}};
#define boxvar_SimCodeUtil_compareEqSystems MMC_REFSTRUCTLIT(boxvar_lit_SimCodeUtil_compareEqSystems)

DLLDirection
modelica_metatype omc_SimCodeUtil_getExpNominal(threadData_t *threadData, modelica_metatype _expr)
{
  modelica_metatype _nominal = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nominal has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _expr;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _v = NULL;
      modelica_real _r1;
      modelica_real _r2;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _t = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _v has no default value.
      // _r1 has no default value.
      // _r2 has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _t has no default value.
      tmp4 = 0;
      for (; tmp4 < 32; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta6 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(fabs(((modelica_real)mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))))))));
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(fabs(mmc_unbox_real((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2)))))));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          _cr = tmpMeta8;
          _t = tmpMeta9;
          /* Pattern matching succeeded */
          _v = omc_SimCodeUtil_cref2simvar(threadData, _cr, omc_SimCodeUtil_getSimCode(threadData));
          { /* match expression */
            modelica_metatype tmp13_1;
            tmp13_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 11)));
            {
              volatile mmc_switch_type tmp13;
              int tmp14;
              tmp13 = 0;
              for (; tmp13 < 3; tmp13++) {
                switch (MMC_SWITCH_CAST(tmp13)) {
                case 0: {
                  modelica_metatype tmpMeta15;
                  modelica_metatype tmpMeta16;
                  modelica_real tmp17;
                  modelica_metatype tmpMeta18;
                  if (optionNone(tmp13_1)) goto tmp12_end;
                  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 1));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,1,1) == 0) goto tmp12_end;
                  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
                  tmp17 = mmc_unbox_real(tmpMeta16);
                  _r1 = tmp17  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta18 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(fabs(_r1)));
                  tmpMeta10 = tmpMeta18;
                  goto tmp12_done;
                }
                case 1: {
                  modelica_metatype tmpMeta19;
                  modelica_metatype tmpMeta20;
                  if (optionNone(tmp13_1)) goto tmp12_end;
                  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 1));
                  _e1 = tmpMeta19;
                  /* Pattern matching succeeded */
                  tmpMeta20 = mmc_mk_cons(_e1, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta10 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT0, tmpMeta20, _t);
                  goto tmp12_done;
                }
                case 2: {
                  modelica_metatype tmpMeta21;
                  if (!optionNone(tmp13_1)) goto tmp12_end;
                  /* Pattern matching succeeded */
                  { /* match expression */
                    modelica_metatype tmp24_1;
                    tmp24_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 3)));
                    {
                      volatile mmc_switch_type tmp24;
                      int tmp25;
                      tmp24 = 0;
                      for (; tmp24 < 2; tmp24++) {
                        switch (MMC_SWITCH_CAST(tmp24)) {
                        case 0: {
                          modelica_metatype tmpMeta26;
                          if (mmc__uniontype__metarecord__typedef__equal(tmp24_1,7,0) == 0) goto tmp23_end;
                          /* Pattern matching succeeded */
                          tmpMeta26 = mmc_mk_cons(_expr, MMC_REFSTRUCTLIT(mmc_nil));
                          tmpMeta21 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT0, tmpMeta26, _t);
                          goto tmp23_done;
                        }
                        case 1: {
                          
                          /* Pattern matching succeeded */
                          tmpMeta21 = _OMC_LIT2;
                          goto tmp23_done;
                        }
                        }
                        goto tmp23_end;
                        tmp23_end: ;
                      }
                      goto goto_22;
                      goto_22:;
                      goto goto_11;
                      goto tmp23_done;
                      tmp23_done:;
                    }
                  }tmpMeta10 = tmpMeta21;
                  goto tmp12_done;
                }
                }
                goto tmp12_end;
                tmp12_end: ;
              }
              goto goto_11;
              goto_11:;
              goto goto_2;
              goto tmp12_done;
              tmp12_done:;
            }
          }tmpMeta1 = tmpMeta10;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,0,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp31_1;modelica_metatype tmp31_2;
            tmp31_1 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))));
            tmp31_2 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4))));
            {
              volatile mmc_switch_type tmp31;
              int tmp32;
              tmp31 = 0;
              for (; tmp31 < 2; tmp31++) {
                switch (MMC_SWITCH_CAST(tmp31)) {
                case 0: {
                  modelica_metatype tmpMeta33;
                  modelica_real tmp34;
                  modelica_metatype tmpMeta35;
                  modelica_real tmp36;
                  modelica_metatype tmpMeta37;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp31_1,1,1) == 0) goto tmp30_end;
                  tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp31_1), 2));
                  tmp34 = mmc_unbox_real(tmpMeta33);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp31_2,1,1) == 0) goto tmp30_end;
                  tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp31_2), 2));
                  tmp36 = mmc_unbox_real(tmpMeta35);
                  _r1 = tmp34  /* pattern as ty=Real */;
                  _r2 = tmp36  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta37 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(_r1 + _r2));
                  tmpMeta28 = tmpMeta37;
                  goto tmp30_done;
                }
                case 1: {
                  modelica_metatype tmpMeta38;
                  
                  _e1 = tmp31_1;
                  _e2 = tmp31_2;
                  /* Pattern matching succeeded */
                  tmpMeta38 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _e1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3))), _e2);
                  tmpMeta28 = tmpMeta38;
                  goto tmp30_done;
                }
                }
                goto tmp30_end;
                tmp30_end: ;
              }
              goto goto_29;
              goto_29:;
              goto goto_2;
              goto tmp30_done;
              tmp30_done:;
            }
          }tmpMeta1 = tmpMeta28;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,1,1) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          
          _t = tmpMeta40;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp44_1;modelica_metatype tmp44_2;
            tmp44_1 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))));
            tmp44_2 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4))));
            {
              volatile mmc_switch_type tmp44;
              int tmp45;
              tmp44 = 0;
              for (; tmp44 < 2; tmp44++) {
                switch (MMC_SWITCH_CAST(tmp44)) {
                case 0: {
                  modelica_metatype tmpMeta46;
                  modelica_real tmp47;
                  modelica_metatype tmpMeta48;
                  modelica_real tmp49;
                  modelica_metatype tmpMeta50;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp44_1,1,1) == 0) goto tmp43_end;
                  tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp44_1), 2));
                  tmp47 = mmc_unbox_real(tmpMeta46);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp44_2,1,1) == 0) goto tmp43_end;
                  tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp44_2), 2));
                  tmp49 = mmc_unbox_real(tmpMeta48);
                  _r1 = tmp47  /* pattern as ty=Real */;
                  _r2 = tmp49  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta50 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(_r1 + _r2));
                  tmpMeta41 = tmpMeta50;
                  goto tmp43_done;
                }
                case 1: {
                  modelica_metatype tmpMeta51;
                  modelica_metatype tmpMeta52;
                  
                  _e1 = tmp44_1;
                  _e2 = tmp44_2;
                  /* Pattern matching succeeded */
                  tmpMeta51 = mmc_mk_box2(3, &DAE_Operator_ADD__desc, _t);
                  tmpMeta52 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _e1, tmpMeta51, _e2);
                  tmpMeta41 = tmpMeta52;
                  goto tmp43_done;
                }
                }
                goto tmp43_end;
                tmp43_end: ;
              }
              goto goto_42;
              goto_42:;
              goto goto_2;
              goto tmp43_done;
              tmp43_done:;
            }
          }tmpMeta1 = tmpMeta41;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta53,2,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp57_1;modelica_metatype tmp57_2;
            tmp57_1 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))));
            tmp57_2 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4))));
            {
              volatile mmc_switch_type tmp57;
              int tmp58;
              tmp57 = 0;
              for (; tmp57 < 2; tmp57++) {
                switch (MMC_SWITCH_CAST(tmp57)) {
                case 0: {
                  modelica_metatype tmpMeta59;
                  modelica_real tmp60;
                  modelica_metatype tmpMeta61;
                  modelica_real tmp62;
                  modelica_metatype tmpMeta63;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp57_1,1,1) == 0) goto tmp56_end;
                  tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp57_1), 2));
                  tmp60 = mmc_unbox_real(tmpMeta59);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp57_2,1,1) == 0) goto tmp56_end;
                  tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp57_2), 2));
                  tmp62 = mmc_unbox_real(tmpMeta61);
                  _r1 = tmp60  /* pattern as ty=Real */;
                  _r2 = tmp62  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta63 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real((_r1) * (_r2)));
                  tmpMeta54 = tmpMeta63;
                  goto tmp56_done;
                }
                case 1: {
                  modelica_metatype tmpMeta64;
                  
                  _e1 = tmp57_1;
                  _e2 = tmp57_2;
                  /* Pattern matching succeeded */
                  tmpMeta64 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _e1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3))), _e2);
                  tmpMeta54 = tmpMeta64;
                  goto tmp56_done;
                }
                }
                goto tmp56_end;
                tmp56_end: ;
              }
              goto goto_55;
              goto_55:;
              goto goto_2;
              goto tmp56_done;
              tmp56_done:;
            }
          }tmpMeta1 = tmpMeta54;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta65,3,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp69_1;modelica_metatype tmp69_2;
            tmp69_1 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))));
            tmp69_2 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4))));
            {
              volatile mmc_switch_type tmp69;
              int tmp70;
              tmp69 = 0;
              for (; tmp69 < 2; tmp69++) {
                switch (MMC_SWITCH_CAST(tmp69)) {
                case 0: {
                  modelica_metatype tmpMeta71;
                  modelica_real tmp72;
                  modelica_metatype tmpMeta73;
                  modelica_real tmp74;
                  modelica_real tmp75;
                  modelica_metatype tmpMeta76;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp69_1,1,1) == 0) goto tmp68_end;
                  tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp69_1), 2));
                  tmp72 = mmc_unbox_real(tmpMeta71);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp69_2,1,1) == 0) goto tmp68_end;
                  tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp69_2), 2));
                  tmp74 = mmc_unbox_real(tmpMeta73);
                  _r1 = tmp72  /* pattern as ty=Real */;
                  _r2 = tmp74  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp75 = _r2;
                  if (tmp75 == 0) {goto goto_67;}
                  tmpMeta76 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real((_r1) / tmp75));
                  tmpMeta66 = tmpMeta76;
                  goto tmp68_done;
                }
                case 1: {
                  modelica_metatype tmpMeta77;
                  
                  _e1 = tmp69_1;
                  _e2 = tmp69_2;
                  /* Pattern matching succeeded */
                  tmpMeta77 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _e1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3))), _e2);
                  tmpMeta66 = tmpMeta77;
                  goto tmp68_done;
                }
                }
                goto tmp68_end;
                tmp68_end: ;
              }
              goto goto_67;
              goto_67:;
              goto goto_2;
              goto tmp68_done;
              tmp68_done:;
            }
          }tmpMeta1 = tmpMeta66;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta78,4,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp82_1;modelica_metatype tmp82_2;
            tmp82_1 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))));
            tmp82_2 = omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4))));
            {
              volatile mmc_switch_type tmp82;
              int tmp83;
              tmp82 = 0;
              for (; tmp82 < 2; tmp82++) {
                switch (MMC_SWITCH_CAST(tmp82)) {
                case 0: {
                  modelica_metatype tmpMeta84;
                  modelica_real tmp85;
                  modelica_metatype tmpMeta86;
                  modelica_real tmp87;
                  modelica_real tmp88;
                  modelica_real tmp89;
                  modelica_real tmp90;
                  modelica_real tmp91;
                  modelica_real tmp92;
                  modelica_real tmp93;
                  modelica_real tmp94;
                  modelica_metatype tmpMeta95;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp82_1,1,1) == 0) goto tmp81_end;
                  tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp82_1), 2));
                  tmp85 = mmc_unbox_real(tmpMeta84);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp82_2,1,1) == 0) goto tmp81_end;
                  tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp82_2), 2));
                  tmp87 = mmc_unbox_real(tmpMeta86);
                  _r1 = tmp85  /* pattern as ty=Real */;
                  _r2 = tmp87  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp88 = _r1;
                  tmp89 = _r2;
                  if(tmp88 < 0.0 && tmp89 != 0.0)
                  {
                    tmp91 = modf(tmp89, &tmp92);
                    
                    if(tmp91 > 0.5)
                    {
                      tmp91 -= 1.0;
                      tmp92 += 1.0;
                    }
                    else if(tmp91 < -0.5)
                    {
                      tmp91 += 1.0;
                      tmp92 -= 1.0;
                    }
                    
                    if(fabs(tmp91) < 1e-10)
                      tmp90 = pow(tmp88, tmp92);
                    else
                    {
                      tmp94 = modf(1.0/tmp89, &tmp93);
                      if(tmp94 > 0.5)
                      {
                        tmp94 -= 1.0;
                        tmp93 += 1.0;
                      }
                      else if(tmp94 < -0.5)
                      {
                        tmp94 += 1.0;
                        tmp93 -= 1.0;
                      }
                      if(fabs(tmp94) < 1e-10 && ((unsigned long)tmp93 & 1))
                      {
                        tmp90 = -pow(-tmp88, tmp91)*pow(tmp88, tmp92);
                      }
                      else
                      {
                        goto goto_80;
                      }
                    }
                  }
                  else
                  {
                    tmp90 = pow(tmp88, tmp89);
                  }
                  if(isnan(tmp90) || isinf(tmp90))
                  {
                    goto goto_80;
                  }tmpMeta95 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(tmp90));
                  tmpMeta79 = tmpMeta95;
                  goto tmp81_done;
                }
                case 1: {
                  modelica_metatype tmpMeta96;
                  
                  _e1 = tmp82_1;
                  _e2 = tmp82_2;
                  /* Pattern matching succeeded */
                  tmpMeta96 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _e1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3))), _e2);
                  tmpMeta79 = tmpMeta96;
                  goto tmp81_done;
                }
                }
                goto tmp81_end;
                tmp81_end: ;
              }
              goto goto_80;
              goto_80:;
              goto goto_2;
              goto tmp81_done;
              tmp81_done:;
            }
          }tmpMeta1 = tmpMeta79;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta97,5,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3)));
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta98;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta98 = mmc_mk_box4(15, &DAE_Exp_IFEXP__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 2))), omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 3)))), omc_SimCodeUtil_getExpNominal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_expr), 4)))));
          tmpMeta1 = tmpMeta98;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta99,1,1) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta99), 2));
          if (3 != MMC_STRLEN(tmpMeta100) || strcmp(MMC_STRINGDATA(_OMC_LIT0), MMC_STRINGDATA(tmpMeta100)) != 0) goto tmp3_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta101)) goto tmp3_end;
          tmpMeta102 = MMC_CAR(tmpMeta101);
          tmpMeta103 = MMC_CDR(tmpMeta101);
          if (!listEmpty(tmpMeta103)) goto tmp3_end;
          
          _e1 = tmpMeta102;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta104,1,1) == 0) goto tmp3_end;
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 2));
          if (4 != MMC_STRLEN(tmpMeta105) || strcmp(MMC_STRINGDATA(_OMC_LIT10), MMC_STRINGDATA(tmpMeta105)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta106,1,1) == 0) goto tmp3_end;
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta106), 2));
          if (4 != MMC_STRLEN(tmpMeta107) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta107)) != 0) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta108)) goto tmp3_end;
          tmpMeta109 = MMC_CAR(tmpMeta108);
          tmpMeta110 = MMC_CDR(tmpMeta108);
          if (!listEmpty(tmpMeta110)) goto tmp3_end;
          tmpMeta111 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta112 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta111), 2));
          
          _e1 = tmpMeta109;
          _t = tmpMeta112;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp116_1;
            tmp116_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp116;
              int tmp117;
              tmp116 = 0;
              for (; tmp116 < 2; tmp116++) {
                switch (MMC_SWITCH_CAST(tmp116)) {
                case 0: {
                  modelica_metatype tmpMeta118;
                  modelica_real tmp119;
                  modelica_real tmp120;
                  modelica_metatype tmpMeta121;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp116_1,1,1) == 0) goto tmp115_end;
                  tmpMeta118 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp116_1), 2));
                  tmp119 = mmc_unbox_real(tmpMeta118);
                  _r1 = tmp119  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp120 = _r1;
                  if(!(tmp120 >= 0.0))
                  {
                    FILE_INFO info = {"",0,0,0,0,0};
                    omc_assert(threadData, info, "Model error: Argument of sqrt(r1) was %g should be >= 0", tmp120);
                  }tmpMeta121 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(sqrt(tmp120)));
                  tmpMeta113 = tmpMeta121;
                  goto tmp115_done;
                }
                case 1: {
                  modelica_metatype tmpMeta122;
                  
                  _e2 = tmp116_1;
                  /* Pattern matching succeeded */
                  tmpMeta122 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta113 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT3, tmpMeta122, _t);
                  goto tmp115_done;
                }
                }
                goto tmp115_end;
                tmp115_end: ;
              }
              goto goto_114;
              goto_114:;
              goto goto_2;
              goto tmp115_done;
              tmp115_done:;
            }
          }tmpMeta1 = tmpMeta113;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          modelica_metatype tmpMeta125;
          modelica_metatype tmpMeta126;
          modelica_metatype tmpMeta127;
          modelica_metatype tmpMeta128;
          modelica_metatype tmpMeta129;
          modelica_metatype tmpMeta130;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta123 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta123,1,1) == 0) goto tmp3_end;
          tmpMeta124 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 2));
          if (3 != MMC_STRLEN(tmpMeta124) || strcmp(MMC_STRINGDATA(_OMC_LIT11), MMC_STRINGDATA(tmpMeta124)) != 0) goto tmp3_end;
          tmpMeta125 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta125)) goto tmp3_end;
          tmpMeta126 = MMC_CAR(tmpMeta125);
          tmpMeta127 = MMC_CDR(tmpMeta125);
          if (listEmpty(tmpMeta127)) goto tmp3_end;
          tmpMeta128 = MMC_CAR(tmpMeta127);
          tmpMeta129 = MMC_CDR(tmpMeta127);
          if (!listEmpty(tmpMeta129)) goto tmp3_end;
          
          _e1 = tmpMeta126;
          _e2 = tmpMeta128;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp133_1;modelica_metatype tmp133_2;
            tmp133_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            tmp133_2 = omc_SimCodeUtil_getExpNominal(threadData, _e2);
            {
              volatile mmc_switch_type tmp133;
              int tmp134;
              tmp133 = 0;
              for (; tmp133 < 2; tmp133++) {
                switch (MMC_SWITCH_CAST(tmp133)) {
                case 0: {
                  modelica_metatype tmpMeta135;
                  modelica_real tmp136;
                  modelica_metatype tmpMeta137;
                  modelica_real tmp138;
                  modelica_real tmp139;
                  modelica_metatype tmpMeta140;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp133_1,1,1) == 0) goto tmp132_end;
                  tmpMeta135 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp133_1), 2));
                  tmp136 = mmc_unbox_real(tmpMeta135);
                  if (mmc__uniontype__metarecord__typedef__equal(tmp133_2,1,1) == 0) goto tmp132_end;
                  tmpMeta137 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp133_2), 2));
                  tmp138 = mmc_unbox_real(tmpMeta137);
                  _r1 = tmp136  /* pattern as ty=Real */;
                  _r2 = tmp138  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp139 = _r2;
                  if (tmp139 == 0) {goto goto_131;}
                  tmpMeta140 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(fmax(1.0,fabs((_r1) / tmp139))));
                  tmpMeta130 = tmpMeta140;
                  goto tmp132_done;
                }
                case 1: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta130 = _OMC_LIT2;
                  goto tmp132_done;
                }
                }
                goto tmp132_end;
                tmp132_end: ;
              }
              goto goto_131;
              goto_131:;
              goto goto_2;
              goto tmp132_done;
              tmp132_done:;
            }
          }tmpMeta1 = tmpMeta130;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta141;
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          modelica_metatype tmpMeta144;
          modelica_metatype tmpMeta145;
          modelica_metatype tmpMeta146;
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta141 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta141,1,1) == 0) goto tmp3_end;
          tmpMeta142 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta141), 2));
          if (3 != MMC_STRLEN(tmpMeta142) || strcmp(MMC_STRINGDATA(_OMC_LIT12), MMC_STRINGDATA(tmpMeta142)) != 0) goto tmp3_end;
          tmpMeta143 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta143)) goto tmp3_end;
          tmpMeta144 = MMC_CAR(tmpMeta143);
          tmpMeta145 = MMC_CDR(tmpMeta143);
          if (listEmpty(tmpMeta145)) goto tmp3_end;
          tmpMeta146 = MMC_CAR(tmpMeta145);
          tmpMeta147 = MMC_CDR(tmpMeta145);
          if (!listEmpty(tmpMeta147)) goto tmp3_end;
          
          _e2 = tmpMeta146;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp151_1;
            tmp151_1 = omc_SimCodeUtil_getExpNominal(threadData, _e2);
            {
              volatile mmc_switch_type tmp151;
              int tmp152;
              tmp151 = 0;
              for (; tmp151 < 2; tmp151++) {
                switch (MMC_SWITCH_CAST(tmp151)) {
                case 0: {
                  modelica_metatype tmpMeta153;
                  modelica_real tmp154;
                  modelica_metatype tmpMeta155;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp151_1,1,1) == 0) goto tmp150_end;
                  tmpMeta153 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp151_1), 2));
                  tmp154 = mmc_unbox_real(tmpMeta153);
                  _r2 = tmp154  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta155 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(_r2));
                  tmpMeta148 = tmpMeta155;
                  goto tmp150_done;
                }
                case 1: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta148 = _OMC_LIT2;
                  goto tmp150_done;
                }
                }
                goto tmp150_end;
                tmp150_end: ;
              }
              goto goto_149;
              goto_149:;
              goto goto_2;
              goto tmp150_done;
              tmp150_done:;
            }
          }tmpMeta1 = tmpMeta148;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta156;
          modelica_metatype tmpMeta157;
          modelica_metatype tmpMeta158;
          modelica_metatype tmpMeta159;
          modelica_metatype tmpMeta160;
          modelica_metatype tmpMeta161;
          modelica_metatype tmpMeta162;
          modelica_metatype tmpMeta163;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta156 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta156,1,1) == 0) goto tmp3_end;
          tmpMeta157 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta156), 2));
          if (3 != MMC_STRLEN(tmpMeta157) || strcmp(MMC_STRINGDATA(_OMC_LIT13), MMC_STRINGDATA(tmpMeta157)) != 0) goto tmp3_end;
          tmpMeta158 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta158)) goto tmp3_end;
          tmpMeta159 = MMC_CAR(tmpMeta158);
          tmpMeta160 = MMC_CDR(tmpMeta158);
          if (listEmpty(tmpMeta160)) goto tmp3_end;
          tmpMeta161 = MMC_CAR(tmpMeta160);
          tmpMeta162 = MMC_CDR(tmpMeta160);
          if (!listEmpty(tmpMeta162)) goto tmp3_end;
          
          _e2 = tmpMeta161;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp166_1;
            tmp166_1 = omc_SimCodeUtil_getExpNominal(threadData, _e2);
            {
              volatile mmc_switch_type tmp166;
              int tmp167;
              tmp166 = 0;
              for (; tmp166 < 2; tmp166++) {
                switch (MMC_SWITCH_CAST(tmp166)) {
                case 0: {
                  modelica_metatype tmpMeta168;
                  modelica_real tmp169;
                  modelica_metatype tmpMeta170;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp166_1,1,1) == 0) goto tmp165_end;
                  tmpMeta168 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp166_1), 2));
                  tmp169 = mmc_unbox_real(tmpMeta168);
                  _r2 = tmp169  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta170 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(_r2));
                  tmpMeta163 = tmpMeta170;
                  goto tmp165_done;
                }
                case 1: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta163 = _OMC_LIT2;
                  goto tmp165_done;
                }
                }
                goto tmp165_end;
                tmp165_end: ;
              }
              goto goto_164;
              goto_164:;
              goto goto_2;
              goto tmp165_done;
              tmp165_done:;
            }
          }tmpMeta1 = tmpMeta163;
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta171;
          modelica_metatype tmpMeta172;
          modelica_metatype tmpMeta173;
          modelica_metatype tmpMeta174;
          modelica_metatype tmpMeta175;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta171 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta171,1,1) == 0) goto tmp3_end;
          tmpMeta172 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta171), 2));
          if (4 != MMC_STRLEN(tmpMeta172) || strcmp(MMC_STRINGDATA(_OMC_LIT14), MMC_STRINGDATA(tmpMeta172)) != 0) goto tmp3_end;
          tmpMeta173 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta173)) goto tmp3_end;
          tmpMeta174 = MMC_CAR(tmpMeta173);
          tmpMeta175 = MMC_CDR(tmpMeta173);
          if (!listEmpty(tmpMeta175)) goto tmp3_end;
          
          _e1 = tmpMeta174;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta176;
          modelica_metatype tmpMeta177;
          modelica_metatype tmpMeta178;
          modelica_metatype tmpMeta179;
          modelica_metatype tmpMeta180;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta176 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta176,1,1) == 0) goto tmp3_end;
          tmpMeta177 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta176), 2));
          if (5 != MMC_STRLEN(tmpMeta177) || strcmp(MMC_STRINGDATA(_OMC_LIT15), MMC_STRINGDATA(tmpMeta177)) != 0) goto tmp3_end;
          tmpMeta178 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta178)) goto tmp3_end;
          tmpMeta179 = MMC_CAR(tmpMeta178);
          tmpMeta180 = MMC_CDR(tmpMeta178);
          if (!listEmpty(tmpMeta180)) goto tmp3_end;
          
          _e1 = tmpMeta179;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta181;
          modelica_metatype tmpMeta182;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta181 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta181,1,1) == 0) goto tmp3_end;
          tmpMeta182 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta181), 2));
          if (3 != MMC_STRLEN(tmpMeta182) || strcmp(MMC_STRINGDATA(_OMC_LIT16), MMC_STRINGDATA(tmpMeta182)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 19: {
          modelica_metatype tmpMeta183;
          modelica_metatype tmpMeta184;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta183 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta183,1,1) == 0) goto tmp3_end;
          tmpMeta184 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta183), 2));
          if (3 != MMC_STRLEN(tmpMeta184) || strcmp(MMC_STRINGDATA(_OMC_LIT17), MMC_STRINGDATA(tmpMeta184)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 20: {
          modelica_metatype tmpMeta185;
          modelica_metatype tmpMeta186;
          modelica_metatype tmpMeta187;
          modelica_metatype tmpMeta188;
          modelica_metatype tmpMeta189;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta185 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta185,1,1) == 0) goto tmp3_end;
          tmpMeta186 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta185), 2));
          if (3 != MMC_STRLEN(tmpMeta186) || strcmp(MMC_STRINGDATA(_OMC_LIT18), MMC_STRINGDATA(tmpMeta186)) != 0) goto tmp3_end;
          tmpMeta187 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta187)) goto tmp3_end;
          tmpMeta188 = MMC_CAR(tmpMeta187);
          tmpMeta189 = MMC_CDR(tmpMeta187);
          if (!listEmpty(tmpMeta189)) goto tmp3_end;
          
          _e1 = tmpMeta188;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 21: {
          modelica_metatype tmpMeta190;
          modelica_metatype tmpMeta191;
          modelica_metatype tmpMeta192;
          modelica_metatype tmpMeta193;
          modelica_metatype tmpMeta194;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta190 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta190,1,1) == 0) goto tmp3_end;
          tmpMeta191 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta190), 2));
          if (4 != MMC_STRLEN(tmpMeta191) || strcmp(MMC_STRINGDATA(_OMC_LIT19), MMC_STRINGDATA(tmpMeta191)) != 0) goto tmp3_end;
          tmpMeta192 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta192)) goto tmp3_end;
          tmpMeta193 = MMC_CAR(tmpMeta192);
          tmpMeta194 = MMC_CDR(tmpMeta192);
          if (!listEmpty(tmpMeta194)) goto tmp3_end;
          
          _e1 = tmpMeta193;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _expr = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 22: {
          modelica_metatype tmpMeta195;
          modelica_metatype tmpMeta196;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta195 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta195,1,1) == 0) goto tmp3_end;
          tmpMeta196 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta195), 2));
          if (4 != MMC_STRLEN(tmpMeta196) || strcmp(MMC_STRINGDATA(_OMC_LIT20), MMC_STRINGDATA(tmpMeta196)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 23: {
          modelica_metatype tmpMeta197;
          modelica_metatype tmpMeta198;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta197 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta197,1,1) == 0) goto tmp3_end;
          tmpMeta198 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta197), 2));
          if (4 != MMC_STRLEN(tmpMeta198) || strcmp(MMC_STRINGDATA(_OMC_LIT21), MMC_STRINGDATA(tmpMeta198)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 24: {
          modelica_metatype tmpMeta199;
          modelica_metatype tmpMeta200;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta199 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta199,1,1) == 0) goto tmp3_end;
          tmpMeta200 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta199), 2));
          if (4 != MMC_STRLEN(tmpMeta200) || strcmp(MMC_STRINGDATA(_OMC_LIT21), MMC_STRINGDATA(tmpMeta200)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        case 25: {
          modelica_metatype tmpMeta201;
          modelica_metatype tmpMeta202;
          modelica_metatype tmpMeta203;
          modelica_metatype tmpMeta204;
          modelica_metatype tmpMeta205;
          modelica_metatype tmpMeta206;
          modelica_metatype tmpMeta207;
          modelica_metatype tmpMeta208;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta201 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta201,1,1) == 0) goto tmp3_end;
          tmpMeta202 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta201), 2));
          if (4 != MMC_STRLEN(tmpMeta202) || strcmp(MMC_STRINGDATA(_OMC_LIT4), MMC_STRINGDATA(tmpMeta202)) != 0) goto tmp3_end;
          tmpMeta203 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta203)) goto tmp3_end;
          tmpMeta204 = MMC_CAR(tmpMeta203);
          tmpMeta205 = MMC_CDR(tmpMeta203);
          if (!listEmpty(tmpMeta205)) goto tmp3_end;
          tmpMeta206 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta207 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta206), 2));
          
          _e1 = tmpMeta204;
          _t = tmpMeta207;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp211_1;
            tmp211_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp211;
              int tmp212;
              tmp211 = 0;
              for (; tmp211 < 2; tmp211++) {
                switch (MMC_SWITCH_CAST(tmp211)) {
                case 0: {
                  modelica_metatype tmpMeta213;
                  modelica_real tmp214;
                  modelica_metatype tmpMeta215;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp211_1,1,1) == 0) goto tmp210_end;
                  tmpMeta213 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp211_1), 2));
                  tmp214 = mmc_unbox_real(tmpMeta213);
                  _r1 = tmp214  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta215 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(sinh(_r1)));
                  tmpMeta208 = tmpMeta215;
                  goto tmp210_done;
                }
                case 1: {
                  modelica_metatype tmpMeta216;
                  
                  _e2 = tmp211_1;
                  /* Pattern matching succeeded */
                  tmpMeta216 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta208 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT4, tmpMeta216, _t);
                  goto tmp210_done;
                }
                }
                goto tmp210_end;
                tmp210_end: ;
              }
              goto goto_209;
              goto_209:;
              goto goto_2;
              goto tmp210_done;
              tmp210_done:;
            }
          }tmpMeta1 = tmpMeta208;
          goto tmp3_done;
        }
        case 26: {
          modelica_metatype tmpMeta217;
          modelica_metatype tmpMeta218;
          modelica_metatype tmpMeta219;
          modelica_metatype tmpMeta220;
          modelica_metatype tmpMeta221;
          modelica_metatype tmpMeta222;
          modelica_metatype tmpMeta223;
          modelica_metatype tmpMeta224;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta217 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta217,1,1) == 0) goto tmp3_end;
          tmpMeta218 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta217), 2));
          if (4 != MMC_STRLEN(tmpMeta218) || strcmp(MMC_STRINGDATA(_OMC_LIT5), MMC_STRINGDATA(tmpMeta218)) != 0) goto tmp3_end;
          tmpMeta219 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta219)) goto tmp3_end;
          tmpMeta220 = MMC_CAR(tmpMeta219);
          tmpMeta221 = MMC_CDR(tmpMeta219);
          if (!listEmpty(tmpMeta221)) goto tmp3_end;
          tmpMeta222 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta223 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta222), 2));
          
          _e1 = tmpMeta220;
          _t = tmpMeta223;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp227_1;
            tmp227_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp227;
              int tmp228;
              tmp227 = 0;
              for (; tmp227 < 2; tmp227++) {
                switch (MMC_SWITCH_CAST(tmp227)) {
                case 0: {
                  modelica_metatype tmpMeta229;
                  modelica_real tmp230;
                  modelica_metatype tmpMeta231;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp227_1,1,1) == 0) goto tmp226_end;
                  tmpMeta229 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp227_1), 2));
                  tmp230 = mmc_unbox_real(tmpMeta229);
                  _r1 = tmp230  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta231 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(cosh(_r1)));
                  tmpMeta224 = tmpMeta231;
                  goto tmp226_done;
                }
                case 1: {
                  modelica_metatype tmpMeta232;
                  
                  _e2 = tmp227_1;
                  /* Pattern matching succeeded */
                  tmpMeta232 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta224 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT5, tmpMeta232, _t);
                  goto tmp226_done;
                }
                }
                goto tmp226_end;
                tmp226_end: ;
              }
              goto goto_225;
              goto_225:;
              goto goto_2;
              goto tmp226_done;
              tmp226_done:;
            }
          }tmpMeta1 = tmpMeta224;
          goto tmp3_done;
        }
        case 27: {
          modelica_metatype tmpMeta233;
          modelica_metatype tmpMeta234;
          modelica_metatype tmpMeta235;
          modelica_metatype tmpMeta236;
          modelica_metatype tmpMeta237;
          modelica_metatype tmpMeta238;
          modelica_metatype tmpMeta239;
          modelica_metatype tmpMeta240;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta233 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta233,1,1) == 0) goto tmp3_end;
          tmpMeta234 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta233), 2));
          if (4 != MMC_STRLEN(tmpMeta234) || strcmp(MMC_STRINGDATA(_OMC_LIT6), MMC_STRINGDATA(tmpMeta234)) != 0) goto tmp3_end;
          tmpMeta235 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta235)) goto tmp3_end;
          tmpMeta236 = MMC_CAR(tmpMeta235);
          tmpMeta237 = MMC_CDR(tmpMeta235);
          if (!listEmpty(tmpMeta237)) goto tmp3_end;
          tmpMeta238 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta239 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta238), 2));
          
          _e1 = tmpMeta236;
          _t = tmpMeta239;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp243_1;
            tmp243_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp243;
              int tmp244;
              tmp243 = 0;
              for (; tmp243 < 2; tmp243++) {
                switch (MMC_SWITCH_CAST(tmp243)) {
                case 0: {
                  modelica_metatype tmpMeta245;
                  modelica_real tmp246;
                  modelica_metatype tmpMeta247;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp243_1,1,1) == 0) goto tmp242_end;
                  tmpMeta245 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp243_1), 2));
                  tmp246 = mmc_unbox_real(tmpMeta245);
                  _r1 = tmp246  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta247 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(tanh(_r1)));
                  tmpMeta240 = tmpMeta247;
                  goto tmp242_done;
                }
                case 1: {
                  modelica_metatype tmpMeta248;
                  
                  _e2 = tmp243_1;
                  /* Pattern matching succeeded */
                  tmpMeta248 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta240 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT6, tmpMeta248, _t);
                  goto tmp242_done;
                }
                }
                goto tmp242_end;
                tmp242_end: ;
              }
              goto goto_241;
              goto_241:;
              goto goto_2;
              goto tmp242_done;
              tmp242_done:;
            }
          }tmpMeta1 = tmpMeta240;
          goto tmp3_done;
        }
        case 28: {
          modelica_metatype tmpMeta249;
          modelica_metatype tmpMeta250;
          modelica_metatype tmpMeta251;
          modelica_metatype tmpMeta252;
          modelica_metatype tmpMeta253;
          modelica_metatype tmpMeta254;
          modelica_metatype tmpMeta255;
          modelica_metatype tmpMeta256;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta249 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta249,1,1) == 0) goto tmp3_end;
          tmpMeta250 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta249), 2));
          if (3 != MMC_STRLEN(tmpMeta250) || strcmp(MMC_STRINGDATA(_OMC_LIT7), MMC_STRINGDATA(tmpMeta250)) != 0) goto tmp3_end;
          tmpMeta251 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta251)) goto tmp3_end;
          tmpMeta252 = MMC_CAR(tmpMeta251);
          tmpMeta253 = MMC_CDR(tmpMeta251);
          if (!listEmpty(tmpMeta253)) goto tmp3_end;
          tmpMeta254 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta255 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta254), 2));
          
          _e1 = tmpMeta252;
          _t = tmpMeta255;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp259_1;
            tmp259_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp259;
              int tmp260;
              tmp259 = 0;
              for (; tmp259 < 2; tmp259++) {
                switch (MMC_SWITCH_CAST(tmp259)) {
                case 0: {
                  modelica_metatype tmpMeta261;
                  modelica_real tmp262;
                  modelica_metatype tmpMeta263;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp259_1,1,1) == 0) goto tmp258_end;
                  tmpMeta261 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp259_1), 2));
                  tmp262 = mmc_unbox_real(tmpMeta261);
                  _r1 = tmp262  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmpMeta263 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(exp(_r1)));
                  tmpMeta256 = tmpMeta263;
                  goto tmp258_done;
                }
                case 1: {
                  modelica_metatype tmpMeta264;
                  
                  _e2 = tmp259_1;
                  /* Pattern matching succeeded */
                  tmpMeta264 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta256 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT7, tmpMeta264, _t);
                  goto tmp258_done;
                }
                }
                goto tmp258_end;
                tmp258_end: ;
              }
              goto goto_257;
              goto_257:;
              goto goto_2;
              goto tmp258_done;
              tmp258_done:;
            }
          }tmpMeta1 = tmpMeta256;
          goto tmp3_done;
        }
        case 29: {
          modelica_metatype tmpMeta265;
          modelica_metatype tmpMeta266;
          modelica_metatype tmpMeta267;
          modelica_metatype tmpMeta268;
          modelica_metatype tmpMeta269;
          modelica_metatype tmpMeta270;
          modelica_metatype tmpMeta271;
          modelica_metatype tmpMeta272;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta265 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta265,1,1) == 0) goto tmp3_end;
          tmpMeta266 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta265), 2));
          if (3 != MMC_STRLEN(tmpMeta266) || strcmp(MMC_STRINGDATA(_OMC_LIT8), MMC_STRINGDATA(tmpMeta266)) != 0) goto tmp3_end;
          tmpMeta267 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta267)) goto tmp3_end;
          tmpMeta268 = MMC_CAR(tmpMeta267);
          tmpMeta269 = MMC_CDR(tmpMeta267);
          if (!listEmpty(tmpMeta269)) goto tmp3_end;
          tmpMeta270 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta271 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta270), 2));
          
          _e1 = tmpMeta268;
          _t = tmpMeta271;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp275_1;
            tmp275_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp275;
              int tmp276;
              tmp275 = 0;
              for (; tmp275 < 2; tmp275++) {
                switch (MMC_SWITCH_CAST(tmp275)) {
                case 0: {
                  modelica_metatype tmpMeta277;
                  modelica_real tmp278;
                  modelica_real tmp279;
                  modelica_metatype tmpMeta280;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp275_1,1,1) == 0) goto tmp274_end;
                  tmpMeta277 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp275_1), 2));
                  tmp278 = mmc_unbox_real(tmpMeta277);
                  _r1 = tmp278  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp279 = _r1;
                  if(!(tmp279 > 0.0))
                  {
                    FILE_INFO info = {"",0,0,0,0,0};
                    omc_assert(threadData, info, "Model error: Argument of log(r1) was %g should be > 0", tmp279);
                  }tmpMeta280 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(log(tmp279)));
                  tmpMeta272 = tmpMeta280;
                  goto tmp274_done;
                }
                case 1: {
                  modelica_metatype tmpMeta281;
                  
                  _e2 = tmp275_1;
                  /* Pattern matching succeeded */
                  tmpMeta281 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta272 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT8, tmpMeta281, _t);
                  goto tmp274_done;
                }
                }
                goto tmp274_end;
                tmp274_end: ;
              }
              goto goto_273;
              goto_273:;
              goto goto_2;
              goto tmp274_done;
              tmp274_done:;
            }
          }tmpMeta1 = tmpMeta272;
          goto tmp3_done;
        }
        case 30: {
          modelica_metatype tmpMeta282;
          modelica_metatype tmpMeta283;
          modelica_metatype tmpMeta284;
          modelica_metatype tmpMeta285;
          modelica_metatype tmpMeta286;
          modelica_metatype tmpMeta287;
          modelica_metatype tmpMeta288;
          modelica_metatype tmpMeta289;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta282 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta282,1,1) == 0) goto tmp3_end;
          tmpMeta283 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta282), 2));
          if (5 != MMC_STRLEN(tmpMeta283) || strcmp(MMC_STRINGDATA(_OMC_LIT9), MMC_STRINGDATA(tmpMeta283)) != 0) goto tmp3_end;
          tmpMeta284 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta284)) goto tmp3_end;
          tmpMeta285 = MMC_CAR(tmpMeta284);
          tmpMeta286 = MMC_CDR(tmpMeta284);
          if (!listEmpty(tmpMeta286)) goto tmp3_end;
          tmpMeta287 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta288 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta287), 2));
          
          _e1 = tmpMeta285;
          _t = tmpMeta288;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp292_1;
            tmp292_1 = omc_SimCodeUtil_getExpNominal(threadData, _e1);
            {
              volatile mmc_switch_type tmp292;
              int tmp293;
              tmp292 = 0;
              for (; tmp292 < 2; tmp292++) {
                switch (MMC_SWITCH_CAST(tmp292)) {
                case 0: {
                  modelica_metatype tmpMeta294;
                  modelica_real tmp295;
                  modelica_real tmp296;
                  modelica_metatype tmpMeta297;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp292_1,1,1) == 0) goto tmp291_end;
                  tmpMeta294 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp292_1), 2));
                  tmp295 = mmc_unbox_real(tmpMeta294);
                  _r1 = tmp295  /* pattern as ty=Real */;
                  /* Pattern matching succeeded */
                  tmp296 = _r1;
                  if(!(tmp296 > 0.0))
                  {
                    FILE_INFO info = {"",0,0,0,0,0};
                    omc_assert(threadData, info, "Model error: Argument of log10(r1) was %g should be > 0", tmp296);
                  }tmpMeta297 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(log10(tmp296)));
                  tmpMeta289 = tmpMeta297;
                  goto tmp291_done;
                }
                case 1: {
                  modelica_metatype tmpMeta298;
                  
                  _e2 = tmp292_1;
                  /* Pattern matching succeeded */
                  tmpMeta298 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta289 = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT9, tmpMeta298, _t);
                  goto tmp291_done;
                }
                }
                goto tmp291_end;
                tmp291_end: ;
              }
              goto goto_290;
              goto_290:;
              goto goto_2;
              goto tmp291_done;
              tmp291_done:;
            }
          }tmpMeta1 = tmpMeta289;
          goto tmp3_done;
        }
        case 31: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _nominal = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _nominal;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getCMakeVersion(threadData_t *threadData, modelica_string _pathToCMake)
{
  modelica_metatype _cmakeVersion = NULL;
  modelica_integer _retVal;
  modelica_string _cmakeVersionLogFile = NULL;
  modelica_metatype _regexOut = NULL;
  modelica_integer _numMatches;
  modelica_string _cmakeVersionString = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cmakeVersion has no default value.
  // _retVal has no default value.
  _cmakeVersionLogFile = _OMC_LIT23;
  // _regexOut has no default value.
  // _numMatches has no default value.
  // _cmakeVersionString has no default value.
  tmpMeta1 = stringAppend(_pathToCMake,_OMC_LIT24);
  _retVal = omc_System_systemCallRestrictedEnv(threadData, tmpMeta1, _cmakeVersionLogFile);

  if((((modelica_integer) 0) != _retVal))
  {
    omc_System_removeFile(threadData, _cmakeVersionLogFile);

    tmpMeta2 = stringAppend(_OMC_LIT25,_pathToCMake);
    omc_Error_addInternalError(threadData, tmpMeta2, _OMC_LIT27);

    MMC_THROW_INTERNAL();
  }

  _numMatches = omc_System_regex(threadData, omc_System_trimWhitespace(threadData, omc_System_readFile(threadData, _cmakeVersionLogFile)), _OMC_LIT28, ((modelica_integer) 1), 1 /* true */, 0 /* false */ ,&_regexOut);

  if((_numMatches == ((modelica_integer) 0)))
  {
    omc_System_removeFile(threadData, _cmakeVersionLogFile);

    tmpMeta3 = stringAppend(_OMC_LIT29,_pathToCMake);
    omc_Error_addInternalError(threadData, tmpMeta3, _OMC_LIT30);

    MMC_THROW_INTERNAL();
  }

  _cmakeVersionString = listHead(_regexOut);

  _cmakeVersion = omc_SemanticVersion_parse(threadData, _cmakeVersionString, 0 /* false */);

  omc_System_removeFile(threadData, _cmakeVersionLogFile);
  _return: OMC_LABEL_UNUSED
  return _cmakeVersion;
}

DLLDirection
modelica_string omc_SimCodeUtil_make2CMakeInclude(threadData_t *threadData, modelica_metatype _includes)
{
  modelica_string _cmakecode = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _cmakecode = _OMC_LIT31;
  {
    modelica_metatype _include;
    for (tmpMeta1 = _includes; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _include = MMC_CAR(tmpMeta1);
      tmpMeta2 = stringAppend(_cmakecode,_OMC_LIT32);
      tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT33);
      tmpMeta4 = stringAppend(tmpMeta3,omc_System_trim(threadData, _include, _OMC_LIT34));
      tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT33);
      _cmakecode = tmpMeta5;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _cmakecode;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_cvodeFmiFlagIsSet(threadData_t *threadData, modelica_metatype _fmiSimulationFlags)
{
  modelica_boolean _needsCvode;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _needsCvode = 0 /* false */;
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _fmiSimulationFlags;
    {
      modelica_metatype _nameValueTuples = NULL;
      modelica_string _setting = NULL;
      modelica_string _value = NULL;
      modelica_string _configFile = NULL;
      modelica_string _fileContent = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _nameValueTuples has no default value.
      // _setting has no default value.
      // _value has no default value.
      // _configFile has no default value.
      // _fileContent has no default value.
      tmp3 = 0;
      for (; tmp3 < 3; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (optionNone(tmp3_1)) goto tmp2_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta5,0,1) == 0) goto tmp2_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          _nameValueTuples = tmpMeta6;
          /* Pattern matching succeeded */
          if((!listEmpty(_nameValueTuples)))
          {
            {
              modelica_metatype _tpl;
              for (tmpMeta7 = _nameValueTuples; !listEmpty(tmpMeta7); tmpMeta7=MMC_CDR(tmpMeta7))
              {
                _tpl = MMC_CAR(tmpMeta7);
                /* Pattern-matching assignment */
                tmpMeta8 = _tpl;
                tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
                tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
                _setting = tmpMeta9;
                _value = tmpMeta10;

                if(((stringEqual(_setting, _OMC_LIT35)) && (stringEqual(_value, _OMC_LIT36))))
                {
                  _needsCvode = 1 /* true */;

                  break;
                }
              }
            }
          }
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (optionNone(tmp3_1)) goto tmp2_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,1) == 0) goto tmp2_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          _configFile = tmpMeta13;
          /* Pattern matching succeeded */
          _fileContent = omc_System_readFile(threadData, _configFile);

          if((!(((modelica_integer) -1) == omc_System_stringFind(threadData, _fileContent, _OMC_LIT37))))
          {
            _needsCvode = 1 /* true */;
          }
          goto tmp2_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _needsCvode;
}
modelica_metatype boxptr_SimCodeUtil_cvodeFmiFlagIsSet(threadData_t *threadData, modelica_metatype _fmiSimulationFlags)
{
  modelica_boolean _needsCvode;
  modelica_metatype out_needsCvode;
  _needsCvode = omc_SimCodeUtil_cvodeFmiFlagIsSet(threadData, _fmiSimulationFlags);
  out_needsCvode = mmc_mk_icon(_needsCvode);
  return out_needsCvode;
}

DLLDirection
modelica_string omc_SimCodeUtil_getCmakeSundialsLinkCode(threadData_t *threadData, modelica_metatype _fmiSimulationFlags, modelica_string *out_cvodeDirectory)
{
  modelica_string _needCvode = NULL;
  modelica_string _cvodeDirectory = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _needCvode = _OMC_LIT38;
  _cvodeDirectory = _OMC_LIT39;
  if(omc_SimCodeUtil_cvodeFmiFlagIsSet(threadData, _fmiSimulationFlags))
  {
    _needCvode = _OMC_LIT40;

    tmpMeta1 = stringAppend(_OMC_LIT33,omc_Settings_getInstallationDirectoryPath(threadData));
    tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT41);
    _cvodeDirectory = tmpMeta2;
  }
  _return: OMC_LABEL_UNUSED
  if (out_cvodeDirectory) { *out_cvodeDirectory = _cvodeDirectory; }
  return _needCvode;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol(threadData_t *threadData, modelica_string _istring)
{
  modelica_string _ostring = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_OMC_LIT42,_istring);
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT33);
  _ostring = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _ostring;
}

DLLDirection
modelica_string omc_SimCodeUtil_getCmakeLinkLibrariesCode(threadData_t *threadData, modelica_metatype _libs)
{
  modelica_string _cmakecode = NULL;
  modelica_metatype _locations = NULL;
  modelica_metatype _libraries = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_metatype tmpMeta29;
  modelica_metatype tmpMeta30;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _cmakecode = _OMC_LIT31;
  // _locations has no default value.
  // _libraries has no default value.
  _locations = omc_SimCodeUtil_getDirectoriesForDLLsFromLinkLibs(threadData, _libs ,&_libraries);

  tmpMeta2 = stringAppend(omc_Settings_getInstallationDirectoryPath(threadData),_OMC_LIT43);
  tmpMeta1 = mmc_mk_cons(tmpMeta2, _locations);
  _locations = tmpMeta1;

  tmpMeta4 = stringAppend(omc_Settings_getInstallationDirectoryPath(threadData),_OMC_LIT44);
  tmpMeta3 = mmc_mk_cons(tmpMeta4, _locations);
  _locations = tmpMeta3;

  _locations = omc_List_map(threadData, _locations, boxvar_SimCodeUtil_getCmakeLinkLibrariesCode_addDockerVol);

  tmpMeta5 = stringAppend(_cmakecode,_OMC_LIT45);
  tmpMeta6 = stringAppend(tmpMeta5,stringDelimitList(_locations, _OMC_LIT46));
  tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT47);
  _cmakecode = tmpMeta7;

  tmpMeta8 = stringAppend(_cmakecode,omc_SimCodeUtil_getCmakeCrossPlatformSuffixes(threadData));
  tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT48);
  _cmakecode = tmpMeta9;

  {
    modelica_metatype _lib;
    for (tmpMeta10 = _libraries; !listEmpty(tmpMeta10); tmpMeta10=MMC_CDR(tmpMeta10))
    {
      _lib = MMC_CAR(tmpMeta10);
      tmpMeta11 = stringAppend(_cmakecode,_OMC_LIT49);
      tmpMeta12 = stringAppend(tmpMeta11,_lib);
      tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT48);
      tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT50);
      tmpMeta15 = stringAppend(tmpMeta14,_lib);
      tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT48);
      tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT51);
      tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT52);
      tmpMeta19 = stringAppend(tmpMeta18,_lib);
      tmpMeta20 = stringAppend(tmpMeta19,_OMC_LIT53);
      tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT48);
      tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT54);
      tmpMeta23 = stringAppend(tmpMeta22,_lib);
      tmpMeta24 = stringAppend(tmpMeta23,_OMC_LIT55);
      tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT48);
      tmpMeta26 = stringAppend(tmpMeta25,_OMC_LIT56);
      tmpMeta27 = stringAppend(tmpMeta26,_lib);
      tmpMeta28 = stringAppend(tmpMeta27,_OMC_LIT55);
      tmpMeta29 = stringAppend(tmpMeta28,_OMC_LIT48);
      _cmakecode = tmpMeta29;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _cmakecode;
}

DLLDirection
modelica_string omc_SimCodeUtil_getCmakeCrossPlatformSuffixes(threadData_t *threadData)
{
  modelica_string _cmakeCode = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cmakeCode has no default value.
  _cmakeCode = _OMC_LIT57;
  _return: OMC_LABEL_UNUSED
  return _cmakeCode;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getDirectoriesForDLLsFromLinkLibs(threadData_t *threadData, modelica_metatype _libsAndLinkDirs, modelica_metatype *out_outLibs)
{
  modelica_metatype _outLocations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outLibs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outLocations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outLibs = tmpMeta2;
  {
    modelica_metatype _str;
    for (tmpMeta3 = _libsAndLinkDirs; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _str = MMC_CAR(tmpMeta3);
      if(omc_StringUtil_startsWith(threadData, _str, _OMC_LIT59))
      {
        tmpMeta4 = mmc_mk_cons(omc_System_trim(threadData, _str, _OMC_LIT59), _outLocations);
        _outLocations = tmpMeta4;
      }
      else
      {
        if(omc_StringUtil_startsWith(threadData, _str, _OMC_LIT58))
        {
          tmpMeta5 = mmc_mk_cons(omc_System_trim(threadData, _str, _OMC_LIT58), _outLibs);
          _outLibs = tmpMeta5;
        }
      }
    }
  }

  _outLocations = listReverse(_outLocations);

  _outLibs = listReverse(_outLibs);
  _return: OMC_LABEL_UNUSED
  if (out_outLibs) { *out_outLibs = _outLibs; }
  return _outLocations;
}

DLLDirection
modelica_string omc_SimCodeUtil_generateRunnerBatScript(threadData_t *threadData, modelica_metatype _code)
{
  modelica_string _fileName = NULL;
  modelica_complex _file;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _fileName has no default value.
  _file = omc_File_File_constructor(threadData, omc_File_noReference(threadData));
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _code;
    {
      modelica_string _str = NULL;
      modelica_string _locations = NULL;
      modelica_metatype _locations_lst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _str has no default value.
      // _locations has no default value.
      // _locations_lst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          
          /* Pattern matching succeeded */
          tmpMeta6 = stringAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_code), 37))),_OMC_LIT60);
          _fileName = tmpMeta6;

          omc_File_open(threadData, _file, _fileName, 2);

          _locations_lst = omc_SimCodeUtil_getDirectoriesForDLLsFromLinkLibs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_code), 32)))), 12))), NULL);

          _locations = stringDelimitList(_locations_lst, _OMC_LIT61);

          tmpMeta7 = stringAppend(_locations,_OMC_LIT61);
          tmpMeta8 = stringAppend(tmpMeta7,omc_Settings_getInstallationDirectoryPath(threadData));
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT62);
          _locations = tmpMeta9;

          tmpMeta10 = stringAppend(_OMC_LIT63,_locations);
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT64);
          tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT65);
          tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT66);
          tmpMeta14 = stringAppend(tmpMeta13,(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_code), 37))));
          tmpMeta15 = stringAppend(tmpMeta14,_OMC_LIT67);
          tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT68);
          tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT48);
          tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT69);
          _str = tmpMeta18;

          omc_File_write(threadData, _file, _str);
          tmp1 = _fileName;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT70, _OMC_LIT71);
          tmp1 = _OMC_LIT31;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _fileName = tmp1;
  _return: OMC_LABEL_UNUSED
  omc_File_File_destructor(threadData,_file);
  return _fileName;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_selectNLEqSys(threadData_t *threadData, modelica_metatype _simEqSysIn)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqs has no default value.
  // _e has no default value.
  {
    modelica_metatype __omcQ_24tmpVar1;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype tmpMeta4;
    modelica_metatype __omcQ_24tmpVar0;
    modelica_integer tmp10;
    modelica_metatype _eq_loopVar = 0;
    modelica_boolean tmp11 = 0;
    modelica_metatype _eq;
    _eq_loopVar = _simEqSysIn;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar1 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar1;
    while(1) {
      tmp10 = 1;
      while (!listEmpty(_eq_loopVar)) {
        _eq = MMC_CAR(_eq_loopVar);
        _eq_loopVar = MMC_CDR(_eq_loopVar);
        { /* match expression */
          modelica_metatype tmp14_1;
          tmp14_1 = _eq;
          {
            volatile mmc_switch_type tmp14;
            int tmp15;
            tmp14 = 0;
            for (; tmp14 < 3; tmp14++) {
              switch (MMC_SWITCH_CAST(tmp14)) {
              case 0: {
                if (mmc__uniontype__metarecord__typedef__equal(tmp14_1,13,3) == 0) goto tmp13_end;
                
                /* Pattern matching succeeded */
                tmp11 = 1 /* true */;
                goto tmp13_done;
              }
              case 1: {
                modelica_metatype tmpMeta16;
                if (mmc__uniontype__metarecord__typedef__equal(tmp14_1,14,6) == 0) goto tmp13_end;
                tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp14_1), 3));
                if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,13,3) == 0) goto tmp13_end;
                
                /* Pattern matching succeeded */
                tmp11 = 1 /* true */;
                goto tmp13_done;
              }
              case 2: {
                
                /* Pattern matching succeeded */
                tmp11 = 0 /* false */;
                goto tmp13_done;
              }
              }
              goto tmp13_end;
              tmp13_end: ;
            }
            goto goto_12;
            goto_12:;
            MMC_THROW_INTERNAL();
            goto tmp13_done;
            tmp13_done:;
          }
        }
        if (tmp11) {
          tmp10--;
          break;
        }
      }
      if (tmp10 == 0) {
        { /* match expression */
          modelica_metatype tmp7_1;
          tmp7_1 = _eq;
          {
            volatile mmc_switch_type tmp7;
            int tmp8;
            tmp7 = 0;
            for (; tmp7 < 2; tmp7++) {
              switch (MMC_SWITCH_CAST(tmp7)) {
              case 0: {
                if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,13,3) == 0) goto tmp6_end;
                
                /* Pattern matching succeeded */
                tmpMeta4 = _eq;
                goto tmp6_done;
              }
              case 1: {
                modelica_metatype tmpMeta9;
                if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,14,6) == 0) goto tmp6_end;
                tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
                if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,13,3) == 0) goto tmp6_end;
                
                _e = tmpMeta9;
                /* Pattern matching succeeded */
                tmpMeta4 = _e;
                goto tmp6_done;
              }
              }
              goto tmp6_end;
              tmp6_end: ;
            }
            goto goto_5;
            goto_5:;
            MMC_THROW_INTERNAL();
            goto tmp6_done;
            tmp6_done:;
          }
        }__omcQ_24tmpVar0 = tmpMeta4;
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar0,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp10 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar1;
  }
  _eqs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _eqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_unbalancedEqSystemPartition(threadData_t *threadData, modelica_metatype _inList, modelica_integer _maxLength)
{
  modelica_metatype _partitions = NULL;
  modelica_integer _length;
  modelica_integer _eqLength;
  modelica_metatype _lst = NULL;
  modelica_metatype _cur = NULL;
  modelica_metatype _first = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _partitions has no default value.
  // _length has no default value.
  // _eqLength has no default value.
  // _lst has no default value.
  // _cur has no default value.
  // _first has no default value.
  _lst = _inList;

  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _cur = tmpMeta1;

  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _partitions = tmpMeta2;

  _length = ((modelica_integer) 0);

  while(1)
  {
    if(!(!listEmpty(_lst))) break;
    /* Pattern-matching assignment */
    tmpMeta3 = _lst;
    if (listEmpty(tmpMeta3)) MMC_THROW_INTERNAL();
    tmpMeta4 = MMC_CAR(tmpMeta3);
    tmpMeta5 = MMC_CDR(tmpMeta3);
    _first = tmpMeta4;
    _lst = tmpMeta5;

    _eqLength = omc_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData, _first);

    if(((_length > ((modelica_integer) 0)) && (_length + _eqLength > _maxLength)))
    {
      tmpMeta6 = mmc_mk_cons(_cur, _partitions);
      _partitions = tmpMeta6;

      _length = ((modelica_integer) 0);

      tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
      _cur = tmpMeta7;
    }

    _length = _eqLength + _length;

    tmpMeta8 = mmc_mk_cons(_first, _cur);
    _cur = tmpMeta8;
  }

  if((!listEmpty(_cur)))
  {
    tmpMeta9 = mmc_mk_cons(_cur, _partitions);
    _partitions = tmpMeta9;
  }
  _return: OMC_LABEL_UNUSED
  return _partitions;
}
modelica_metatype boxptr_SimCodeUtil_unbalancedEqSystemPartition(threadData_t *threadData, modelica_metatype _inList, modelica_metatype _maxLength)
{
  modelica_integer tmp1;
  modelica_metatype _partitions = NULL;
  tmp1 = mmc_unbox_integer(_maxLength);
  _partitions = omc_SimCodeUtil_unbalancedEqSystemPartition(threadData, _inList, tmp1);
  /* skip box _partitions; list<list<SimCode.SimEqSystem>> */
  return _partitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEq(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feq, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache)
{
  modelica_metatype _eq = NULL;
  modelica_metatype _cache = NULL;
  modelica_integer _ix;
  modelica_integer _aliasOf;
  modelica_metatype tmpMeta1;
  modelica_boolean tmp2 = 0;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eq = __omcQ_24in_5Feq;
  _cache = __omcQ_24in_5Fcache;
  // _ix has no default value.
  // _aliasOf has no default value.
  _ix = omc_SimCodeUtil_simEqSystemIndex(threadData, _eq);

  if(omc_BaseHashTable_hasKey(threadData, _eq, _cache))
  {
    _aliasOf = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _eq, _cache));

    if((_aliasOf != _ix))
    {
      tmpMeta1 = mmc_mk_box3(21, &SimCode_SimEqSystem_SES__ALIAS__desc, mmc_mk_integer(_ix), omc_BaseHashTable_get(threadData, _eq, _cache));
      _eq = tmpMeta1;
    }

    goto _return;
  }

  { /* match expression */
    modelica_metatype tmp5_1;
    tmp5_1 = _eq;
    {
      volatile mmc_switch_type tmp5;
      int tmp6;
      tmp5 = 0;
      for (; tmp5 < 4; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,5) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmp2 = 1 /* true */;
          goto tmp4_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,5,5) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmp2 = 1 /* true */;
          goto tmp4_done;
        }
        case 2: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,10,3) == 0) goto tmp4_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 3));
          if (listEmpty(tmpMeta7)) goto tmp4_end;
          tmpMeta8 = MMC_CAR(tmpMeta7);
          tmpMeta9 = MMC_CDR(tmpMeta7);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,11,2) == 0) goto tmp4_end;
          if (!listEmpty(tmpMeta9)) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmp2 = 1 /* true */;
          goto tmp4_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp2 = 0 /* false */;
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  if(tmp2)
  {
    tmpMeta10 = mmc_mk_box2(0, _eq, mmc_mk_integer(_ix));
    _cache = omc_BaseHashTable_add(threadData, tmpMeta10, _cache);
  }
  _return: OMC_LABEL_UNUSED
  if (out_cache) { *out_cache = _cache; }
  return _eq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEqs(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype _cache = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqs = __omcQ_24in_5Feqs;
  _cache = __omcQ_24in_5Fcache;
  _eqs = omc_List_mapFold(threadData, _eqs, boxvar_SimCodeUtil_aliasSimEq, _cache ,&_cache);
  _return: OMC_LABEL_UNUSED
  if (out_cache) { *out_cache = _cache; }
  return _eqs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_aliasSimEqSystems(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs, modelica_metatype __omcQ_24in_5Fcache, modelica_metatype *out_cache)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype _cache = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqs = __omcQ_24in_5Feqs;
  _cache = __omcQ_24in_5Fcache;
  _eqs = omc_List_mapFold(threadData, _eqs, boxvar_SimCodeUtil_aliasSimEqs, _cache ,&_cache);
  _return: OMC_LABEL_UNUSED
  if (out_cache) { *out_cache = _cache; }
  return _eqs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_findResources(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fe, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype _unknownUri, modelica_metatype *out_tree)
{
  modelica_metatype _e = NULL;
  modelica_metatype _tree = NULL;
  modelica_string _f = NULL;
  modelica_metatype _e1 = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _e = __omcQ_24in_5Fe;
  _tree = __omcQ_24in_5Ftree;
  // _f has no default value.
  // _e1 has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _e;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (28 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT76), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmpMeta8);
          tmpMeta10 = MMC_CDR(tmpMeta8);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,2,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (!listEmpty(tmpMeta10)) goto tmp3_end;
          
          _f = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_AvlSetString_add(threadData, _tree, _f);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,1) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          if (26 != MMC_STRLEN(tmpMeta13) || strcmp(MMC_STRINGDATA(_OMC_LIT77), MMC_STRINGDATA(tmpMeta13)) != 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta14)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmpMeta14);
          tmpMeta16 = MMC_CDR(tmpMeta14);
          
          _e1 = tmpMeta15;
          /* Pattern matching succeeded */
          tmpMeta17 = mmc_mk_cons(omc_ExpressionBasics_printExpStr(threadData, _e1), MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addMessage(threadData, _OMC_LIT75, tmpMeta17);

          omc_Mutable_update(threadData, _unknownUri, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = _tree;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _tree;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _tree = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_tree) { *out_tree = _tree; }
  return _e;
}

static modelica_metatype closure0_SimCodeUtil_findResources(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_e, modelica_metatype $in_tree, modelica_metatype tmp1)
{
  modelica_metatype unknownUri = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_findResources(thData, $in_e, $in_tree, unknownUri, tmp1);
}static modelica_metatype closure1_Expression_traverseSubexpressions(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_e, modelica_metatype $in_arg, modelica_metatype tmp3)
{
  modelica_fnptr func = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_traverseSubexpressions(thData, $in_e, $in_arg, func, tmp3);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getResources(threadData_t *threadData, modelica_metatype _classes, modelica_metatype _dlow1, modelica_metatype _dlow2)
{
  modelica_metatype _resources = NULL;
  modelica_metatype _tree = NULL;
  modelica_metatype _fns = NULL;
  modelica_metatype _unknownUri = NULL;
  modelica_fnptr _f1;
  modelica_fnptr _f2;
  modelica_string _file = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _resources has no default value.
  // _tree has no default value.
  // _fns has no default value.
  // _unknownUri has no default value.
  // _file has no default value.
  _fns = omc_DAEUtil_getFunctionList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow1), 3)))), 12))), 0 /* false */);

  _tree = _OMC_LIT78;

  _unknownUri = omc_Mutable_create(threadData, mmc_mk_boolean(0 /* false */));

  tmpMeta2 = mmc_mk_box1(0, _unknownUri);
  _f1 = (modelica_fnptr) (modelica_fnptr) mmc_mk_box2(0,closure0_SimCodeUtil_findResources,tmpMeta2);

  tmpMeta4 = mmc_mk_box1(0, ((modelica_fnptr) _f1));
  _f2 = (modelica_fnptr) (modelica_fnptr) mmc_mk_box2(0,closure1_Expression_traverseSubexpressions,tmpMeta4);

  omc_DAEUtil_traverseDAEFunctions(threadData, _fns, ((modelica_fnptr) _f2), _tree ,&_tree);

  _tree = omc_BackendDAEUtil_traverseBackendDAEExpsNoCopyWithUpdate(threadData, _dlow1, ((modelica_fnptr) _f2), _tree);

  _tree = omc_BackendDAEUtil_traverseBackendDAEExpsNoCopyWithUpdate(threadData, _dlow2, ((modelica_fnptr) _f2), _tree);

  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  _resources = omc_AvlSetString_listKeys(threadData, _tree, tmpMeta5);

  if(mmc_unbox_boolean(omc_Mutable_access(threadData, _unknownUri)))
  {
    {
      modelica_metatype _cl;
      for (tmpMeta6 = _classes; !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
      {
        _cl = MMC_CAR(tmpMeta6);
        _file = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cl), 11)))), 2)));

        if((stringEqual(omc_System_basename(threadData, _file), _OMC_LIT79)))
        {
          tmpMeta7 = mmc_mk_cons(omc_System_dirname(threadData, _file), _resources);
          _resources = tmpMeta7;
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _resources;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getValueReferenceMapping2(threadData_t *threadData, modelica_metatype _vars, modelica_integer __omcQ_24in_5Fi, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype *out_tree)
{
  modelica_integer _i;
  modelica_metatype _tree = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _i = __omcQ_24in_5Fi;
  _tree = __omcQ_24in_5Ftree;
  {
    modelica_metatype _v;
    for (tmpMeta1 = _vars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _v = MMC_CAR(tmpMeta1);
      _tree = omc_AvlTreeCRToInt_add(threadData, _tree, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2))), _i, boxvar_AvlTreeCRToInt_addConflictDefault);

      _i = ((modelica_integer) 1) + _i;
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_tree) { *out_tree = _tree; }
  return _i;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getValueReferenceMapping2(threadData_t *threadData, modelica_metatype _vars, modelica_metatype __omcQ_24in_5Fi, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype *out_tree)
{
  modelica_integer tmp1;
  modelica_integer _i;
  modelica_metatype out_i;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5Fi);
  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, _vars, tmp1, __omcQ_24in_5Ftree, out_tree);
  out_i = mmc_mk_icon(_i);
  /* skip box _tree; AvlTreeCRToInt.Tree */
  return out_i;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getValueReferenceMapping(threadData_t *threadData, modelica_metatype _modelInfo)
{
  modelica_metatype _tree = NULL;
  modelica_integer _i;
  modelica_metatype _vars = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _tree has no default value.
  // _i has no default value.
  // _vars has no default value.
  _tree = _OMC_LIT80;

  _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 2))), ((modelica_integer) 0), _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 3))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 4))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 5))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 13))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 10))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 6))), ((modelica_integer) 0), _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 14))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 11))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 7))), ((modelica_integer) 0), _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 15))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 12))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 16))), ((modelica_integer) 0), _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 17))), _i, _tree ,&_tree);

  _i = omc_SimCodeUtil_getValueReferenceMapping2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 18))), _i, _tree ,&_tree);
  _return: OMC_LABEL_UNUSED
  return _tree;
}

DLLDirection
modelica_integer omc_SimCodeUtil_lookupVRForRealOutputDerivative(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _simCode, modelica_string _fmuType)
{
  modelica_integer _vr;
  modelica_metatype _outputRealDerivativeCref = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _vr has no default value.
  // _outputRealDerivativeCref has no default value.
  if((stringEqual(_fmuType, _OMC_LIT83)))
  {
    _outputRealDerivativeCref = omc_ComponentReference_appendStringLastIdent(threadData, _OMC_LIT81, _cr);

    _outputRealDerivativeCref = omc_ComponentReference_prependStringCref(threadData, _OMC_LIT82, _outputRealDerivativeCref);

    _vr = omc_AvlTreeCRToInt_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 41))), _outputRealDerivativeCref);
  }
  else
  {
    _vr = ((modelica_integer) -1);
  }
  _return: OMC_LABEL_UNUSED
  return _vr;
}
modelica_metatype boxptr_SimCodeUtil_lookupVRForRealOutputDerivative(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _simCode, modelica_metatype _fmuType)
{
  modelica_integer _vr;
  modelica_metatype out_vr;
  _vr = omc_SimCodeUtil_lookupVRForRealOutputDerivative(threadData, _cr, _simCode, _fmuType);
  out_vr = mmc_mk_icon(_vr);
  return out_vr;
}

DLLDirection
modelica_integer omc_SimCodeUtil_lookupVR(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _simCode)
{
  modelica_integer _vr;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _vr has no default value.
  _vr = omc_AvlTreeCRToInt_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 41))), _cr);
  _return: OMC_LABEL_UNUSED
  return _vr;
}
modelica_metatype boxptr_SimCodeUtil_lookupVR(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _simCode)
{
  modelica_integer _vr;
  modelica_metatype out_vr;
  _vr = omc_SimCodeUtil_lookupVR(threadData, _cr, _simCode);
  out_vr = mmc_mk_icon(_vr);
  return out_vr;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_crefSimCodeIndexGreaterThan(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _simCode)
{
  modelica_boolean _b;
  modelica_metatype _v1 = NULL;
  modelica_metatype _v2 = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _v1 has no default value.
  // _v2 has no default value.
  _v1 = omc_SimCodeUtil_cref2simvar(threadData, _cr1, _simCode);

  _v2 = omc_SimCodeUtil_cref2simvar(threadData, _cr2, _simCode);

  _b = omc_SimCodeUtil_simvarGraterThan(threadData, _v1, _v2);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_crefSimCodeIndexGreaterThan(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _simCode)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_crefSimCodeIndexGreaterThan(threadData, _cr1, _cr2, _simCode);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData_t *threadData, modelica_metatype _eqn)
{
  modelica_integer _n;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _n has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eqn;
    {
      modelica_metatype _ls = NULL;
      modelica_metatype _nls = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ls has no default value.
      // _nls has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _eqn = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3)));
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _ls = tmpMeta6;
          /* Pattern matching succeeded */
          tmp1 = listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ls), 5))));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _nls = tmpMeta7;
          /* Pattern matching succeeded */
          tmp1 = listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_nls), 4))));
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _n = tmp1;
  _return: OMC_LABEL_UNUSED
  return _n;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData_t *threadData, modelica_metatype _eqn)
{
  modelica_integer _n;
  modelica_metatype out_n;
  _n = omc_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData, _eqn);
  out_n = mmc_mk_icon(_n);
  return out_n;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getNumContinuousEquations(threadData_t *threadData, modelica_metatype _eqns, modelica_integer _numStates)
{
  modelica_integer _n;
  modelica_integer _numEqns;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _n has no default value.
  _numEqns = ((modelica_integer) 0);
  {
    modelica_metatype _eqn;
    for (tmpMeta1 = _eqns; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqn = MMC_CAR(tmpMeta1);
      _numEqns = _numEqns + omc_SimCodeUtil_getNumContinuousEquationsSingleEq(threadData, _eqn);
    }
  }

  _n = _numEqns + _numStates;
  _return: OMC_LABEL_UNUSED
  return _n;
}
modelica_metatype boxptr_SimCodeUtil_getNumContinuousEquations(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _numStates)
{
  modelica_integer tmp1;
  modelica_integer _n;
  modelica_metatype out_n;
  tmp1 = mmc_unbox_integer(_numStates);
  _n = omc_SimCodeUtil_getNumContinuousEquations(threadData, _eqns, tmp1);
  out_n = mmc_mk_icon(_n);
  return out_n;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_simvarGraterThan(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _v2)
{
  modelica_boolean _b;
  modelica_integer _t1;
  modelica_integer _t2;
  modelica_integer _k1;
  modelica_integer _k2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _t1 has no default value.
  // _t2 has no default value.
  // _k1 has no default value.
  // _k2 has no default value.
  _k1 = valueConstructor((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v1), 3))));

  _k2 = valueConstructor((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v2), 3))));

  _t1 = valueConstructor((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v1), 13))));

  _t2 = valueConstructor((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v2), 13))));

  _b = ((_t1 == _t2)?((_k1 == _k2)?(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v1), 7)))) > mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v2), 7))))):(_k1 > _k2)):(_t1 > _t2));
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_simvarGraterThan(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _v2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_simvarGraterThan(threadData, _v1, _v2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_lhsGreaterThan(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2, modelica_metatype _simCode)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _eq1;
    tmp4_2 = _eq2;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_simvarGraterThan(threadData, omc_SimCodeUtil_cref2simvar(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq1), 3))), _simCode), omc_SimCodeUtil_cref2simvar(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq2), 3))), _simCode));
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_lhsGreaterThan(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2, modelica_metatype _simCode)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_lhsGreaterThan(threadData, _eq1, _eq2, _simCode);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

static modelica_metatype closure2_SimCodeUtil_lhsGreaterThan(threadData_t *thData, modelica_metatype closure, modelica_metatype eq1, modelica_metatype eq2)
{
  modelica_metatype simCode = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_lhsGreaterThan(thData, eq1, eq2, simCode);
}
DLLDirection
modelica_metatype omc_SimCodeUtil_sortSimpleAssignmentBasedOnLhs(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqs = __omcQ_24in_5Feqs;
  tmpMeta1 = mmc_mk_box1(0, omc_SimCodeUtil_getSimCode(threadData));
  _eqs = omc_List_sort(threadData, _eqs, (modelica_fnptr) mmc_mk_box2(0,closure2_SimCodeUtil_lhsGreaterThan,tmpMeta1));
  _return: OMC_LABEL_UNUSED
  return _eqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_filterScalarLiteralAssignments(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqs = __omcQ_24in_5Feqs;
  {
    modelica_metatype __omcQ_24tmpVar3;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar2;
    modelica_integer tmp4;
    modelica_metatype _e_loopVar = 0;
    modelica_metatype _e;
    _e_loopVar = _eqs;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar3 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar3;
    while(1) {
      tmp4 = 1;
      while (!listEmpty(_e_loopVar)) {
        _e = MMC_CAR(_e_loopVar);
        _e_loopVar = MMC_CDR(_e_loopVar);
        if ((!omc_SimCodeUtil_isScalarLiteralAssignment(threadData, _e))) {
          tmp4--;
          break;
        }
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar2 = _e;
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar2,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar3;
  }
  _eqs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _eqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_selectScalarLiteralAssignments(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqs)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqs = __omcQ_24in_5Feqs;
  {
    modelica_metatype __omcQ_24tmpVar5;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar4;
    modelica_integer tmp4;
    modelica_metatype _e_loopVar = 0;
    modelica_metatype _e;
    _e_loopVar = _eqs;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar5 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar5;
    while(1) {
      tmp4 = 1;
      while (!listEmpty(_e_loopVar)) {
        _e = MMC_CAR(_e_loopVar);
        _e_loopVar = MMC_CDR(_e_loopVar);
        if (omc_SimCodeUtil_isScalarLiteralAssignment(threadData, _e)) {
          tmp4--;
          break;
        }
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar4 = _e;
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar4,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar5;
  }
  _eqs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _eqs;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_isScalarLiteralAssignment(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_Expression_isSimpleLiteralValue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), 0 /* false */);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_SimCodeUtil_isScalarLiteralAssignment(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_isScalarLiteralAssignment(threadData, _eq);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getClockedPartitions(threadData_t *threadData, modelica_metatype _simcode)
{
  modelica_metatype _clockedPartitions = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _clockedPartitions has no default value.
  _clockedPartitions = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simcode), 11)));
  _return: OMC_LABEL_UNUSED
  return _clockedPartitions;
}

DLLDirection
modelica_integer omc_SimCodeUtil_absoluteClockIdxForBaseClock(threadData_t *threadData, modelica_integer _baseClockIdx, modelica_metatype _allBaseClockPartitions)
{
  modelica_integer _absBaseClockIdx;
  modelica_integer _i;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _absBaseClockIdx has no default value.
  _i = ((modelica_integer) 1);
  _absBaseClockIdx = ((modelica_integer) 1);

  while(1)
  {
    if(!(_i < _baseClockIdx)) break;
    _absBaseClockIdx = _absBaseClockIdx + listLength(omc_SimCodeUtil_getSubPartition(threadData, listGet(_allBaseClockPartitions, _i)));

    _i = ((modelica_integer) 1) + _i;
  }
  _return: OMC_LABEL_UNUSED
  return _absBaseClockIdx;
}
modelica_metatype boxptr_SimCodeUtil_absoluteClockIdxForBaseClock(threadData_t *threadData, modelica_metatype _baseClockIdx, modelica_metatype _allBaseClockPartitions)
{
  modelica_integer tmp1;
  modelica_integer _absBaseClockIdx;
  modelica_metatype out_absBaseClockIdx;
  tmp1 = mmc_unbox_integer(_baseClockIdx);
  _absBaseClockIdx = omc_SimCodeUtil_absoluteClockIdxForBaseClock(threadData, tmp1, _allBaseClockPartitions);
  out_absBaseClockIdx = mmc_mk_icon(_absBaseClockIdx);
  return out_absBaseClockIdx;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_codegenExpSanityCheck(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fe, modelica_metatype _context)
{
  modelica_metatype _e = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _simCode = NULL;
  modelica_integer _index;
  modelica_metatype _crf_lst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _e = __omcQ_24in_5Fe;
  // _vars has no default value.
  // _simCode has no default value.
  // _index has no default value.
  // _crf_lst has no default value.
  if(omc_SimCodeFunctionUtil_inFunctionContext(threadData, _context))
  {
    goto _return;
  }

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _e;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _simCode = omc_SimCodeUtil_getSimCode(threadData);

          _crf_lst = omc_ComponentReference_expandCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2))), 1 /* true */);

          {
            modelica_metatype __omcQ_24tmpVar7;
            modelica_metatype* tmp8;
            modelica_metatype tmpMeta9;
            modelica_metatype __omcQ_24tmpVar6;
            modelica_integer tmp10;
            modelica_metatype _cr_loopVar = 0;
            modelica_metatype _cr;
            _cr_loopVar = _crf_lst;
            tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar7 = tmpMeta9; /* defaultValue */
            tmp8 = &__omcQ_24tmpVar7;
            while(1) {
              tmp10 = 1;
              if (!listEmpty(_cr_loopVar)) {
                _cr = MMC_CAR(_cr_loopVar);
                _cr_loopVar = MMC_CDR(_cr_loopVar);
                tmp10--;
              }
              if (tmp10 == 0) {
                __omcQ_24tmpVar6 = omc_SimCodeUtil_cref2simvar(threadData, _cr, _simCode);
                *tmp8 = mmc_mk_cons(__omcQ_24tmpVar6,0);
                tmp8 = &MMC_CDR(*tmp8);
              } else if (tmp10 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp8 = mmc_mk_nil();
            tmpMeta7 = __omcQ_24tmpVar7;
          }
          _vars = tmpMeta7;

          if((!listEmpty(_vars)))
          {
            /* Pattern-matching assignment */
            tmpMeta11 = _vars;
            if (listEmpty(tmpMeta11)) goto goto_2;
            tmpMeta12 = MMC_CAR(tmpMeta11);
            tmpMeta13 = MMC_CDR(tmpMeta11);
            tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 7));
            tmp15 = mmc_unbox_integer(tmpMeta14);
            _index = tmp15  /* pattern as ty=Integer */;
            _vars = tmpMeta13;

            {
              modelica_metatype _v;
              for (tmpMeta16 = _vars; !listEmpty(tmpMeta16); tmpMeta16=MMC_CDR(tmpMeta16))
              {
                _v = MMC_CAR(tmpMeta16);
                if((mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 7)))) != ((modelica_integer) 1) + _index))
                {
                  _e = omc_Expression_expandCrefs(threadData, _e, 0 /* false */, ((modelica_integer) 0), NULL);

                  break;
                }

                _index = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 7))));
              }
            }
          }
          tmpMeta1 = _e;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _e;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _e = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _e;
}

DLLDirection
modelica_string omc_SimCodeUtil_localCref2Index(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _inCrefToSimVarHT)
{
  modelica_string _outIndex = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outIndex has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inCref;
    tmp4_2 = _inCrefToSimVarHT;
    {
      modelica_metatype _cref = NULL;
      modelica_metatype _crefToSimVarHT = NULL;
      modelica_metatype _sv = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cref has no default value.
      // _crefToSimVarHT has no default value.
      // _sv has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_string tmp6;
          
          _cref = tmp4_1;
          _crefToSimVarHT = tmp4_2;
          /* Pattern matching succeeded */
          _sv = omc_BaseHashTable_get(threadData, _cref, _crefToSimVarHT);
          tmp6 = modelica_integer_to_modelica_string(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 7)))), ((modelica_integer) 0), 1 /* true */);
          tmp1 = tmp6;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT84;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outIndex = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outIndex;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_localCref2SimVar(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _inCrefToSimVarHT)
{
  modelica_metatype _outSimVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimVar has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inCref;
    tmp4_2 = _inCrefToSimVarHT;
    {
      modelica_metatype _cref = NULL;
      modelica_metatype _badcref = NULL;
      modelica_metatype _crefToSimVarHT = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cref has no default value.
      // _badcref has no default value.
      // _crefToSimVarHT has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          
          _cref = tmp4_1;
          _crefToSimVarHT = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BaseHashTable_get(threadData, _cref, _crefToSimVarHT);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          
          /* Pattern matching succeeded */
          tmpMeta6 = stringAppend(_OMC_LIT85,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _inCref));
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          _badcref = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta6, _OMC_LIT86, tmpMeta7);
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _badcref, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) -2)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _OMC_LIT86, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), tmpMeta8, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_badcref), mmc_mk_boolean(0 /* false */));
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outSimVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outSimVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createJacContext(threadData_t *threadData, modelica_string _name, modelica_metatype _jacHT)
{
  modelica_metatype _outContext = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outContext has no default value.
  tmpMeta1 = mmc_mk_box3(6, &SimCodeFunction_Context_JACOBIAN__CONTEXT__desc, _name, _jacHT);
  _outContext = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outContext;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_simVarFromHT(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _crefToSimVarHT)
{
  modelica_metatype _outSimVar = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _badcref = NULL;
  modelica_metatype _sv = NULL;
  modelica_metatype _subs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimVar has no default value.
  // _cref has no default value.
  // _badcref has no default value.
  // _sv has no default value.
  // _subs has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta23;
          /* Pattern matching succeeded */
          if(omc_BaseHashTable_hasKey(threadData, _inCref, _crefToSimVarHT))
          {
            _sv = omc_BaseHashTable_get(threadData, _inCref, _crefToSimVarHT);
          }
          else
          {
            if(omc_Flags_isSet(threadData, _OMC_LIT97))
            {
              _sv = omc_BaseHashTable_get(threadData, omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _inCref), _crefToSimVarHT);

              _subs = omc_ComponentReference_crefLastSubs(threadData, _inCref);

              tmpMeta5 = MMC_TAGPTR(mmc_alloc_words(33));
              memcpy(MMC_UNTAGPTR(tmpMeta5), MMC_UNTAGPTR(_sv), 33*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta5))[2] = omc_ComponentReference_crefSetLastSubs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 2))), _subs);
              _sv = tmpMeta5;
            }
            else
            {
              _sv = omc_BaseHashTable_get(threadData, omc_ComponentReference_crefStripSubs(threadData, _inCref), _crefToSimVarHT);

              _subs = omc_ComponentReferenceBasics_crefSubs(threadData, _inCref);

              tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(33));
              memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_sv), 33*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = omc_ComponentReference_crefApplySubs(threadData, omc_ComponentReference_crefStripSubs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 2)))), _subs);
              _sv = tmpMeta6;
            }

            { /* match expression */
              modelica_metatype tmp11_1;
              tmp11_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 19)));
              {
                modelica_integer _index;
                volatile mmc_switch_type tmp11;
                int tmp12;
                // _index has no default value.
                tmp11 = 0;
                for (; tmp11 < 2; tmp11++) {
                  switch (MMC_SWITCH_CAST(tmp11)) {
                  case 0: {
                    modelica_metatype tmpMeta13;
                    modelica_integer tmp14;
                    if (optionNone(tmp11_1)) goto tmp10_end;
                    tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 1));
                    tmp14 = mmc_unbox_integer(tmpMeta13);
                    _index = tmp14  /* pattern as ty=Integer */;
                    /* Pattern matching succeeded */
                    tmpMeta8 = mmc_mk_some(mmc_mk_integer(((modelica_integer) -1) + _index + omc_SimCodeUtilShared_getScalarElementIndex(threadData, _subs, omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 21))), boxvar_stringInt))));
                    goto tmp10_done;
                  }
                  case 1: {
                    
                    /* Pattern matching succeeded */
                    tmpMeta8 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 19)));
                    goto tmp10_done;
                  }
                  }
                  goto tmp10_end;
                  tmp10_end: ;
                }
                goto goto_9;
                goto_9:;
                goto goto_1;
                goto tmp10_done;
                tmp10_done:;
              }
            }
            tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(33));
            memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_sv), 33*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[19] = tmpMeta8;
            _sv = tmpMeta7;

            { /* match expression */
              modelica_metatype tmp19_1;
              tmp19_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 20)));
              {
                modelica_integer _fmiIndex;
                volatile mmc_switch_type tmp19;
                int tmp20;
                // _fmiIndex has no default value.
                tmp19 = 0;
                for (; tmp19 < 2; tmp19++) {
                  switch (MMC_SWITCH_CAST(tmp19)) {
                  case 0: {
                    modelica_metatype tmpMeta21;
                    modelica_integer tmp22;
                    if (optionNone(tmp19_1)) goto tmp18_end;
                    tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp19_1), 1));
                    tmp22 = mmc_unbox_integer(tmpMeta21);
                    _fmiIndex = tmp22  /* pattern as ty=Integer */;
                    /* Pattern matching succeeded */
                    tmpMeta16 = mmc_mk_some(mmc_mk_integer(((modelica_integer) -1) + _fmiIndex + omc_SimCodeUtilShared_getScalarElementIndex(threadData, _subs, omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 21))), boxvar_stringInt))));
                    goto tmp18_done;
                  }
                  case 1: {
                    
                    /* Pattern matching succeeded */
                    tmpMeta16 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 20)));
                    goto tmp18_done;
                  }
                  }
                  goto tmp18_end;
                  tmp18_end: ;
                }
                goto goto_17;
                goto_17:;
                goto goto_1;
                goto tmp18_done;
                tmp18_done:;
              }
            }
            tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(33));
            memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_sv), 33*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[20] = tmpMeta16;
            _sv = tmpMeta15;
          }

          { /* match expression */
            modelica_metatype tmp26_1;
            tmp26_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sv), 16)));
            {
              int tmp26;
              {
                switch (MMC_SWITCH_CAST(valueConstructor(tmp26_1))) {
                case 3: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta23 = _sv;
                  goto tmp25_done;
                }
                case 4: {
                  modelica_metatype tmpMeta27;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,1,1) == 0) goto tmp25_end;
                  tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
                  _cref = tmpMeta27;
                  /* Pattern matching succeeded */
                  tmpMeta23 = omc_SimCodeUtil_simVarFromHT(threadData, _cref, _crefToSimVarHT);
                  goto tmp25_done;
                }
                case 5: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta23 = _sv;
                  goto tmp25_done;
                }
                }
                goto tmp25_end;
                tmp25_end: ;
              }
              goto goto_24;
              goto_24:;
              goto goto_1;
              goto tmp25_done;
              tmp25_done:;
            }
          }
          _sv = tmpMeta23;
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          /* Pattern matching succeeded */
          tmpMeta28 = stringAppend(_OMC_LIT98,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _inCref));
          tmpMeta29 = MMC_REFSTRUCTLIT(mmc_nil);
          _badcref = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta28, _OMC_LIT86, tmpMeta29);

          tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta31 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _badcref, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) -2)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _OMC_LIT86, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), tmpMeta30, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_badcref), mmc_mk_boolean(0 /* false */));
          _sv = tmpMeta31;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;

  _outSimVar = _sv;
  _return: OMC_LABEL_UNUSED
  return _outSimVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_cref2simvar(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _simCode)
{
  modelica_metatype _outSimVar = NULL;
  modelica_metatype _crefToSimVarHT = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _badcref = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimVar has no default value.
  // _crefToSimVarHT has no default value.
  // _cref has no default value.
  // _badcref has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta5 = _simCode;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 44));
          _crefToSimVarHT = tmpMeta6;

          _cref = (mmc_unbox_boolean((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 53))))?_inCref:omc_ComponentReference_crefStripSubs(threadData, _inCref));

          _outSimVar = omc_SimCodeUtil_simVarFromHT(threadData, _cref, _crefToSimVarHT);
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta7 = stringAppend(_OMC_LIT99,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _inCref));
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _badcref = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta7, _OMC_LIT86, tmpMeta8);

          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _badcref, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) -2)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _OMC_LIT86, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), tmpMeta9, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_badcref), mmc_mk_boolean(0 /* false */));
          _outSimVar = tmpMeta10;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _outSimVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimCode(threadData_t *threadData)
{
  modelica_metatype _code = NULL;
  modelica_metatype _ocode = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _code has no default value.
  // _ocode has no default value.
  _ocode = getGlobalRoot(((modelica_integer) 25));

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _ocode;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _code = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _code;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT100, _OMC_LIT101);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _code = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _code;
}

DLLDirection
modelica_integer omc_SimCodeUtil_nVariablesReal(threadData_t *threadData, modelica_metatype _varInfo)
{
  modelica_integer _n;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _n has no default value.
  _n = (((modelica_integer) 2)) * (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 6))))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 7)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 8)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 29)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 30))));
  _return: OMC_LABEL_UNUSED
  return _n;
}
modelica_metatype boxptr_SimCodeUtil_nVariablesReal(threadData_t *threadData, modelica_metatype _varInfo)
{
  modelica_integer _n;
  modelica_metatype out_n;
  _n = omc_SimCodeUtil_nVariablesReal(threadData, _varInfo);
  out_n = mmc_mk_icon(_n);
  return out_n;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getFunctionIndex(threadData_t *threadData)
{
  modelica_metatype _files = NULL;
  modelica_metatype _delst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _files has no default value.
  // _delst has no default value.
  _delst = getGlobalRoot(((modelica_integer) 2));

  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _files = omc_DoubleEnded_toListAndClear(threadData, _delst, tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return _files;
}

DLLDirection
modelica_string omc_SimCodeUtil_addFunctionIndex(threadData_t *threadData, modelica_string _prefix, modelica_string _suffix)
{
  modelica_string _newName = NULL;
  modelica_metatype _delst = NULL;
  modelica_string tmp1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _newName has no default value.
  // _delst has no default value.
  _delst = getGlobalRoot(((modelica_integer) 2));

  tmp1 = modelica_integer_to_modelica_string(omc_DoubleEnded_length(threadData, _delst), ((modelica_integer) 0), 1 /* true */);
  tmpMeta2 = stringAppend(_prefix,tmp1);
  tmpMeta3 = stringAppend(tmpMeta2,_suffix);
  _newName = tmpMeta3;

  omc_DoubleEnded_push__back(threadData, _delst, _newName);
  _return: OMC_LABEL_UNUSED
  return _newName;
}

DLLDirection
void omc_SimCodeUtil_resetFunctionIndex(threadData_t *threadData)
{
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  setGlobalRoot(((modelica_integer) 2), omc_DoubleEnded_fromList(threadData, tmpMeta1));
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getInputIndex(threadData_t *threadData, modelica_metatype _var)
{
  modelica_integer _inputIndex;
  modelica_metatype _v = NULL;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _inputIndex has no default value.
  // _v has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 26));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          
          _v = tmpMeta7;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(arrayLength(_v) == ((modelica_integer) 1))) goto tmp3_end;
          tmp1 = mmc_unbox_integer(arrayGet(_v, ((modelica_integer) 1)));
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 26));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT102, _OMC_LIT103);
          goto goto_2;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) -1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _inputIndex = tmp1;
  _return: OMC_LABEL_UNUSED
  return _inputIndex;
}
modelica_metatype boxptr_SimCodeUtil_getInputIndex(threadData_t *threadData, modelica_metatype _var)
{
  modelica_integer _inputIndex;
  modelica_metatype out_inputIndex;
  _inputIndex = omc_SimCodeUtil_getInputIndex(threadData, _var);
  out_inputIndex = mmc_mk_icon(_inputIndex);
  return out_inputIndex;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimEqSystemsByIndexLst(threadData_t *threadData, modelica_metatype _idcs, modelica_metatype _allSes)
{
  modelica_metatype _sesOut = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _sesOut has no default value.
  _sesOut = omc_List_map1(threadData, _idcs, boxvar_SimCodeUtil_getSimEqSysForIndex, _allSes);
  _return: OMC_LABEL_UNUSED
  return _sesOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_computeDependencies(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype _cref)
{
  modelica_metatype _deps = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _deps has no default value.
  tmpMeta1 = mmc_mk_cons(_cref, MMC_REFSTRUCTLIT(mmc_nil));
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _deps = listReverse(omc_SimCodeUtil_computeDependenciesHelper(threadData, listReverse(_eqs), tmpMeta1, tmpMeta2));
  _return: OMC_LABEL_UNUSED
  return _deps;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_computeDependenciesHelper(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype _unknowns, modelica_metatype _res)
{
  modelica_metatype _deps = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _deps has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _eqs;
    tmp4_2 = _res;
    {
      modelica_metatype _tail = NULL;
      modelica_metatype _head = NULL;
      modelica_metatype _new_unknowns = NULL;
      modelica_metatype _r = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _linsys_unk = NULL;
      modelica_metatype _nlsys_unk = NULL;
      modelica_metatype _nlsys_eqs = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _beqs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _tail has no default value.
      // _head has no default value.
      // _new_unknowns has no default value.
      // _r has no default value.
      // _cref has no default value.
      // _linsys_unk has no default value.
      // _nlsys_unk has no default value.
      // _nlsys_eqs has no default value.
      // _exp has no default value.
      // _beqs has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _r = tmp4_2;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _r;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,3,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          
          _head = tmpMeta6;
          _cref = tmpMeta8;
          _exp = tmpMeta9;
          _tail = tmpMeta7;
          _r = tmp4_2;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp10 = omc_List_isMemberOnTrue(threadData, _cref, _unknowns, boxvar_ComponentReferenceBasics_crefEqual);
          if (1 /* true */ != tmp10) goto goto_2;

          _new_unknowns = omc_Expression_getAllCrefs(threadData, _exp);
          tmpMeta11 = mmc_mk_cons(_head, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_SimCodeUtil_computeDependenciesHelper(threadData, _tail, listAppend(_unknowns, _new_unknowns), listAppend(_r, tmpMeta11));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_boolean tmp16;
          modelica_metatype tmpMeta17;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,4,6) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 4));
          
          _head = tmpMeta12;
          _cref = tmpMeta14;
          _exp = tmpMeta15;
          _tail = tmpMeta13;
          _r = tmp4_2;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp16 = omc_List_isMemberOnTrue(threadData, _cref, _unknowns, boxvar_ComponentReferenceBasics_crefEqual);
          if (1 /* true */ != tmp16) goto goto_2;

          _new_unknowns = omc_Expression_getAllCrefs(threadData, _exp);
          tmpMeta17 = mmc_mk_cons(_head, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_SimCodeUtil_computeDependenciesHelper(threadData, _tail, listAppend(_unknowns, _new_unknowns), listAppend(_r, tmpMeta17));
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_boolean tmp22;
          modelica_metatype tmpMeta23;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta18 = MMC_CAR(tmp4_1);
          tmpMeta19 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,12,3) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 6));
          
          _head = tmpMeta18;
          _beqs = tmpMeta21;
          _tail = tmpMeta19;
          _r = tmp4_2;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _linsys_unk = omc_SimCodeUtil_getSimEqSystemCrefsLHS(threadData, _head);

          /* Pattern-matching assignment */
          tmp22 = listEmpty(omc_List_intersectionOnTrue(threadData, _linsys_unk, _unknowns, boxvar_ComponentReferenceBasics_crefEqual));
          if (0 /* false */ != tmp22) goto goto_2;

          _new_unknowns = omc_List_flatten(threadData, omc_List_map(threadData, _beqs, boxvar_Expression_getAllCrefs));
          tmpMeta23 = mmc_mk_cons(_head, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_SimCodeUtil_computeDependenciesHelper(threadData, _tail, listAppend(_unknowns, _new_unknowns), listAppend(_r, tmpMeta23));
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_boolean tmp29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta24 = MMC_CAR(tmp4_1);
          tmpMeta25 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,13,3) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 3));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 4));
          
          _head = tmpMeta24;
          _nlsys_eqs = tmpMeta27;
          _nlsys_unk = tmpMeta28;
          _tail = tmpMeta25;
          _r = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp29 = listEmpty(omc_List_intersectionOnTrue(threadData, _nlsys_unk, _unknowns, boxvar_ComponentReferenceBasics_crefEqual));
          if (0 /* false */ != tmp29) goto goto_2;

          tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
          _new_unknowns = omc_SimCodeUtil_getNLSysRHS(threadData, _nlsys_eqs, tmpMeta30);
          tmpMeta31 = mmc_mk_cons(_head, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_SimCodeUtil_computeDependenciesHelper(threadData, _tail, listAppend(_unknowns, _new_unknowns), listAppend(_r, tmpMeta31));
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta32 = MMC_CAR(tmp4_1);
          tmpMeta33 = MMC_CDR(tmp4_1);
          
          _tail = tmpMeta33;
          _r = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_computeDependenciesHelper(threadData, _tail, _unknowns, _r);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 6) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _deps = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _deps;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getNLSysRHS(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype _res)
{
  modelica_metatype _unknowns = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _unknowns has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _eqs;
    {
      modelica_metatype _tail = NULL;
      modelica_metatype _exp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _tail has no default value.
      // _exp has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _res;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          
          _exp = tmpMeta8;
          _tail = tmpMeta7;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = omc_SimCodeUtil_getNLSysRHS(threadData, _tail, listAppend(_res, omc_Expression_getAllCrefs(threadData, _exp)));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,6) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 5));
          
          _exp = tmpMeta11;
          _tail = tmpMeta10;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = omc_SimCodeUtil_getNLSysRHS(threadData, _tail, listAppend(_res, omc_Expression_getAllCrefs(threadData, _exp)));
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,2,7) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 6));
          
          _exp = tmpMeta14;
          _tail = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getNLSysRHS(threadData, _tail, listAppend(_res, omc_Expression_getAllCrefs(threadData, _exp)));
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT104),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _unknowns = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _unknowns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSimVarsForSensitivities(threadData_t *threadData, modelica_metatype _inStateSimVars, modelica_metatype _inParamSimVars, modelica_integer _nFixedParameters, modelica_integer *out_countSensitivityParams)
{
  modelica_metatype _outSimCodeVars = NULL;
  modelica_integer _countSensitivityParams;
  modelica_boolean _debug;
  modelica_metatype _tmpVariables = NULL;
  modelica_metatype _emptyVars = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _sensitivityParams = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimCodeVars has no default value.
  _countSensitivityParams = ((modelica_integer) 0);
  _debug = 0 /* false */;
  // _tmpVariables has no default value.
  // _emptyVars has no default value.
  // _var has no default value.
  // _cref has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _sensitivityParams = tmpMeta1;
  _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

  _tmpVariables = omc_BackendVariable_emptyVarsSized(threadData, (listLength(_inStateSimVars)) * (_nFixedParameters));

  {
    modelica_metatype _param;
    for (tmpMeta2 = _inParamSimVars; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _param = MMC_CAR(tmpMeta2);
      if((mmc_unbox_boolean((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_param), 22)))) && omc_ComponentReference_crefIsIdent(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_param), 2))))))
      {
        _countSensitivityParams = ((modelica_integer) 1) + _countSensitivityParams;

        tmpMeta3 = mmc_mk_cons(_param, _sensitivityParams);
        _sensitivityParams = tmpMeta3;

        {
          modelica_metatype _state;
          for (tmpMeta4 = _inStateSimVars; !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
          {
            _state = MMC_CAR(tmpMeta4);
            tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
            _cref = omc_ComponentReferenceBasics_makeCrefIdent(threadData, _OMC_LIT105, _OMC_LIT86, tmpMeta5);

            _cref = omc_ComponentReference_joinCrefs(threadData, _cref, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_param), 2))));

            _cref = omc_ComponentReference_joinCrefs(threadData, _cref, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_state), 2))));

            _var = omc_BackendVariable_makeVar(threadData, _cref);

            _tmpVariables = omc_BackendVariable_addNewVar(threadData, _var, _tmpVariables);
          }
        }
      }
    }
  }

  /* Pattern-matching assignment */
  tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta9 = mmc_mk_box2(0, tmpMeta8, _emptyVars);
  tmpMeta10 = omc_BackendVariable_traverseBackendDAEVars(threadData, _tmpVariables, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta9);
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
  _outSimCodeVars = tmpMeta11;

  _outSimCodeVars = listReverse(_outSimCodeVars);

  _outSimCodeVars = listAppend(listReverse(_sensitivityParams), _outSimCodeVars);
  _return: OMC_LABEL_UNUSED
  if (out_countSensitivityParams) { *out_countSensitivityParams = _countSensitivityParams; }
  return _outSimCodeVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSimVarsForSensitivities(threadData_t *threadData, modelica_metatype _inStateSimVars, modelica_metatype _inParamSimVars, modelica_metatype _nFixedParameters, modelica_metatype *out_countSensitivityParams)
{
  modelica_integer tmp1;
  modelica_integer _countSensitivityParams;
  modelica_metatype _outSimCodeVars = NULL;
  tmp1 = mmc_unbox_integer(_nFixedParameters);
  _outSimCodeVars = omc_SimCodeUtil_createSimVarsForSensitivities(threadData, _inStateSimVars, _inParamSimVars, tmp1, &_countSensitivityParams);
  /* skip box _outSimCodeVars; list<SimCodeVar.SimVar> */
  if (out_countSensitivityParams) { *out_countSensitivityParams = mmc_mk_icon(_countSensitivityParams); }
  return _outSimCodeVars;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_hasLargeEquationSystems1(threadData_t *threadData, modelica_metatype _iComps)
{
  modelica_boolean _oHasLargeEquationSystems;
  modelica_boolean _hasLargeEqSystem;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oHasLargeEquationSystems has no default value.
  _hasLargeEqSystem = 0 /* false */;
  // _vars has no default value.
  {
    modelica_metatype _comp;
    for (tmpMeta1 = _iComps; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _comp = MMC_CAR(tmpMeta1);
      if((!_hasLargeEqSystem))
      {
        if((omc_BackendDAEUtil_isLinearEqSystemComp(threadData, _comp) || omc_BackendDAEUtil_isNonLinearEqSystemComp(threadData, _comp)))
        {
          /* Pattern-matching assignment */
          tmpMeta2 = _comp;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta2,1,5) == 0) MMC_THROW_INTERNAL();
          tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
          _vars = tmpMeta3;

          _hasLargeEqSystem = (listLength(_vars) > ((modelica_integer) 10));
        }
        else
        {
          if((omc_BackendDAEUtil_isLinearTornSystemComp(threadData, _comp) || omc_BackendDAEUtil_isNonLinearTornSystemComp(threadData, _comp)))
          {
            /* Pattern-matching assignment */
            tmpMeta4 = _comp;
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta4,7,4) == 0) MMC_THROW_INTERNAL();
            tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
            tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
            _vars = tmpMeta6;

            _hasLargeEqSystem = (listLength(_vars) > ((modelica_integer) 10));
          }
        }
      }
    }
  }

  _oHasLargeEquationSystems = _hasLargeEqSystem;
  _return: OMC_LABEL_UNUSED
  return _oHasLargeEquationSystems;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_hasLargeEquationSystems1(threadData_t *threadData, modelica_metatype _iComps)
{
  modelica_boolean _oHasLargeEquationSystems;
  modelica_metatype out_oHasLargeEquationSystems;
  _oHasLargeEquationSystems = omc_SimCodeUtil_hasLargeEquationSystems1(threadData, _iComps);
  out_oHasLargeEquationSystems = mmc_mk_icon(_oHasLargeEquationSystems);
  return out_oHasLargeEquationSystems;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_hasLargeEquationSystems(threadData_t *threadData, modelica_metatype _iDlow, modelica_metatype _iInitDAE)
{
  modelica_boolean _oHasLargeEqSystem;
  modelica_boolean _hasLargeEqSystem;
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oHasLargeEqSystem has no default value.
  _hasLargeEqSystem = 0 /* false */;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = tmpMeta1;
  /* Pattern-matching assignment */
  tmpMeta2 = _iDlow;
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  _eqs = tmpMeta3;

  {
    modelica_metatype _eqsys;
    for (tmpMeta4 = _eqs; !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
    {
      _eqsys = MMC_CAR(tmpMeta4);
      if((!_hasLargeEqSystem))
      {
        _hasLargeEqSystem = omc_SimCodeUtil_hasLargeEquationSystems1(threadData, omc_BackendDAEUtil_getStrongComponents(threadData, _eqsys));
      }
    }
  }

  if((!_hasLargeEqSystem))
  {
    /* Pattern-matching assignment */
    tmpMeta6 = _iInitDAE;
    tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
    _eqs = tmpMeta7;

    {
      modelica_metatype _eqsys;
      for (tmpMeta8 = _eqs; !listEmpty(tmpMeta8); tmpMeta8=MMC_CDR(tmpMeta8))
      {
        _eqsys = MMC_CAR(tmpMeta8);
        if((!_hasLargeEqSystem))
        {
          _hasLargeEqSystem = omc_SimCodeUtil_hasLargeEquationSystems1(threadData, omc_BackendDAEUtil_getStrongComponents(threadData, _eqsys));
        }
      }
    }
  }

  if(omc_Flags_isSet(threadData, _OMC_LIT110))
  {
    if((!_hasLargeEqSystem))
    {
      fputs(MMC_STRINGDATA(_OMC_LIT107),stdout);
    }
    else
    {
      fputs(MMC_STRINGDATA(_OMC_LIT106),stdout);
    }
  }

  _oHasLargeEqSystem = _hasLargeEqSystem;
  _return: OMC_LABEL_UNUSED
  return _oHasLargeEqSystem;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_hasLargeEquationSystems(threadData_t *threadData, modelica_metatype _iDlow, modelica_metatype _iInitDAE)
{
  modelica_boolean _oHasLargeEqSystem;
  modelica_metatype out_oHasLargeEqSystem;
  _oHasLargeEqSystem = omc_SimCodeUtil_hasLargeEquationSystems(threadData, _iDlow, _iInitDAE);
  out_oHasLargeEqSystem = mmc_mk_icon(_oHasLargeEqSystem);
  return out_oHasLargeEqSystem;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getHighestDerivationVisit(threadData_t *threadData, modelica_integer _i, modelica_metatype _ders, modelica_metatype _depth)
{
  modelica_integer _d;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _d = mmc_unbox_integer(arrayGet(_depth, _i));
  if((_d >= ((modelica_integer) 0)))
  {
    goto _return;
  }
  else
  {
    if((_d == ((modelica_integer) -2)))
    {
      _d = ((modelica_integer) 0);

      goto _return;
    }
  }

  arrayUpdate(_depth, _i, mmc_mk_integer(((modelica_integer) -2)));

  _d = omc_SimCodeUtil_getHighestDerivationVisit(threadData, mmc_unbox_integer(arrayGet(_ders, _i)), _ders, _depth);

  arrayUpdate(_depth, _i, mmc_mk_integer(_d));
  _return: OMC_LABEL_UNUSED
  return _d;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getHighestDerivationVisit(threadData_t *threadData, modelica_metatype _i, modelica_metatype _ders, modelica_metatype _depth)
{
  modelica_integer tmp1;
  modelica_integer _d;
  modelica_metatype out_d;
  tmp1 = mmc_unbox_integer(_i);
  _d = omc_SimCodeUtil_getHighestDerivationVisit(threadData, tmp1, _ders, _depth);
  out_d = mmc_mk_icon(_d);
  return out_d;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getHighestDerivation(threadData_t *threadData, modelica_metatype _inDAE)
{
  jmp_buf *old_mmc_jumper = threadData->mmc_jumper;
  modelica_integer _highestDerivation;
  modelica_metatype _vars = NULL;
  modelica_metatype _states = NULL;
  modelica_metatype _ders = NULL;
  modelica_metatype _depth = NULL;
  modelica_metatype _allStates = NULL;
  modelica_metatype _var = NULL;
  modelica_integer _index;
  modelica_integer _pos;
  modelica_integer _length;
  modelica_integer _curIndex;
  modelica_metatype _derCref = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta11;
  modelica_integer tmp12;
  modelica_integer tmp13;
  modelica_integer tmp14;
  modelica_integer tmp15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _highestDerivation has no default value.
  // _vars has no default value.
  // _states has no default value.
  // _ders has no default value.
  // _depth has no default value.
  // _allStates has no default value.
  // _var has no default value.
  // _index has no default value.
  // _pos has no default value.
  // _length has no default value.
  // _curIndex has no default value.
  // _derCref has no default value.
  _vars = omc_BackendDAEUtil_getAllVarLst(threadData, _inDAE);

  _states = omc_List_filterOnTrue(threadData, _vars, boxvar_BackendVariable_isStateVar);

  _length = listLength(_states);

  if((_length == ((modelica_integer) 0)))
  {
    _highestDerivation = ((modelica_integer) 0);

    goto _return;
  }

  _ders = arrayCreate(_length, mmc_mk_integer(((modelica_integer) -1)));

  _depth = arrayCreate(_length, mmc_mk_integer(((modelica_integer) -1)));

  _allStates = omc_BackendVariable_listVar1(threadData, _states);

  _curIndex = ((modelica_integer) 1);

  {
    modelica_metatype _state;
    for (tmpMeta1 = _states; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _state = MMC_CAR(tmpMeta1);
      { /* matchcontinue expression */
        volatile modelica_metatype tmp4_1;
        tmp4_1 = _state;
        {
          volatile mmc_switch_type tmp4;
          int tmp5;
          tmp4 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp3_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp4 < 2; tmp4++) {
            switch (MMC_SWITCH_CAST(tmp4)) {
            case 0: {
              modelica_metatype tmpMeta6;
              modelica_metatype tmpMeta7;
              modelica_integer tmp8;
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
              tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
              tmp8 = mmc_unbox_integer(tmpMeta7);
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
              if (optionNone(tmpMeta9)) goto tmp3_end;
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
              
              _index = tmp8  /* pattern as ty=Integer */;
              _derCref = tmpMeta10;
              /* Pattern matching succeeded */
              _var = omc_BackendVariable_getVarSingle(threadData, _derCref, _allStates ,&_pos);

              if((!omc_BackendVariable_varEqual(threadData, _state, _var)))
              {
                arrayUpdate(_ders, _curIndex, mmc_mk_integer(_pos));
              }
              else
              {
                arrayUpdate(_depth, _curIndex, mmc_mk_integer(((modelica_integer) 0)));
              }
              goto tmp3_done;
            }
            case 1: {
              
              /* Pattern matching succeeded */
              arrayUpdate(_depth, _curIndex, mmc_mk_integer(((modelica_integer) 0)));
              goto tmp3_done;
            }
            }
            goto tmp3_end;
            tmp3_end: ;
          }
          goto goto_2;
          tmp3_done:
          (void)tmp4;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp3_done2;
          goto_2:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp4 < 2) {
            goto tmp3_top;
          }
          MMC_THROW_INTERNAL();
          tmp3_done2:;
        }
      }
      ;

      _curIndex = ((modelica_integer) 1) + _curIndex;
    }
  }

  tmp12 = ((modelica_integer) 1); tmp13 = 1; tmp14 = _length;
  if(!(((tmp13 > 0) && (tmp12 > tmp14)) || ((tmp13 < 0) && (tmp12 < tmp14))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp12, tmp14); _i += tmp13)
    {
      omc_SimCodeUtil_getHighestDerivationVisit(threadData, _i, _ders, _depth);
    }
  }

  {
    modelica_integer __omcQ_24tmpVar9;
    modelica_integer __omcQ_24tmpVar8;
    modelica_integer tmp16;
    modelica_metatype _i_loopVar = 0;
    modelica_integer tmp17;
    modelica_metatype _i;
    _i_loopVar = _depth;
    tmp17 = 1;
    __omcQ_24tmpVar9 = ((modelica_integer) -4611686018427387903); /* defaultValue */
    while(1) {
      tmp16 = 1;
      if (tmp17 <= arrayLength(_i_loopVar)) {
        _i = arrayGet(_i_loopVar, tmp17++);
        tmp16--;
      }
      if (tmp16 == 0) {
        __omcQ_24tmpVar8 = mmc_unbox_integer(_i);
        __omcQ_24tmpVar9 = modelica_integer_max((modelica_integer)(__omcQ_24tmpVar8),(modelica_integer)(__omcQ_24tmpVar9));
      } else if (tmp16 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    tmp15 = __omcQ_24tmpVar9;
  }
  _highestDerivation = tmp15;

  omc_GCExt_free(threadData, _ders);

  omc_GCExt_free(threadData, _depth);
  _return: OMC_LABEL_UNUSED
  threadData->mmc_jumper = old_mmc_jumper;
  return _highestDerivation;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getHighestDerivation(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_integer _highestDerivation;
  modelica_metatype out_highestDerivation;
  _highestDerivation = omc_SimCodeUtil_getHighestDerivation(threadData, _inDAE);
  out_highestDerivation = mmc_mk_icon(_highestDerivation);
  return out_highestDerivation;
}

DLLDirection
modelica_string omc_SimCodeUtil_getLocalValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inSimCode, modelica_metatype _inCrefToSimVarHT, modelica_boolean _inElimNegAliases)
{
  modelica_string _outValueReference = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outValueReference has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inSimVar;
    tmp4_2 = _inCrefToSimVarHT;
    {
      modelica_metatype _cref = NULL;
      modelica_string _valueReference = NULL;
      modelica_metatype _crefToSimVarHT = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cref has no default value.
      // _valueReference has no default value.
      // _crefToSimVarHT has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cref = tmpMeta6;
          _crefToSimVarHT = tmp4_2;
          /* Pattern matching succeeded */
          _valueReference = omc_SimCodeUtil_localCref2Index(threadData, _cref, _crefToSimVarHT);

          if((stringEqual(_valueReference, _OMC_LIT84)))
          {
            _valueReference = omc_SimCodeUtil_getValueReference(threadData, _inSimVar, _inSimCode, _inElimNegAliases);
          }
          tmp1 = _valueReference;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT111, _OMC_LIT112);
          tmp1 = _OMC_LIT113;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outValueReference = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outValueReference;
}
modelica_metatype boxptr_SimCodeUtil_getLocalValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inSimCode, modelica_metatype _inCrefToSimVarHT, modelica_metatype _inElimNegAliases)
{
  modelica_integer tmp1;
  modelica_string _outValueReference = NULL;
  tmp1 = mmc_unbox_integer(_inElimNegAliases);
  _outValueReference = omc_SimCodeUtil_getLocalValueReference(threadData, _inSimVar, _inSimCode, _inCrefToSimVarHT, tmp1);
  /* skip box _outValueReference; String */
  return _outValueReference;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_getDefaultValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inVarInfo)
{
  modelica_string _outDefaultValueReference = NULL;
  modelica_integer _reference;
  modelica_integer _numReal;
  modelica_integer _numInteger;
  modelica_integer _numBoolean;
  modelica_string tmp1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDefaultValueReference has no default value.
  // _reference has no default value.
  _numReal = (((modelica_integer) 2)) * (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 6))))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 7)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 8)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 14)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 11))));
  _numInteger = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 9)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 15)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 12))));
  _numBoolean = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 10)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 16)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVarInfo), 13))));
  _reference = omc_SimCodeUtil_getVariableIndex(threadData, _inSimVar);

  if((_reference > _numReal + _numInteger + _numBoolean))
  {
    _reference = _reference + (-_numInteger) - _numBoolean - _numReal;
  }
  else
  {
    if((_reference > _numReal + _numInteger))
    {
      _reference = _reference + (-_numReal) - _numInteger;
    }
    else
    {
      if((_reference > _numReal))
      {
        _reference = _reference - _numReal;
      }
      else
      {
        if((_reference < ((modelica_integer) 0)))
        {
          omc_Error_addInternalError(threadData, _OMC_LIT114, _OMC_LIT115);
        }
      }
    }
  }

  tmp1 = modelica_integer_to_modelica_string(((modelica_integer) -1) + _reference, ((modelica_integer) 0), 1 /* true */);
  _outDefaultValueReference = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outDefaultValueReference;
}

DLLDirection
modelica_string omc_SimCodeUtil_getValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inSimCode, modelica_boolean _inElimNegAliases)
{
  modelica_string _outValueReference = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outValueReference has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_boolean tmp4_2;modelica_string tmp4_3;
    tmp4_1 = _inSimVar;
    tmp4_2 = _inElimNegAliases;
    tmp4_3 = omc_Config_simCodeTarget(threadData);
    {
      modelica_metatype _simVar = NULL;
      modelica_metatype _cref = NULL;
      modelica_string _valueReference = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _simVar has no default value.
      // _cref has no default value.
      // _valueReference has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 16));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,2,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_getDefaultValueReference(threadData, _inSimVar, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimCode), 2)))), 10))));
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta19;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)) || (stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT120)))) goto tmp3_end;
          { /* match expression */
            modelica_metatype tmp10_1;
            tmp10_1 = _inSimVar;
            {
              modelica_metatype _componentRef = NULL;
              volatile mmc_switch_type tmp10;
              int tmp11;
              // _componentRef has no default value.
              tmp10 = 0;
              for (; tmp10 < 4; tmp10++) {
                switch (MMC_SWITCH_CAST(tmp10)) {
                case 0: {
                  modelica_metatype tmpMeta12;
                  modelica_metatype tmpMeta13;
                  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp10_1), 16));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,1) == 0) goto tmp9_end;
                  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
                  
                  _cref = tmpMeta13;
                  /* Pattern matching succeeded */
                  tmpMeta7 = omc_SimCodeUtil_cref2simvar(threadData, _cref, _inSimCode);
                  goto tmp9_done;
                }
                case 1: {
                  modelica_metatype tmpMeta14;
                  modelica_metatype tmpMeta15;
                  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp10_1), 16));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,2,1) == 0) goto tmp9_end;
                  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
                  
                  _cref = tmpMeta15;
                  /* Pattern matching succeeded */
                  tmpMeta7 = omc_SimCodeUtil_cref2simvar(threadData, _cref, _inSimCode);
                  goto tmp9_done;
                }
                case 2: {
                  modelica_metatype tmpMeta16;
                  modelica_metatype tmpMeta17;
                  modelica_metatype tmpMeta18;
                  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp10_1), 2));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,0,4) == 0) goto tmp9_end;
                  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
                  if (4 != MMC_STRLEN(tmpMeta17) || strcmp(MMC_STRINGDATA(_OMC_LIT116), MMC_STRINGDATA(tmpMeta17)) != 0) goto tmp9_end;
                  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 5));
                  
                  _componentRef = tmpMeta18;
                  /* Pattern matching succeeded */
                  tmpMeta7 = omc_SimCodeUtil_cref2simvar(threadData, _componentRef, _inSimCode);
                  goto tmp9_done;
                }
                case 3: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta7 = _inSimVar;
                  goto tmp9_done;
                }
                }
                goto tmp9_end;
                tmp9_end: ;
              }
              goto goto_8;
              goto_8:;
              goto goto_2;
              goto tmp9_done;
              tmp9_done:;
            }
          }
          _simVar = tmpMeta7;

          _valueReference = omc_SimCodeUtil_getVarIndexByMapping(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimCode), 42))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 2))), 1 /* true */, _OMC_LIT84);

          if((stringEqual(_valueReference, _OMC_LIT84)))
          {
            tmpMeta19 = stringAppend(_OMC_LIT117,omc_SimCodeUtil_simVarString(threadData, _simVar));
            omc_Error_addInternalError(threadData, tmpMeta19, _OMC_LIT118);
          }
          tmp1 = _valueReference;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 16));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,1,1) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          
          _cref = tmpMeta21;
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_getDefaultValueReference(threadData, omc_SimCodeUtil_cref2simvar(threadData, _cref, _inSimCode), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimCode), 2)))), 10))));
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_getDefaultValueReference(threadData, _inSimVar, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimCode), 2)))), 10))));
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outValueReference = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outValueReference;
}
modelica_metatype boxptr_SimCodeUtil_getValueReference(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _inSimCode, modelica_metatype _inElimNegAliases)
{
  modelica_integer tmp1;
  modelica_string _outValueReference = NULL;
  tmp1 = mmc_unbox_integer(_inElimNegAliases);
  _outValueReference = omc_SimCodeUtil_getValueReference(threadData, _inSimVar, _inSimCode, tmp1);
  /* skip box _outValueReference; String */
  return _outValueReference;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getVariableFMIIndex(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_integer _outVariableIndex;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVariableIndex has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      modelica_integer _variableIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _variableIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 20));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _variableIndex = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _variableIndex;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 0);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVariableIndex = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outVariableIndex;
}
modelica_metatype boxptr_SimCodeUtil_getVariableFMIIndex(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_integer _outVariableIndex;
  modelica_metatype out_outVariableIndex;
  _outVariableIndex = omc_SimCodeUtil_getVariableFMIIndex(threadData, _inVar);
  out_outVariableIndex = mmc_mk_icon(_outVariableIndex);
  return out_outVariableIndex;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getVariableIndex(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_integer _outVariableIndex;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVariableIndex has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      modelica_integer _variableIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _variableIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _variableIndex = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _variableIndex;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 0);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVariableIndex = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outVariableIndex;
}
modelica_metatype boxptr_SimCodeUtil_getVariableIndex(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_integer _outVariableIndex;
  modelica_metatype out_outVariableIndex;
  _outVariableIndex = omc_SimCodeUtil_getVariableIndex(threadData, _inVar);
  out_outVariableIndex = mmc_mk_icon(_outVariableIndex);
  return out_outVariableIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getScalarVars(threadData_t *threadData, modelica_metatype _inVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = tmpMeta1;

  {
    modelica_metatype _var;
    for (tmpMeta2 = listReverse(_inVars); !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _var = MMC_CAR(tmpMeta2);
      _outVars = listAppend(omc_SimCodeUtil_getScalarElements(threadData, _var), _outVars);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_fillScalarElements(threadData_t *threadData, modelica_metatype _eltIn, modelica_metatype _dims, modelica_integer _dimIdx, modelica_metatype _subsIn, modelica_metatype __omcQ_24in_5Felts)
{
  modelica_metatype __omcQ_24mrfa_5F0 = NULL;
  modelica_metatype __omcQ_24mrfa_5F1 = NULL;
  modelica_metatype _elts = NULL;
  modelica_metatype _elt = NULL;
  modelica_metatype _subs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta15;
  modelica_integer tmp16;
  modelica_integer tmp17;
  modelica_integer tmp18;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F0 has no default value.
  // __omcQ_24mrfa_5F1 has no default value.
  _elts = __omcQ_24in_5Felts;
  _elt = _eltIn;
  // _subs has no default value.
  tmp16 = mmc_unbox_integer(listGet(_dims, _dimIdx)); tmp17 = ((modelica_integer) -1); tmp18 = ((modelica_integer) 1);
  if(!(((tmp17 > 0) && (tmp16 > tmp18)) || ((tmp17 < 0) && (tmp16 < tmp18))))
  {
    modelica_integer _i;
    for(_i = mmc_unbox_integer(listGet(_dims, _dimIdx)); in_range_integer(_i, tmp16, tmp18); _i += tmp17)
    {
      tmpMeta2 = mmc_mk_box2(3, &DAE_Exp_ICONST__desc, mmc_mk_integer(_i));
      tmpMeta3 = mmc_mk_box2(5, &DAE_Subscript_INDEX__desc, tmpMeta2);
      tmpMeta1 = mmc_mk_cons(tmpMeta3, _subsIn);
      _subs = tmpMeta1;

      if((_dimIdx < listLength(_dims)))
      {
        _elts = omc_SimCodeUtil_fillScalarElements(threadData, _eltIn, _dims, ((modelica_integer) 1) + _dimIdx, _subs, _elts);
      }
      else
      {
        _subs = listReverse(_subs);

        __omcQ_24mrfa_5F0 = omc_ComponentReference_crefSetLastSubs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 2))), _subs);

        __omcQ_24mrfa_5F1 = mmc_mk_some(omc_ComponentReference_crefSetLastSubs(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 31)))), _subs));

        tmpMeta4 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, __omcQ_24mrfa_5F0, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 30))), __omcQ_24mrfa_5F1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_elt), 32))));
        _elt = tmpMeta4;

        { /* match expression */
          modelica_metatype tmp7_1;
          tmp7_1 = _elt;
          {
            modelica_metatype _cref = NULL;
            modelica_boolean _fixed;
            volatile mmc_switch_type tmp7;
            int tmp8;
            // _cref has no default value.
            // _fixed has no default value.
            tmp7 = 0;
            for (; tmp7 < 2; tmp7++) {
              switch (MMC_SWITCH_CAST(tmp7)) {
              case 0: {
                modelica_metatype tmpMeta9;
                modelica_metatype tmpMeta10;
                modelica_metatype tmpMeta11;
                modelica_integer tmp12;
                modelica_metatype tmpMeta13;
                modelica_metatype tmpMeta14;
                tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
                if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,5,2) == 0) goto tmp6_end;
                tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
                tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
                tmp12 = mmc_unbox_integer(tmpMeta11);
                
                _cref = tmpMeta10;
                _fixed = tmp12  /* pattern as ty=Boolean */;
                /* Pattern matching succeeded */
                tmpMeta14 = mmc_mk_box3(8, &BackendDAE_VarKind_CLOCKED__STATE__desc, omc_ComponentReference_crefSetLastSubs(threadData, _cref, _subs), mmc_mk_boolean(_fixed));
                tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(33));
                memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_elt), 33*sizeof(modelica_metatype));
                ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[3] = tmpMeta14;
                _elt = tmpMeta13;
                goto tmp6_done;
              }
              case 1: {
                
                /* Pattern matching succeeded */
                goto tmp6_done;
              }
              }
              goto tmp6_end;
              tmp6_end: ;
            }
            goto goto_5;
            goto_5:;
            MMC_THROW_INTERNAL();
            goto tmp6_done;
            tmp6_done:;
          }
        }
        ;

        tmpMeta15 = mmc_mk_cons(_elt, _elts);
        _elts = tmpMeta15;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _elts;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillScalarElements(threadData_t *threadData, modelica_metatype _eltIn, modelica_metatype _dims, modelica_metatype _dimIdx, modelica_metatype _subsIn, modelica_metatype __omcQ_24in_5Felts)
{
  modelica_integer tmp1;
  modelica_metatype _elts = NULL;
  tmp1 = mmc_unbox_integer(_dimIdx);
  _elts = omc_SimCodeUtil_fillScalarElements(threadData, _eltIn, _dims, tmp1, _subsIn, __omcQ_24in_5Felts);
  /* skip box _elts; list<SimCodeVar.SimVar> */
  return _elts;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getScalarElements(threadData_t *threadData, modelica_metatype _var)
{
  modelica_metatype _elts = NULL;
  modelica_metatype _dims = NULL;
  modelica_metatype _elt = NULL;
  modelica_integer _index;
  modelica_integer _fmi_index;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _elts has no default value.
  // _dims has no default value.
  // _elt has no default value.
  // _index has no default value.
  // _fmi_index has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 31));
          if (!optionNone(tmpMeta7)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta8;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,6,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          if (optionNone(tmpMeta10)) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 20));
          if (optionNone(tmpMeta13)) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          
          _index = tmp12  /* pattern as ty=Integer */;
          _fmi_index = tmp15  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _dims = omc_List_map(threadData, omc_List_lastN(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 21))), listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 21))))), boxvar_stringInt);

          _elt = _var;

          tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(33));
          memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_elt), 33*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[13] = omc_Types_arrayElementType(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 13))));
          _elt = tmpMeta16;

          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          _elts = omc_SimCodeUtil_fillScalarElements(threadData, _elt, _dims, ((modelica_integer) 1), tmpMeta17, tmpMeta18);
          tmpMeta1 = omc_SimCodeUtil_setVariableIndexHelper(threadData, _elts, _index, _fmi_index, NULL, NULL);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta19;
          
          /* Pattern matching succeeded */
          tmpMeta19 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _elts = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _elts;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumScalars(threadData_t *threadData, modelica_metatype _vars)
{
  modelica_integer _numScalars;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _numScalars has no default value.
  _numScalars = mmc_unbox_integer(omc_List_applyAndFold(threadData, _vars, boxvar_intAdd, boxvar_SimCodeUtilShared_getNumElems, mmc_mk_integer(((modelica_integer) 0))));
  _return: OMC_LABEL_UNUSED
  return _numScalars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumScalars(threadData_t *threadData, modelica_metatype _vars)
{
  modelica_integer _numScalars;
  modelica_metatype out_numScalars;
  _numScalars = omc_SimCodeUtil_getNumScalars(threadData, _vars);
  out_numScalars = mmc_mk_icon(_numScalars);
  return out_numScalars;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getStateSimVarIndexFromIndex(threadData_t *threadData, modelica_metatype _inStateVars, modelica_integer _inIndex)
{
  modelica_integer _outVariableIndex;
  modelica_metatype _stateVar = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVariableIndex has no default value.
  // _stateVar has no default value.
  _stateVar = listGet(_inStateVars, ((modelica_integer) 1) + _inIndex - (((stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119))?((modelica_integer) 0):listLength(_inStateVars))));

  _outVariableIndex = omc_SimCodeUtil_getVariableIndex(threadData, _stateVar);
  _return: OMC_LABEL_UNUSED
  return _outVariableIndex;
}
modelica_metatype boxptr_SimCodeUtil_getStateSimVarIndexFromIndex(threadData_t *threadData, modelica_metatype _inStateVars, modelica_metatype _inIndex)
{
  modelica_integer tmp1;
  modelica_integer _outVariableIndex;
  modelica_metatype out_outVariableIndex;
  tmp1 = mmc_unbox_integer(_inIndex);
  _outVariableIndex = omc_SimCodeUtil_getStateSimVarIndexFromIndex(threadData, _inStateVars, tmp1);
  out_outVariableIndex = mmc_mk_icon(_outVariableIndex);
  return out_outVariableIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_mergeSparsePatter(threadData_t *threadData, modelica_metatype _inA, modelica_metatype _inB, modelica_metatype _inAccum)
{
  modelica_metatype _out = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _out has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inA;
    tmp4_2 = _inB;
    {
      modelica_metatype _restA = NULL;
      modelica_metatype _restB = NULL;
      modelica_metatype _crefA = NULL;
      modelica_metatype _crefB = NULL;
      modelica_metatype _listA = NULL;
      modelica_metatype _listB = NULL;
      modelica_metatype _listOut = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _restA has no default value.
      // _restB has no default value.
      // _crefA has no default value.
      // _crefB has no default value.
      // _listA has no default value.
      // _listB has no default value.
      // _listOut has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = listReverse(_inAccum);
          goto tmp3_done;
        }
        case 1: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inB;
          goto tmp3_done;
        }
        case 2: {
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inA;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_boolean tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_2);
          tmpMeta11 = MMC_CDR(tmp4_2);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          _crefA = tmpMeta8;
          _listA = tmpMeta9;
          _restA = tmpMeta7;
          _crefB = tmpMeta12;
          _listB = tmpMeta13;
          _restB = tmpMeta11;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp14 = omc_ComponentReferenceBasics_crefEqual(threadData, _crefA, _crefB);
          if (1 /* true */ != tmp14) goto goto_2;

          _listOut = omc_List_unionOnTrue(threadData, _listA, _listB, boxvar_ComponentReferenceBasics_crefEqual);
          tmpMeta16 = mmc_mk_box2(0, _crefA, _listOut);
          tmpMeta15 = mmc_mk_cons(tmpMeta16, _inAccum);
          /* Tail recursive call */
          _inA = _restA;
          _inB = _restB;
          _inAccum = tmpMeta15;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _out = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _out;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateSparsePatterCref2DerCref(threadData_t *threadData, modelica_metatype _sparsePattern, modelica_metatype _inSimVarHT, modelica_metatype _inAccum, modelica_metatype _inAccum2, modelica_metatype *out_outDerCrefs)
{
  modelica_metatype _outSparsePattern = NULL;
  modelica_metatype _outDerCrefs = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSparsePattern has no default value.
  // _outDerCrefs has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _sparsePattern;
    {
      modelica_metatype _cref = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _simVar = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cref has no default value.
      // _crefs has no default value.
      // _rest has no default value.
      // _simVar has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = listReverse(_inAccum);
          tmpMeta[0+1] = listReverse(_inAccum2);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          _cref = tmpMeta8;
          _crefs = tmpMeta9;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _simVar = omc_BaseHashTable_get(threadData, _cref, _inSimVarHT);

          if(omc_BackendVariable_isVarKindState(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 3)))))
          {
            _cref = omc_ComponentReference_crefPrefixDer(threadData, _cref);
          }
          tmpMeta11 = mmc_mk_box2(0, _cref, _crefs);
          tmpMeta10 = mmc_mk_cons(tmpMeta11, _inAccum);
          tmpMeta12 = mmc_mk_cons(_cref, _inAccum2);
          /* Tail recursive call */
          _sparsePattern = _rest;
          _inAccum = tmpMeta10;
          _inAccum2 = tmpMeta12;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outSparsePattern = tmpMeta[0+0];
  _outDerCrefs = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outDerCrefs) { *out_outDerCrefs = _outDerCrefs; }
  return _outSparsePattern;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateSparsePatterInts2FMIUnknown(threadData_t *threadData, modelica_metatype _inSparsePattern, modelica_metatype _inAccum)
{
  modelica_metatype _outFmiUnknown = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFmiUnknown has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inSparsePattern;
    {
      modelica_metatype _rest = NULL;
      modelica_integer _unknown;
      modelica_metatype _dependencies = NULL;
      modelica_metatype _dependenciesKind = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _unknown has no default value.
      // _dependencies has no default value.
      // _dependenciesKind has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = listReverse(_inAccum);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          _unknown = tmp9  /* pattern as ty=Integer */;
          _dependencies = tmpMeta10;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _dependenciesKind = omc_List_fill(threadData, _OMC_LIT121, listLength(_dependencies));
          tmpMeta12 = mmc_mk_box4(3, &SimCode_FmiUnknown_FMIUNKNOWN__desc, mmc_mk_integer(_unknown), _dependencies, _dependenciesKind);
          tmpMeta11 = mmc_mk_cons(tmpMeta12, _inAccum);
          /* Tail recursive call */
          _inSparsePattern = _rest;
          _inAccum = tmpMeta11;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFmiUnknown = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFmiUnknown;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isFmiUnknown(threadData_t *threadData, modelica_integer _index, modelica_metatype _inFMIUnknown)
{
  modelica_boolean _out;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _out has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inFMIUnknown;
    {
      modelica_integer _i;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _i has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          
          _i = tmp7  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(_i == _index)) goto tmp3_end;
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _out = tmp1;
  _return: OMC_LABEL_UNUSED
  return _out;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isFmiUnknown(threadData_t *threadData, modelica_metatype _index, modelica_metatype _inFMIUnknown)
{
  modelica_integer tmp1;
  modelica_boolean _out;
  modelica_metatype out_out;
  tmp1 = mmc_unbox_integer(_index);
  _out = omc_SimCodeUtil_isFmiUnknown(threadData, tmp1, _inFMIUnknown);
  out_out = mmc_mk_icon(_out);
  return out_out;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isOutputSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 18));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isOutputSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isOutputSimVar(threadData, _inVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isClockedStateSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,5,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isClockedStateSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isClockedStateSimVar(threadData, _inVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getAllParamSimVars(threadData_t *threadData, modelica_metatype _inModelInfo)
{
  modelica_metatype _allParamVars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _allParamVars = tmpMeta1;
  _allParamVars = listAppend(listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 14)))), listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 17)))));
  _return: OMC_LABEL_UNUSED
  return _allParamVars;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpFmiInitialUnknownsDependencies(threadData_t *threadData, modelica_metatype _sparsePattern, modelica_string _heading)
{
  modelica_metatype _rowspT = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype _dependencylist = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _rowspT has no default value.
  // _var has no default value.
  // _dependencylist has no default value.
  tmpMeta1 = stringAppend(_heading,_OMC_LIT48);
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT122);
  tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta3),stdout);

  /* Pattern-matching assignment */
  tmpMeta4 = _sparsePattern;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  _rowspT = tmpMeta5;

  {
    modelica_metatype _i;
    for (tmpMeta6 = _rowspT; !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
    {
      _i = MMC_CAR(tmpMeta6);
      /* Pattern-matching assignment */
      tmpMeta7 = _i;
      tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
      tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
      _var = tmpMeta8;
      _dependencylist = tmpMeta9;

      tmpMeta10 = stringAppend(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _var),_OMC_LIT123);
      tmpMeta11 = stringAppend(tmpMeta10,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _dependencylist));
      tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT48);
      fputs(MMC_STRINGDATA(tmpMeta12),stdout);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExactSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype _default_causality = NULL;
  modelica_metatype _default_variability = NULL;
  modelica_metatype _default_initial = NULL;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  _default_causality = _OMC_LIT93;
  _default_variability = _OMC_LIT124;
  // _default_initial has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 30));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 30));
          if (!optionNone(tmpMeta8)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _default_initial = omc_SimCodeUtil_getDefaultFmiInitialAttribute(threadData, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 29))), _default_variability), omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 18))), _default_causality));
          tmp1 = omc_SimCodeUtil_isInitialExact(threadData, _default_initial);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExactSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isInitialExactSimVar(threadData, _simVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityInputSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 18));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,2,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityInputSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isCausalityInputSimVar(threadData, _simVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _depVars, modelica_metatype _indepVars, modelica_metatype _initialUnknowns, modelica_metatype _crefSimVarHT, modelica_metatype *out_outindepVars)
{
  modelica_metatype _outdepVars = NULL;
  modelica_metatype _outindepVars = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _referenceVar = NULL;
  modelica_metatype _variability = NULL;
  modelica_boolean _isConst;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta14;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outdepVars = _depVars;
  _outindepVars = _indepVars;
  // _cref has no default value.
  // _referenceVar has no default value.
  // _variability has no default value.
  _isConst = 0 /* false */;
  {
    modelica_metatype _var;
    for (tmpMeta1 = _inVar; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      _cref = omc_BackendVariable_varCref(threadData, _var);

      if(omc_UnorderedSet_contains(threadData, _cref, _initialUnknowns))
      {
        tmpMeta2 = mmc_mk_cons(_var, _outdepVars);
        _outdepVars = tmpMeta2;
      }

      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp5;
          int tmp6;
          tmp5 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp4_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp5 < 2; tmp5++) {
            switch (MMC_SWITCH_CAST(tmp5)) {
            case 0: {
              modelica_boolean tmp7 = 0;
              modelica_metatype tmpMeta13;
              /* Pattern matching succeeded */
              _referenceVar = omc_BaseHashTable_get(threadData, _cref, _crefSimVarHT);

              { /* match expression */
                modelica_metatype tmp10_1;
                tmp10_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_referenceVar), 29)));
                {
                  volatile mmc_switch_type tmp10;
                  int tmp11;
                  tmp10 = 0;
                  for (; tmp10 < 2; tmp10++) {
                    switch (MMC_SWITCH_CAST(tmp10)) {
                    case 0: {
                      modelica_metatype tmpMeta12;
                      if (optionNone(tmp10_1)) goto tmp9_end;
                      tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp10_1), 1));
                      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,0,0) == 0) goto tmp9_end;
                      /* Pattern matching succeeded */
                      tmp7 = 1 /* true */;
                      goto tmp9_done;
                    }
                    case 1: {
                      
                      /* Pattern matching succeeded */
                      tmp7 = 0 /* false */;
                      goto tmp9_done;
                    }
                    }
                    goto tmp9_end;
                    tmp9_end: ;
                  }
                  goto goto_8;
                  goto_8:;
                  goto goto_3;
                  goto tmp9_done;
                  tmp9_done:;
                }
              }
              _isConst = tmp7;

              if(((!_isConst) && (omc_SimCodeUtil_isCausalityInputSimVar(threadData, _referenceVar) || omc_SimCodeUtil_isInitialExactSimVar(threadData, _referenceVar))))
              {
                tmpMeta13 = mmc_mk_cons(_var, _outindepVars);
                _outindepVars = tmpMeta13;
              }
              goto tmp4_done;
            }
            case 1: {
              /* Pattern matching succeeded */
              goto tmp4_done;
            }
            }
            goto tmp4_end;
            tmp4_end: ;
          }
          goto goto_3;
          tmp4_done:
          (void)tmp5;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp4_done2;
          goto_3:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp5 < 2) {
            goto tmp4_top;
          }
          MMC_THROW_INTERNAL();
          tmp4_done2:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outindepVars) { *out_outindepVars = _outindepVars; }
  return _outdepVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDependentAndIndepentVarsForJacobian(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _orderedVars, modelica_metatype _crefSimVarHT)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _var = NULL;
  modelica_metatype _simVar = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVar = tmpMeta1;
  // _var has no default value.
  // _simVar has no default value.
  {
    modelica_metatype _cr;
    for (tmpMeta2 = _crefs; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _cr = MMC_CAR(tmpMeta2);
      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp5;
          int tmp6;
          tmp5 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp4_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp5 < 2; tmp5++) {
            switch (MMC_SWITCH_CAST(tmp5)) {
            case 0: {
              modelica_metatype tmpMeta7;
              /* Pattern matching succeeded */
              _var = omc_BackendVariable_getVarSingle(threadData, _cr, _orderedVars, NULL);

              _simVar = omc_BaseHashTable_get(threadData, _cr, _crefSimVarHT);

              if((omc_BackendVariable_isRealVar(threadData, _var) && isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 31))))))
              {
                tmpMeta7 = mmc_mk_cons(_var, _outVar);
                _outVar = tmpMeta7;
              }
              goto tmp4_done;
            }
            case 1: {
              modelica_metatype tmpMeta8;
              /* Pattern matching succeeded */
              tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
              _outVar = tmpMeta8;
              goto tmp4_done;
            }
            }
            goto tmp4_end;
            tmp4_end: ;
          }
          goto goto_3;
          tmp4_done:
          (void)tmp5;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp4_done2;
          goto_3:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp5 < 2) {
            goto tmp4_top;
          }
          MMC_THROW_INTERNAL();
          tmp4_done2:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiInitialUnknowns(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_metatype _inSimDAE, modelica_metatype _crefSimVarHT, modelica_metatype _initialUnknownList, modelica_metatype *out_fmiDerInit, modelica_metatype *out_sortedUnknownCrefs, modelica_metatype *out_sortedknownCrefs)
{
  modelica_metatype _outFmiUnknownlist = NULL;
  modelica_metatype _fmiDerInit = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _sortedUnknownCrefs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _sortedknownCrefs = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _initialUnknownCrefs = NULL;
  modelica_metatype _indepCrefs = NULL;
  modelica_metatype _depCrefs = NULL;
  modelica_metatype _crefs = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _tmpBDAE = NULL;
  modelica_metatype _orderedVars = NULL;
  modelica_metatype _indepVars = NULL;
  modelica_metatype _depVars = NULL;
  modelica_metatype _fmiDerInitIndepVars = NULL;
  modelica_metatype _fmiDerInitDepVars = NULL;
  modelica_metatype _sparsePattern = NULL;
  modelica_metatype _sparseColoring = NULL;
  modelica_metatype _rowspt = NULL;
  modelica_metatype _sparseInts = NULL;
  modelica_metatype _vars1 = NULL;
  modelica_metatype _vars2 = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _currentSystem = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _lhs = NULL;
  modelica_metatype _rhs = NULL;
  modelica_metatype _eqn = NULL;
  modelica_string _strMatchingAlgorithm = NULL;
  modelica_string _strIndexReductionMethod = NULL;
  modelica_metatype _outAdjacencyMatrix = NULL;
  modelica_metatype _match1 = NULL;
  modelica_metatype _match2 = NULL;
  modelica_boolean _debug;
  modelica_metatype _initialUnknowns = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_metatype tmpMeta29;
  modelica_metatype tmpMeta30;
  modelica_metatype tmpMeta31;
  modelica_metatype tmpMeta32;
  modelica_metatype tmpMeta33;
  modelica_metatype tmpMeta34;
  modelica_metatype tmpMeta35;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFmiUnknownlist has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _fmiDerInit = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _sortedUnknownCrefs = tmpMeta2;
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _sortedknownCrefs = tmpMeta3;
  // _initialUnknownCrefs has no default value.
  // _indepCrefs has no default value.
  // _depCrefs has no default value.
  // _crefs has no default value.
  // _cref has no default value.
  // _tmpBDAE has no default value.
  // _orderedVars has no default value.
  // _indepVars has no default value.
  // _depVars has no default value.
  // _fmiDerInitIndepVars has no default value.
  // _fmiDerInitDepVars has no default value.
  // _sparsePattern has no default value.
  // _sparseColoring has no default value.
  // _rowspt has no default value.
  // _sparseInts has no default value.
  // _vars1 has no default value.
  // _vars2 has no default value.
  // _shared has no default value.
  // _currentSystem has no default value.
  // _eqs has no default value.
  // _lhs has no default value.
  // _rhs has no default value.
  // _eqn has no default value.
  // _strMatchingAlgorithm has no default value.
  // _strIndexReductionMethod has no default value.
  // _outAdjacencyMatrix has no default value.
  // _match1 has no default value.
  // _match2 has no default value.
  _debug = 0 /* false */;
  // _initialUnknowns has no default value.
  _initialUnknownCrefs = omc_List_map(threadData, _initialUnknownList, boxvar_SimCodeUtil_getCrefFromSimVar);

  _initialUnknowns = omc_UnorderedSet_fromList(threadData, _initialUnknownCrefs, boxvar_ComponentReferenceBasics_hashComponentRef, boxvar_ComponentReferenceBasics_crefEqual);

  if(_debug)
  {
    tmpMeta4 = stringAppend(_OMC_LIT125,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _initialUnknownCrefs));
    fputs(MMC_STRINGDATA(tmpMeta4),stdout);
  }

  _tmpBDAE = omc_BackendDAEUtil_copyBackendDAE(threadData, _inInitDAE);

  _tmpBDAE = omc_BackendDAEOptimize_collapseIndependentBlocks(threadData, _tmpBDAE);

  /* Pattern-matching assignment */
  tmpMeta5 = _tmpBDAE;
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
  if (listEmpty(tmpMeta6)) MMC_THROW_INTERNAL();
  tmpMeta7 = MMC_CAR(tmpMeta6);
  tmpMeta8 = MMC_CDR(tmpMeta6);
  if (!listEmpty(tmpMeta8)) MMC_THROW_INTERNAL();
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
  _currentSystem = tmpMeta7;
  _shared = tmpMeta9;

  if(_debug)
  {
    omc_BackendDump_dumpVariables(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 2))), _OMC_LIT126);

    omc_BackendDump_dumpEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 3))), _OMC_LIT127);

    omc_BackendDump_dumpVariables(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 2))), _OMC_LIT128);

    omc_BackendDump_dumpVariables(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimDAE), 3)))), 2))), _OMC_LIT129);
  }

  {
    modelica_metatype _var;
    for (tmpMeta10 = omc_BackendVariable_varList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimDAE), 3)))), 2)))); !listEmpty(tmpMeta10); tmpMeta10=MMC_CDR(tmpMeta10))
    {
      _var = MMC_CAR(tmpMeta10);
      if((omc_BackendVariable_isParam(threadData, _var) && (!omc_BackendVariable_containsCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 2)))))))
      {
        _lhs = omc_BackendVariable_varExp(threadData, _var);

        _rhs = omc_BackendVariable_varBindExpStartValueNoFail(threadData, _var);

        tmpMeta11 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _lhs, _rhs, _OMC_LIT92, _OMC_LIT132);
        _eqn = tmpMeta11;

        omc_BackendEquation_add(threadData, _eqn, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 3))));

        _currentSystem = omc_BackendVariable_addVarDAE(threadData, _var, _currentSystem);
      }
      else
      {
        if((!omc_BackendVariable_containsCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 2))))))
        {
          _shared = omc_BackendVariable_addGlobalKnownVarDAE(threadData, _var, _shared);
        }
      }
    }
  }

  _outAdjacencyMatrix = omc_BackendDAEUtil_adjacencyMatrixScalar(threadData, _currentSystem, _OMC_LIT133, mmc_mk_none(), omc_BackendDAEUtil_isInitializationDAE(threadData, _shared), NULL, NULL, NULL);

  _match1 = omc_Matching_PerfectMatching(threadData, _outAdjacencyMatrix ,&_match2);

  tmpMeta14 = mmc_mk_box4(4, &BackendDAE_Matching_MATCHING__desc, _match1, _match2, omc_BackendDAEUtil_getStrongComponents(threadData, _currentSystem));
  tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(11));
  memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_currentSystem), 11*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[7] = tmpMeta14;
  _currentSystem = tmpMeta13;

  tmpMeta15 = mmc_mk_cons(_currentSystem, MMC_REFSTRUCTLIT(mmc_nil));
  tmpMeta16 = mmc_mk_box3(3, &BackendDAE_BackendDAE_DAE__desc, tmpMeta15, _shared);
  _tmpBDAE = tmpMeta16;

  _strMatchingAlgorithm = omc_BackendDAEUtil_getMatchingAlgorithmString(threadData);

  _strIndexReductionMethod = omc_BackendDAEUtil_getIndexReductionMethodString(threadData);

  _tmpBDAE = omc_BackendDAEUtil_causalizeDAE(threadData, _tmpBDAE, mmc_mk_none(), omc_BackendDAEUtil_getMatchingAlgorithm(threadData, mmc_mk_some(_strMatchingAlgorithm)), omc_BackendDAEUtil_getIndexReductionMethod(threadData, mmc_mk_some(_strIndexReductionMethod)), 0 /* false */);

  if(_debug)
  {
    omc_BackendDump_dumpBackendDAE(threadData, _tmpBDAE, _OMC_LIT134);
  }

  _orderedVars = omc_BackendVariable_equationSystemsVarsLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpBDAE), 2))));

  tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
  _indepVars = tmpMeta17;

  tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
  _depVars = tmpMeta18;

  _depVars = omc_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns(threadData, _orderedVars, _depVars, _indepVars, _initialUnknowns, _crefSimVarHT ,&_indepVars);

  _depVars = omc_SimCodeUtil_getDepAndIndepVarsForInitialUnknowns(threadData, omc_BackendVariable_varList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpBDAE), 3)))), 2)))), _depVars, _indepVars, _initialUnknowns, _crefSimVarHT ,&_indepVars);

  if(_debug)
  {
    omc_BackendDump_dumpVarList(threadData, _depVars, _OMC_LIT135);

    omc_BackendDump_dumpVarList(threadData, _indepVars, _OMC_LIT136);
  }

  _sparsePattern = omc_SymbolicJacobian_generateSparsePattern(threadData, _tmpBDAE, _indepVars, _depVars, 0 /* false */ ,&_sparseColoring);

  if(_debug)
  {
    omc_SimCodeUtil_dumpFmiInitialUnknownsDependencies(threadData, _sparsePattern, _OMC_LIT137);
  }

  /* Pattern-matching assignment */
  tmpMeta19 = _sparsePattern;
  tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
  tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 3));
  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
  tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
  _rowspt = tmpMeta20;
  _indepCrefs = tmpMeta22;
  _depCrefs = tmpMeta23;

  _vars1 = omc_SimCodeUtil_getSimVars2Crefs(threadData, _indepCrefs, _crefSimVarHT);

  _vars2 = omc_SimCodeUtil_getSimVars2Crefs(threadData, _depCrefs, _crefSimVarHT);

  _vars2 = listAppend(_vars1, _vars2);

  tmpMeta24 = MMC_REFSTRUCTLIT(mmc_nil);
  _indepCrefs = tmpMeta24;

  tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
  _depCrefs = tmpMeta25;

  {
    modelica_metatype _i;
    for (tmpMeta26 = _rowspt; !listEmpty(tmpMeta26); tmpMeta26=MMC_CDR(tmpMeta26))
    {
      _i = MMC_CAR(tmpMeta26);
      /* Pattern-matching assignment */
      tmpMeta27 = _i;
      tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 1));
      tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
      _cref = tmpMeta28;
      _crefs = tmpMeta29;

      tmpMeta30 = mmc_mk_cons(_cref, _depCrefs);
      _depCrefs = tmpMeta30;

      {
        modelica_metatype _cr;
        for (tmpMeta31 = _crefs; !listEmpty(tmpMeta31); tmpMeta31=MMC_CDR(tmpMeta31))
        {
          _cr = MMC_CAR(tmpMeta31);
          if((!listMember(_cr, _indepCrefs)))
          {
            tmpMeta32 = mmc_mk_cons(_cr, _indepCrefs);
            _indepCrefs = tmpMeta32;
          }
        }
      }
    }
  }

  if(((!omc_Flags_isSet(threadData, _OMC_LIT142)) && (!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))))
  {
    _fmiDerInitDepVars = omc_SimCodeUtil_getDependentAndIndepentVarsForJacobian(threadData, _depCrefs, omc_BackendVariable_listVar(threadData, _orderedVars), _crefSimVarHT);

    _fmiDerInitIndepVars = omc_SimCodeUtil_getDependentAndIndepentVarsForJacobian(threadData, _indepCrefs, omc_BackendVariable_listVar(threadData, _orderedVars), _crefSimVarHT);

    if(_debug)
    {
      omc_BackendDump_dumpVarList(threadData, _fmiDerInitDepVars, _OMC_LIT138);

      omc_BackendDump_dumpVarList(threadData, _fmiDerInitIndepVars, _OMC_LIT139);
    }

    _fmiDerInit = omc_SymbolicJacobian_createFMIModelDerivativesForInitialization(threadData, _inInitDAE, _inSimDAE, _fmiDerInitDepVars, _fmiDerInitIndepVars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_currentSystem), 2))), _sparsePattern, _sparseColoring);

    _sortedknownCrefs = omc_SimCodeUtil_sortInitialUnknowsSimVars(threadData, omc_SimCodeUtil_getSimVars2Crefs(threadData, _indepCrefs, _crefSimVarHT));

    _sortedUnknownCrefs = omc_SimCodeUtil_sortInitialUnknowsSimVars(threadData, omc_SimCodeUtil_getSimVars2Crefs(threadData, _depCrefs, _crefSimVarHT));
  }

  _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _vars2, _rowspt, 1 /* true */);

  tmpMeta35 = MMC_REFSTRUCTLIT(mmc_nil);
  _outFmiUnknownlist = omc_SimCodeUtil_translateSparsePatterInts2FMIUnknown(threadData, _sparseInts, tmpMeta35);
  _return: OMC_LABEL_UNUSED
  if (out_fmiDerInit) { *out_fmiDerInit = _fmiDerInit; }
  if (out_sortedUnknownCrefs) { *out_sortedUnknownCrefs = _sortedUnknownCrefs; }
  if (out_sortedknownCrefs) { *out_sortedknownCrefs = _sortedknownCrefs; }
  return _outFmiUnknownlist;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExact(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _initial_;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExact(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isInitialExact(threadData, _initial_);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getCrefFromSimVar(threadData_t *threadData, modelica_metatype _inSimVar)
{
  modelica_metatype _outCref = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outCref = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSimVar), 2)));
  _return: OMC_LABEL_UNUSED
  return _outCref;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityCalculatedParameterSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 18));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,5,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityCalculatedParameterSimVar(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isCausalityCalculatedParameterSimVar(threadData, _inVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialApproxOrCalculated(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _initial_;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 5: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 6: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialApproxOrCalculated(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isInitialApproxOrCalculated(threadData, _initial_);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isStateInitialUnknownSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = (!mmc_unbox_boolean((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 12)))));
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData, _simVar);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isStateInitialUnknownSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isStateInitialUnknownSimVar(threadData, _simVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype _default_causality = NULL;
  modelica_metatype _default_variability = NULL;
  modelica_metatype _default_initial = NULL;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  _default_causality = _OMC_LIT93;
  _default_variability = _OMC_LIT124;
  // _default_initial has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 30));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,3,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 30));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,2,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 30));
          if (!optionNone(tmpMeta10)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _default_initial = omc_SimCodeUtil_getDefaultFmiInitialAttribute(threadData, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 29))), _default_variability), omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 18))), _default_causality));
          tmp1 = omc_SimCodeUtil_isInitialApproxOrCalculated(threadData, _default_initial);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_SimCodeUtil_isInitialApproxOrCalculatedSimVar(threadData, _simVar);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  return out_outBoolean;
}

static modelica_metatype closure3_SimCodeUtil_isFmiUnknown(threadData_t *thData, modelica_metatype closure, modelica_metatype index)
{
  modelica_metatype inFMIUnknown = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_isFmiUnknown(thData, index, inFMIUnknown);
}static modelica_metatype closure4_SimCodeUtil_isFmiUnknown(threadData_t *thData, modelica_metatype closure, modelica_metatype index)
{
  modelica_metatype inFMIUnknown = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_isFmiUnknown(thData, index, inFMIUnknown);
}static modelica_metatype closure5_SimCodeUtil_isFmiUnknown(threadData_t *thData, modelica_metatype closure, modelica_metatype index)
{
  modelica_metatype inFMIUnknown = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_isFmiUnknown(thData, index, inFMIUnknown);
}
DLLDirection
modelica_metatype omc_SimCodeUtil_createFMIModelStructure(threadData_t *threadData, modelica_metatype _inSymjacs, modelica_metatype _inModelInfo, modelica_integer _inUniqueEqIndex, modelica_metatype _inInitDAE, modelica_metatype _inSimDAE, modelica_metatype *out_outFmiModelStructure, modelica_metatype *out_outModelInfo, modelica_metatype *out_symJacs, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _symJacFMI = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outFmiModelStructure = NULL;
  modelica_metatype _outModelInfo = NULL;
  modelica_metatype _symJacs = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _spTA = NULL;
  modelica_metatype _spTA1 = NULL;
  modelica_metatype _sparseInts = NULL;
  modelica_metatype _allUnknowns = NULL;
  modelica_metatype _derivatives = NULL;
  modelica_metatype _outputs = NULL;
  modelica_metatype _discreteStates = NULL;
  modelica_metatype _allInitialUnknowns = NULL;
  modelica_metatype _varsA = NULL;
  modelica_metatype _varsB = NULL;
  modelica_metatype _varsC = NULL;
  modelica_metatype _varsD = NULL;
  modelica_metatype _clockedStates = NULL;
  modelica_metatype _allOutputVars = NULL;
  modelica_metatype _allParamVars = NULL;
  modelica_metatype _tmpInitialUnknowns = NULL;
  modelica_metatype _diffCrefsA = NULL;
  modelica_metatype _diffCrefsA1 = NULL;
  modelica_metatype _diffedCrefsA = NULL;
  modelica_metatype _diffedCrefsA1 = NULL;
  modelica_metatype _derdiffCrefsA = NULL;
  modelica_metatype _optcontPartDer = NULL;
  modelica_metatype _optinitialPartDer = NULL;
  modelica_metatype _spPattern = NULL;
  modelica_metatype _spPattern1 = NULL;
  modelica_metatype _spColors = NULL;
  modelica_metatype _spColors1 = NULL;
  modelica_metatype _nlPattern = NULL;
  modelica_metatype _contPartDer = NULL;
  modelica_metatype _initPartDer = NULL;
  modelica_metatype _contSimJac = NULL;
  modelica_metatype _initSimJac = NULL;
  modelica_metatype _contPartSimDer = NULL;
  modelica_metatype _initPartSimDer = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _crefSimVarHT = NULL;
  modelica_metatype _intLst = NULL;
  modelica_metatype _fmiDerInit = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _symJacsInit = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype _symJacFMIINIT = NULL;
  modelica_metatype tmpMeta5;
  modelica_metatype _sortedUnknownCrefs = NULL;
  modelica_metatype tmpMeta6;
  modelica_metatype _sortedknownCrefs = NULL;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _symJacFMI = tmpMeta1;
  // _outFmiModelStructure has no default value.
  _outModelInfo = _inModelInfo;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _symJacs = tmpMeta2;
  _uniqueEqIndex = _inUniqueEqIndex;
  // _spTA has no default value.
  // _spTA1 has no default value.
  // _sparseInts has no default value.
  // _allUnknowns has no default value.
  // _derivatives has no default value.
  // _outputs has no default value.
  // _discreteStates has no default value.
  // _allInitialUnknowns has no default value.
  // _varsA has no default value.
  // _varsB has no default value.
  // _varsC has no default value.
  // _varsD has no default value.
  // _clockedStates has no default value.
  // _allOutputVars has no default value.
  // _allParamVars has no default value.
  // _tmpInitialUnknowns has no default value.
  // _diffCrefsA has no default value.
  // _diffCrefsA1 has no default value.
  // _diffedCrefsA has no default value.
  // _diffedCrefsA1 has no default value.
  // _derdiffCrefsA has no default value.
  // _optcontPartDer has no default value.
  // _optinitialPartDer has no default value.
  // _spPattern has no default value.
  // _spPattern1 has no default value.
  // _spColors has no default value.
  // _spColors1 has no default value.
  // _nlPattern has no default value.
  // _contPartDer has no default value.
  // _initPartDer has no default value.
  // _contSimJac has no default value.
  // _initSimJac has no default value.
  // _contPartSimDer has no default value.
  _initPartSimDer = mmc_mk_none();
  // _vars has no default value.
  // _crefSimVarHT has no default value.
  // _intLst has no default value.
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _fmiDerInit = tmpMeta3;
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _symJacsInit = tmpMeta4;
  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  _symJacFMIINIT = tmpMeta5;
  tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
  _sortedUnknownCrefs = tmpMeta6;
  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _sortedknownCrefs = tmpMeta7;
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp10;
      int tmp11;
      tmp10 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp9_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp10 < 2; tmp10++) {
        switch (MMC_SWITCH_CAST(tmp10)) {
        case 0: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_integer tmp54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_integer tmp80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta12 = omc_SymbolicJacobian_getJacobianMatrixbyName(threadData, _inSymjacs, _OMC_LIT143);
          if (optionNone(tmpMeta12)) goto goto_8;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 1));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 3));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 4));
          _optcontPartDer = tmpMeta14;
          _spPattern = tmpMeta15;
          _spTA = tmpMeta16;
          _diffCrefsA = tmpMeta18;
          _diffedCrefsA = tmpMeta19;
          _spColors = tmpMeta20;
          _nlPattern = tmpMeta21;

          _crefSimVarHT = omc_SimCodeUtil_createCrefToSimVarHT(threadData, _inModelInfo);

          tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta23 = MMC_REFSTRUCTLIT(mmc_nil);
          _spTA = omc_SimCodeUtil_translateSparsePatterCref2DerCref(threadData, _spTA, _crefSimVarHT, tmpMeta22, tmpMeta23 ,&_derdiffCrefsA);

          _varsA = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffedCrefsA, _crefSimVarHT);

          _varsB = omc_SimCodeUtil_getSimVars2Crefs(threadData, _derdiffCrefsA, _crefSimVarHT);

          _varsC = listAppend(_varsA, _varsB);

          _varsD = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffCrefsA, _crefSimVarHT);

          _varsA = listAppend(_varsC, _varsD);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _varsA, _spTA, 1 /* true */);

          tmpMeta24 = MMC_REFSTRUCTLIT(mmc_nil);
          _allUnknowns = omc_SimCodeUtil_translateSparsePatterInts2FMIUnknown(threadData, _sparseInts, tmpMeta24);

          {
            modelica_metatype __omcQ_24tmpVar11;
            modelica_metatype* tmp26;
            modelica_metatype tmpMeta27;
            modelica_metatype __omcQ_24tmpVar10;
            modelica_integer tmp28;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 3)));
            tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar11 = tmpMeta27; /* defaultValue */
            tmp26 = &__omcQ_24tmpVar11;
            while(1) {
              tmp28 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp28--;
              }
              if (tmp28 == 0) {
                __omcQ_24tmpVar10 = mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v));
                *tmp26 = mmc_mk_cons(__omcQ_24tmpVar10,0);
                tmp26 = &MMC_CDR(*tmp26);
              } else if (tmp28 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp26 = mmc_mk_nil();
            tmpMeta25 = __omcQ_24tmpVar11;
          }
          _intLst = tmpMeta25;

          {
            modelica_metatype __omcQ_24tmpVar13;
            modelica_metatype* tmp30;
            modelica_metatype tmpMeta31;
            modelica_metatype __omcQ_24tmpVar12;
            modelica_integer tmp32;
            modelica_metatype _fmiUnknown_loopVar = 0;
            modelica_metatype tmpMeta33;
            modelica_metatype _fmiUnknown;
            _fmiUnknown_loopVar = _allUnknowns;
            tmpMeta31 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar13 = tmpMeta31; /* defaultValue */
            tmp30 = &__omcQ_24tmpVar13;
            while(1) {
              tmp32 = 1;
              while (!listEmpty(_fmiUnknown_loopVar)) {
                _fmiUnknown = MMC_CAR(_fmiUnknown_loopVar);
                _fmiUnknown_loopVar = MMC_CDR(_fmiUnknown_loopVar);
                tmpMeta33 = mmc_mk_box1(0, _fmiUnknown);
                if (omc_List_any(threadData, _intLst, (modelica_fnptr) mmc_mk_box2(0,closure3_SimCodeUtil_isFmiUnknown,tmpMeta33))) {
                  tmp32--;
                  break;
                }
              }
              if (tmp32 == 0) {
                __omcQ_24tmpVar12 = _fmiUnknown;
                *tmp30 = mmc_mk_cons(__omcQ_24tmpVar12,0);
                tmp30 = &MMC_CDR(*tmp30);
              } else if (tmp32 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp30 = mmc_mk_nil();
            tmpMeta29 = __omcQ_24tmpVar13;
          }
          _derivatives = tmpMeta29;

          _varsA = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 4))), boxvar_SimCodeUtil_isOutputSimVar);

          _varsB = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 6))), boxvar_SimCodeUtil_isOutputSimVar);

          _varsC = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 7))), boxvar_SimCodeUtil_isOutputSimVar);

          _varsD = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 16))), boxvar_SimCodeUtil_isOutputSimVar);

          _allOutputVars = listAppend(listAppend(_varsA, _varsB), listAppend(_varsC, _varsD));

          {
            modelica_metatype __omcQ_24tmpVar15;
            modelica_metatype* tmp35;
            modelica_metatype tmpMeta36;
            modelica_metatype __omcQ_24tmpVar14;
            modelica_integer tmp37;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _allOutputVars;
            tmpMeta36 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar15 = tmpMeta36; /* defaultValue */
            tmp35 = &__omcQ_24tmpVar15;
            while(1) {
              tmp37 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp37--;
              }
              if (tmp37 == 0) {
                __omcQ_24tmpVar14 = mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v));
                *tmp35 = mmc_mk_cons(__omcQ_24tmpVar14,0);
                tmp35 = &MMC_CDR(*tmp35);
              } else if (tmp37 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp35 = mmc_mk_nil();
            tmpMeta34 = __omcQ_24tmpVar15;
          }
          _intLst = tmpMeta34;

          {
            modelica_metatype __omcQ_24tmpVar17;
            modelica_metatype* tmp39;
            modelica_metatype tmpMeta40;
            modelica_metatype __omcQ_24tmpVar16;
            modelica_integer tmp41;
            modelica_metatype _fmiUnknown_loopVar = 0;
            modelica_metatype tmpMeta42;
            modelica_metatype _fmiUnknown;
            _fmiUnknown_loopVar = _allUnknowns;
            tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar17 = tmpMeta40; /* defaultValue */
            tmp39 = &__omcQ_24tmpVar17;
            while(1) {
              tmp41 = 1;
              while (!listEmpty(_fmiUnknown_loopVar)) {
                _fmiUnknown = MMC_CAR(_fmiUnknown_loopVar);
                _fmiUnknown_loopVar = MMC_CDR(_fmiUnknown_loopVar);
                tmpMeta42 = mmc_mk_box1(0, _fmiUnknown);
                if (omc_List_any(threadData, _intLst, (modelica_fnptr) mmc_mk_box2(0,closure4_SimCodeUtil_isFmiUnknown,tmpMeta42))) {
                  tmp41--;
                  break;
                }
              }
              if (tmp41 == 0) {
                __omcQ_24tmpVar16 = _fmiUnknown;
                *tmp39 = mmc_mk_cons(__omcQ_24tmpVar16,0);
                tmp39 = &MMC_CDR(*tmp39);
              } else if (tmp41 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp39 = mmc_mk_nil();
            tmpMeta38 = __omcQ_24tmpVar17;
          }
          _outputs = tmpMeta38;

          _clockedStates = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 4))), boxvar_SimCodeUtil_isClockedStateSimVar);

          {
            modelica_metatype __omcQ_24tmpVar19;
            modelica_metatype* tmp44;
            modelica_metatype tmpMeta45;
            modelica_metatype __omcQ_24tmpVar18;
            modelica_integer tmp46;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _clockedStates;
            tmpMeta45 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar19 = tmpMeta45; /* defaultValue */
            tmp44 = &__omcQ_24tmpVar19;
            while(1) {
              tmp46 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp46--;
              }
              if (tmp46 == 0) {
                __omcQ_24tmpVar18 = mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v));
                *tmp44 = mmc_mk_cons(__omcQ_24tmpVar18,0);
                tmp44 = &MMC_CDR(*tmp44);
              } else if (tmp46 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp44 = mmc_mk_nil();
            tmpMeta43 = __omcQ_24tmpVar19;
          }
          _intLst = tmpMeta43;

          {
            modelica_metatype __omcQ_24tmpVar21;
            modelica_metatype* tmp48;
            modelica_metatype tmpMeta49;
            modelica_metatype __omcQ_24tmpVar20;
            modelica_integer tmp50;
            modelica_metatype _fmiUnknown_loopVar = 0;
            modelica_metatype tmpMeta51;
            modelica_metatype _fmiUnknown;
            _fmiUnknown_loopVar = _allUnknowns;
            tmpMeta49 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar21 = tmpMeta49; /* defaultValue */
            tmp48 = &__omcQ_24tmpVar21;
            while(1) {
              tmp50 = 1;
              while (!listEmpty(_fmiUnknown_loopVar)) {
                _fmiUnknown = MMC_CAR(_fmiUnknown_loopVar);
                _fmiUnknown_loopVar = MMC_CDR(_fmiUnknown_loopVar);
                tmpMeta51 = mmc_mk_box1(0, _fmiUnknown);
                if (omc_List_any(threadData, _intLst, (modelica_fnptr) mmc_mk_box2(0,closure5_SimCodeUtil_isFmiUnknown,tmpMeta51))) {
                  tmp50--;
                  break;
                }
              }
              if (tmp50 == 0) {
                __omcQ_24tmpVar20 = _fmiUnknown;
                *tmp48 = mmc_mk_cons(__omcQ_24tmpVar20,0);
                tmp48 = &MMC_CDR(*tmp48);
              } else if (tmp50 == 1) {
                break;
              } else {
                goto goto_8;
              }
            }
            *tmp48 = mmc_mk_nil();
            tmpMeta47 = __omcQ_24tmpVar21;
          }
          _discreteStates = tmpMeta47;

          if((!omc_SimCodeUtil_checkForEmptyBDAE(threadData, _optcontPartDer)))
          {
            tmpMeta53 = mmc_mk_box4(0, _optcontPartDer, _spPattern, _spColors, _nlPattern);
            tmpMeta52 = mmc_mk_cons(tmpMeta53, MMC_REFSTRUCTLIT(mmc_nil));
            _contPartDer = tmpMeta52;

            /* Pattern-matching tuple assignment */
            tmpMeta55 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta56 = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _contPartDer, _crefSimVarHT, _uniqueEqIndex, _OMC_LIT144, tmpMeta55, &tmp54);
            if (listEmpty(tmpMeta56)) goto goto_8;
            tmpMeta57 = MMC_CAR(tmpMeta56);
            tmpMeta58 = MMC_CDR(tmpMeta56);
            if (!listEmpty(tmpMeta58)) goto goto_8;
            _contSimJac = tmpMeta57;
            _uniqueEqIndex = tmp54;

            /* Pattern-matching tuple assignment */
            tmpMeta61 = mmc_mk_cons(_contSimJac, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta62 = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta61, _inModelInfo, &tmpMeta59, &tmpMeta60);
            if (listEmpty(tmpMeta62)) goto goto_8;
            tmpMeta63 = MMC_CAR(tmpMeta62);
            tmpMeta64 = MMC_CDR(tmpMeta62);
            if (!listEmpty(tmpMeta64)) goto goto_8;
            _contSimJac = tmpMeta63;
            _outModelInfo = tmpMeta59;
            _symJacs = tmpMeta60;

            _contPartSimDer = mmc_mk_some(_contSimJac);

            tmpMeta65 = mmc_mk_cons(omc_SimCodeUtil_rewriteJacPartIdx(threadData, _contSimJac, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 17))))), MMC_REFSTRUCTLIT(mmc_nil));
            _symJacFMI = tmpMeta65;
          }
          else
          {
            _contPartSimDer = mmc_mk_none();
          }

          tmpMeta66 = MMC_REFSTRUCTLIT(mmc_nil);
          _tmpInitialUnknowns = tmpMeta66;

          _tmpInitialUnknowns = omc_List_filterCons(threadData, _allOutputVars, boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar, _tmpInitialUnknowns);

          _allParamVars = omc_SimCodeUtil_getAllParamSimVars(threadData, _inModelInfo);

          _tmpInitialUnknowns = omc_List_filterCons(threadData, _allParamVars, boxvar_SimCodeUtil_isCausalityCalculatedParameterSimVar, _tmpInitialUnknowns);

          _tmpInitialUnknowns = omc_List_filterCons(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 2))), boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar, _tmpInitialUnknowns);

          _tmpInitialUnknowns = omc_List_filterCons(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 3))), boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar, _tmpInitialUnknowns);

          _tmpInitialUnknowns = listReverseInPlace(_tmpInitialUnknowns);

          if((!listEmpty(_tmpInitialUnknowns)))
          {
            _allInitialUnknowns = omc_SimCodeUtil_getFmiInitialUnknowns(threadData, _inInitDAE, _inSimDAE, _crefSimVarHT, _tmpInitialUnknowns ,&_fmiDerInit ,&_sortedUnknownCrefs ,&_sortedknownCrefs);
          }
          else
          {
            tmpMeta67 = MMC_REFSTRUCTLIT(mmc_nil);
            _allInitialUnknowns = tmpMeta67;
          }

          if((!listEmpty(_fmiDerInit)))
          {
            /* Pattern-matching assignment */
            tmpMeta68 = omc_SymbolicJacobian_getJacobianMatrixbyName(threadData, _fmiDerInit, _OMC_LIT145);
            if (optionNone(tmpMeta68)) goto goto_8;
            tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 1));
            tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 1));
            tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 2));
            tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 2));
            tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 3));
            tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 1));
            tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 2));
            tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 3));
            tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 4));
            _optinitialPartDer = tmpMeta70;
            _spPattern1 = tmpMeta71;
            _spTA1 = tmpMeta72;
            _diffCrefsA1 = tmpMeta74;
            _diffedCrefsA1 = tmpMeta75;
            _spColors1 = tmpMeta76;
            _nlPattern = tmpMeta77;

            if((!omc_SimCodeUtil_checkForEmptyBDAE(threadData, _optinitialPartDer)))
            {
              tmpMeta79 = mmc_mk_box4(0, _optinitialPartDer, _spPattern1, _spColors1, _nlPattern);
              tmpMeta78 = mmc_mk_cons(tmpMeta79, MMC_REFSTRUCTLIT(mmc_nil));
              _initPartDer = tmpMeta78;

              /* Pattern-matching tuple assignment */
              tmpMeta81 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta82 = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _initPartDer, _crefSimVarHT, _uniqueEqIndex, _OMC_LIT146, tmpMeta81, &tmp80);
              if (listEmpty(tmpMeta82)) goto goto_8;
              tmpMeta83 = MMC_CAR(tmpMeta82);
              tmpMeta84 = MMC_CDR(tmpMeta82);
              if (!listEmpty(tmpMeta84)) goto goto_8;
              _initSimJac = tmpMeta83;
              _uniqueEqIndex = tmp80;

              /* Pattern-matching tuple assignment */
              tmpMeta86 = mmc_mk_cons(_initSimJac, MMC_REFSTRUCTLIT(mmc_nil));
              tmpMeta87 = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta86, _inModelInfo, NULL, &tmpMeta85);
              if (listEmpty(tmpMeta87)) goto goto_8;
              tmpMeta88 = MMC_CAR(tmpMeta87);
              tmpMeta89 = MMC_CDR(tmpMeta87);
              if (!listEmpty(tmpMeta89)) goto goto_8;
              _initSimJac = tmpMeta88;
              _symJacsInit = tmpMeta85;

              _initPartSimDer = mmc_mk_some(_initSimJac);

              tmpMeta90 = mmc_mk_cons(omc_SimCodeUtil_rewriteJacPartIdx(threadData, _initSimJac, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 17))))), MMC_REFSTRUCTLIT(mmc_nil));
              _symJacFMIINIT = tmpMeta90;

              _symJacFMI = listAppend(_symJacFMIINIT, _symJacFMI);

              _symJacs = listAppend(_symJacsInit, _symJacs);
            }
          }

          tmpMeta91 = mmc_mk_box2(3, &SimCode_FmiOutputs_FMIOUTPUTS__desc, _outputs);
          tmpMeta92 = mmc_mk_box2(3, &SimCode_FmiDerivatives_FMIDERIVATIVES__desc, _derivatives);
          tmpMeta93 = mmc_mk_box2(3, &SimCode_FmiDiscreteStates_FMIDISCRETESTATES__desc, _discreteStates);
          tmpMeta94 = mmc_mk_box4(3, &SimCode_FmiInitialUnknowns_FMIINITIALUNKNOWNS__desc, _allInitialUnknowns, _sortedUnknownCrefs, _sortedknownCrefs);
          tmpMeta95 = mmc_mk_box7(3, &SimCode_FmiModelStructure_FMIMODELSTRUCTURE__desc, tmpMeta91, tmpMeta92, _contPartSimDer, _initPartSimDer, tmpMeta93, tmpMeta94);
          _outFmiModelStructure = mmc_mk_some(tmpMeta95);
          goto tmp9_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp98;
              int tmp99;
              tmp98 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp97_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp98 < 2; tmp98++) {
                switch (MMC_SWITCH_CAST(tmp98)) {
                case 0: {
                  modelica_metatype tmpMeta100;
                  modelica_metatype tmpMeta107;
                  modelica_metatype tmpMeta114;
                  modelica_metatype tmpMeta121;
                  modelica_metatype tmpMeta122;
                  modelica_metatype tmpMeta129;
                  modelica_metatype tmpMeta130;
                  modelica_metatype tmpMeta131;
                  modelica_metatype tmpMeta132;
                  modelica_metatype tmpMeta133;
                  modelica_metatype tmpMeta134;
                  modelica_metatype tmpMeta135;
                  /* Pattern matching succeeded */
                  {
                    modelica_metatype __omcQ_24tmpVar23;
                    modelica_metatype* tmp101;
                    modelica_metatype tmpMeta102;
                    modelica_metatype tmpMeta103;
                    modelica_metatype tmpMeta104;
                    modelica_metatype tmpMeta105;
                    modelica_metatype __omcQ_24tmpVar22;
                    modelica_integer tmp106;
                    modelica_metatype _v_loopVar = 0;
                    modelica_metatype _v;
                    _v_loopVar = omc_SimCodeUtil_getScalarVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 3))));
                    tmpMeta102 = MMC_REFSTRUCTLIT(mmc_nil);
                    __omcQ_24tmpVar23 = tmpMeta102; /* defaultValue */
                    tmp101 = &__omcQ_24tmpVar23;
                    while(1) {
                      tmp106 = 1;
                      if (!listEmpty(_v_loopVar)) {
                        _v = MMC_CAR(_v_loopVar);
                        _v_loopVar = MMC_CDR(_v_loopVar);
                        tmp106--;
                      }
                      if (tmp106 == 0) {
                        tmpMeta103 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta104 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta105 = mmc_mk_box4(3, &SimCode_FmiUnknown_FMIUNKNOWN__desc, mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v)), tmpMeta103, tmpMeta104);
                        __omcQ_24tmpVar22 = tmpMeta105;
                        *tmp101 = mmc_mk_cons(__omcQ_24tmpVar22,0);
                        tmp101 = &MMC_CDR(*tmp101);
                      } else if (tmp106 == 1) {
                        break;
                      } else {
                        goto goto_96;
                      }
                    }
                    *tmp101 = mmc_mk_nil();
                    tmpMeta100 = __omcQ_24tmpVar23;
                  }
                  _derivatives = tmpMeta100;

                  _varsA = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 4))), boxvar_SimCodeUtil_isOutputSimVar);

                  {
                    modelica_metatype __omcQ_24tmpVar25;
                    modelica_metatype* tmp108;
                    modelica_metatype tmpMeta109;
                    modelica_metatype tmpMeta110;
                    modelica_metatype tmpMeta111;
                    modelica_metatype tmpMeta112;
                    modelica_metatype __omcQ_24tmpVar24;
                    modelica_integer tmp113;
                    modelica_metatype _v_loopVar = 0;
                    modelica_metatype _v;
                    _v_loopVar = omc_SimCodeUtil_getScalarVars(threadData, _varsA);
                    tmpMeta109 = MMC_REFSTRUCTLIT(mmc_nil);
                    __omcQ_24tmpVar25 = tmpMeta109; /* defaultValue */
                    tmp108 = &__omcQ_24tmpVar25;
                    while(1) {
                      tmp113 = 1;
                      if (!listEmpty(_v_loopVar)) {
                        _v = MMC_CAR(_v_loopVar);
                        _v_loopVar = MMC_CDR(_v_loopVar);
                        tmp113--;
                      }
                      if (tmp113 == 0) {
                        tmpMeta110 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta111 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta112 = mmc_mk_box4(3, &SimCode_FmiUnknown_FMIUNKNOWN__desc, mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v)), tmpMeta110, tmpMeta111);
                        __omcQ_24tmpVar24 = tmpMeta112;
                        *tmp108 = mmc_mk_cons(__omcQ_24tmpVar24,0);
                        tmp108 = &MMC_CDR(*tmp108);
                      } else if (tmp113 == 1) {
                        break;
                      } else {
                        goto goto_96;
                      }
                    }
                    *tmp108 = mmc_mk_nil();
                    tmpMeta107 = __omcQ_24tmpVar25;
                  }
                  _outputs = tmpMeta107;

                  _clockedStates = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 4))), boxvar_SimCodeUtil_isClockedStateSimVar);

                  {
                    modelica_metatype __omcQ_24tmpVar27;
                    modelica_metatype* tmp115;
                    modelica_metatype tmpMeta116;
                    modelica_metatype tmpMeta117;
                    modelica_metatype tmpMeta118;
                    modelica_metatype tmpMeta119;
                    modelica_metatype __omcQ_24tmpVar26;
                    modelica_integer tmp120;
                    modelica_metatype _v_loopVar = 0;
                    modelica_metatype _v;
                    _v_loopVar = omc_SimCodeUtil_getScalarVars(threadData, _clockedStates);
                    tmpMeta116 = MMC_REFSTRUCTLIT(mmc_nil);
                    __omcQ_24tmpVar27 = tmpMeta116; /* defaultValue */
                    tmp115 = &__omcQ_24tmpVar27;
                    while(1) {
                      tmp120 = 1;
                      if (!listEmpty(_v_loopVar)) {
                        _v = MMC_CAR(_v_loopVar);
                        _v_loopVar = MMC_CDR(_v_loopVar);
                        tmp120--;
                      }
                      if (tmp120 == 0) {
                        tmpMeta117 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta118 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta119 = mmc_mk_box4(3, &SimCode_FmiUnknown_FMIUNKNOWN__desc, mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v)), tmpMeta117, tmpMeta118);
                        __omcQ_24tmpVar26 = tmpMeta119;
                        *tmp115 = mmc_mk_cons(__omcQ_24tmpVar26,0);
                        tmp115 = &MMC_CDR(*tmp115);
                      } else if (tmp120 == 1) {
                        break;
                      } else {
                        goto goto_96;
                      }
                    }
                    *tmp115 = mmc_mk_nil();
                    tmpMeta114 = __omcQ_24tmpVar27;
                  }
                  _discreteStates = tmpMeta114;

                  _varsA = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 4))), boxvar_SimCodeUtil_isOutputSimVar);

                  _varsB = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 6))), boxvar_SimCodeUtil_isOutputSimVar);

                  _varsC = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 7))), boxvar_SimCodeUtil_isOutputSimVar);

                  _varsD = omc_List_filterOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 16))), boxvar_SimCodeUtil_isOutputSimVar);

                  _allOutputVars = omc_SimCodeUtil_getScalarVars(threadData, listAppend(listAppend(_varsA, _varsB), listAppend(_varsC, _varsD)));

                  tmpMeta121 = MMC_REFSTRUCTLIT(mmc_nil);
                  _tmpInitialUnknowns = tmpMeta121;

                  _tmpInitialUnknowns = omc_List_filterCons(threadData, _allOutputVars, boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar, _tmpInitialUnknowns);

                  _tmpInitialUnknowns = omc_List_filterCons(threadData, omc_SimCodeUtil_getScalarVars(threadData, omc_SimCodeUtil_getAllParamSimVars(threadData, _inModelInfo)), boxvar_SimCodeUtil_isCausalityCalculatedParameterSimVar, _tmpInitialUnknowns);

                  _tmpInitialUnknowns = omc_List_filterCons(threadData, omc_SimCodeUtil_getScalarVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 2)))), boxvar_SimCodeUtil_isStateInitialUnknownSimVar, _tmpInitialUnknowns);

                  _tmpInitialUnknowns = omc_List_filterCons(threadData, omc_SimCodeUtil_getScalarVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inModelInfo), 11)))), 3)))), boxvar_SimCodeUtil_isInitialApproxOrCalculatedSimVar, _tmpInitialUnknowns);

                  _tmpInitialUnknowns = listReverseInPlace(_tmpInitialUnknowns);

                  {
                    modelica_metatype __omcQ_24tmpVar29;
                    modelica_metatype* tmp123;
                    modelica_metatype tmpMeta124;
                    modelica_metatype tmpMeta125;
                    modelica_metatype tmpMeta126;
                    modelica_metatype tmpMeta127;
                    modelica_metatype __omcQ_24tmpVar28;
                    modelica_integer tmp128;
                    modelica_metatype _v_loopVar = 0;
                    modelica_metatype _v;
                    _v_loopVar = _tmpInitialUnknowns;
                    tmpMeta124 = MMC_REFSTRUCTLIT(mmc_nil);
                    __omcQ_24tmpVar29 = tmpMeta124; /* defaultValue */
                    tmp123 = &__omcQ_24tmpVar29;
                    while(1) {
                      tmp128 = 1;
                      if (!listEmpty(_v_loopVar)) {
                        _v = MMC_CAR(_v_loopVar);
                        _v_loopVar = MMC_CDR(_v_loopVar);
                        tmp128--;
                      }
                      if (tmp128 == 0) {
                        tmpMeta125 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta126 = MMC_REFSTRUCTLIT(mmc_nil);
                        tmpMeta127 = mmc_mk_box4(3, &SimCode_FmiUnknown_FMIUNKNOWN__desc, mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _v)), tmpMeta125, tmpMeta126);
                        __omcQ_24tmpVar28 = tmpMeta127;
                        *tmp123 = mmc_mk_cons(__omcQ_24tmpVar28,0);
                        tmp123 = &MMC_CDR(*tmp123);
                      } else if (tmp128 == 1) {
                        break;
                      } else {
                        goto goto_96;
                      }
                    }
                    *tmp123 = mmc_mk_nil();
                    tmpMeta122 = __omcQ_24tmpVar29;
                  }
                  _allInitialUnknowns = tmpMeta122;

                  _contPartSimDer = mmc_mk_none();

                  _initPartSimDer = mmc_mk_none();

                  tmpMeta129 = mmc_mk_box2(3, &SimCode_FmiOutputs_FMIOUTPUTS__desc, _outputs);
                  tmpMeta130 = mmc_mk_box2(3, &SimCode_FmiDerivatives_FMIDERIVATIVES__desc, _derivatives);
                  tmpMeta131 = mmc_mk_box2(3, &SimCode_FmiDiscreteStates_FMIDISCRETESTATES__desc, _discreteStates);
                  tmpMeta132 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta133 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta134 = mmc_mk_box4(3, &SimCode_FmiInitialUnknowns_FMIINITIALUNKNOWNS__desc, _allInitialUnknowns, tmpMeta132, tmpMeta133);
                  tmpMeta135 = mmc_mk_box7(3, &SimCode_FmiModelStructure_FMIMODELSTRUCTURE__desc, tmpMeta129, tmpMeta130, _contPartSimDer, _initPartSimDer, tmpMeta131, tmpMeta134);
                  _outFmiModelStructure = mmc_mk_some(tmpMeta135);
                  goto tmp97_done;
                }
                case 1: {
                  /* Pattern matching succeeded */
                  omc_Error_addInternalError(threadData, _OMC_LIT147, _OMC_LIT148);

                  goto goto_96;
                  goto tmp97_done;
                }
                }
                goto tmp97_end;
                tmp97_end: ;
              }
              goto goto_96;
              tmp97_done:
              (void)tmp98;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp97_done2;
              goto_96:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp98 < 2) {
                goto tmp97_top;
              }
              goto goto_8;
              tmp97_done2:;
            }
          }
          ;
          goto tmp9_done;
        }
        }
        goto tmp9_end;
        tmp9_end: ;
      }
      goto goto_8;
      tmp9_done:
      (void)tmp10;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp9_done2;
      goto_8:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp10 < 2) {
        goto tmp9_top;
      }
      MMC_THROW_INTERNAL();
      tmp9_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_outFmiModelStructure) { *out_outFmiModelStructure = _outFmiModelStructure; }
  if (out_outModelInfo) { *out_outModelInfo = _outModelInfo; }
  if (out_symJacs) { *out_symJacs = _symJacs; }
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _symJacFMI;
}
modelica_metatype boxptr_SimCodeUtil_createFMIModelStructure(threadData_t *threadData, modelica_metatype _inSymjacs, modelica_metatype _inModelInfo, modelica_metatype _inUniqueEqIndex, modelica_metatype _inInitDAE, modelica_metatype _inSimDAE, modelica_metatype *out_outFmiModelStructure, modelica_metatype *out_outModelInfo, modelica_metatype *out_symJacs, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _symJacFMI = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_inUniqueEqIndex);
  _symJacFMI = omc_SimCodeUtil_createFMIModelStructure(threadData, _inSymjacs, _inModelInfo, tmp1, _inInitDAE, _inSimDAE, out_outFmiModelStructure, out_outModelInfo, out_symJacs, &_uniqueEqIndex);
  /* skip box _symJacFMI; list<SimCode.JacobianMatrix> */
  /* skip box _outFmiModelStructure; Option<SimCode.FmiModelStructure> */
  /* skip box _outModelInfo; SimCode.ModelInfo */
  /* skip box _symJacs; list<SimCode.JacobianMatrix> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _symJacFMI;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createFMISimulationFlags(threadData_t *threadData, modelica_boolean _printWarning)
{
  modelica_metatype _fmiSimulationFlags = NULL;
  modelica_metatype _fmiFlagsList = NULL;
  modelica_string _pathToFile = NULL;
  modelica_string _msg = NULL;
  modelica_string _tmpName = NULL;
  modelica_string _tmpValue = NULL;
  modelica_metatype _tmpSplitted = NULL;
  modelica_metatype _nameValueTuples = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _fmiSimulationFlags has no default value.
  // _fmiFlagsList has no default value.
  // _pathToFile has no default value.
  // _msg has no default value.
  // _tmpName has no default value.
  // _tmpValue has no default value.
  // _tmpSplitted has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _nameValueTuples = tmpMeta1;
  _fmiFlagsList = omc_Flags_getConfigStringList(threadData, _OMC_LIT153);

  if(listEmpty(_fmiFlagsList))
  {
    _fmiSimulationFlags = mmc_mk_none();
  }
  else
  {
    if(((listLength(_fmiFlagsList) == ((modelica_integer) 1)) && (stringEqual(listHead(_fmiFlagsList), _OMC_LIT172))))
    {
      _fmiSimulationFlags = mmc_mk_none();
    }
    else
    {
      if(((listLength(_fmiFlagsList) == ((modelica_integer) 1)) && (stringEqual(listHead(_fmiFlagsList), _OMC_LIT171))))
      {
        _fmiSimulationFlags = _OMC_LIT161;
      }
      else
      {
        if(((listLength(_fmiFlagsList) == ((modelica_integer) 1)) && (stringEqual(omc_List_last(threadData, omc_Util_stringSplitAtChar(threadData, listHead(_fmiFlagsList), _OMC_LIT169)), _OMC_LIT170))))
        {
          _pathToFile = listHead(_fmiFlagsList);

          if(omc_System_regularFileExists(threadData, _pathToFile))
          {
            tmpMeta2 = mmc_mk_box2(4, &SimCode_FmiSimulationFlags_FMI__SIMULATION__FLAGS__FILE__desc, _pathToFile);
            _fmiSimulationFlags = mmc_mk_some(tmpMeta2);

            goto _return;
          }
          else
          {
            if(omc_System_regularFileExists(threadData, omc_Util_absoluteOrRelative(threadData, _pathToFile)))
            {
              tmpMeta3 = mmc_mk_box2(4, &SimCode_FmiSimulationFlags_FMI__SIMULATION__FLAGS__FILE__desc, omc_Util_absoluteOrRelative(threadData, _pathToFile));
              _fmiSimulationFlags = mmc_mk_some(tmpMeta3);

              goto _return;
            }
            else
            {
              if(_printWarning)
              {
                tmpMeta4 = stringAppend(_OMC_LIT166,_pathToFile);
                tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT167);
                tmpMeta6 = stringAppend(tmpMeta5,_pathToFile);
                tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT168);
                _msg = tmpMeta7;

                omc_Error_addCompilerWarning(threadData, _msg);
              }

              _fmiSimulationFlags = _OMC_LIT161;

              goto _return;
            }
          }
        }
        else
        {
          {
            modelica_metatype _flag;
            for (tmpMeta8 = _fmiFlagsList; !listEmpty(tmpMeta8); tmpMeta8=MMC_CDR(tmpMeta8))
            {
              _flag = MMC_CAR(tmpMeta8);
              _tmpSplitted = omc_Util_stringSplitAtChar(threadData, _flag, _OMC_LIT154);

              if((!(listLength(_tmpSplitted) == ((modelica_integer) 2))))
              {
                if(_printWarning)
                {
                  tmpMeta9 = stringAppend(_OMC_LIT155,_flag);
                  tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT156);
                  _msg = tmpMeta10;

                  omc_Error_addCompilerWarning(threadData, _msg);
                }

                _fmiSimulationFlags = _OMC_LIT161;

                goto _return;
              }

              /* Pattern-matching assignment */
              tmpMeta11 = _tmpSplitted;
              if (listEmpty(tmpMeta11)) MMC_THROW_INTERNAL();
              tmpMeta12 = MMC_CAR(tmpMeta11);
              tmpMeta13 = MMC_CDR(tmpMeta11);
              if (listEmpty(tmpMeta13)) MMC_THROW_INTERNAL();
              tmpMeta14 = MMC_CAR(tmpMeta13);
              tmpMeta15 = MMC_CDR(tmpMeta13);
              if (!listEmpty(tmpMeta15)) MMC_THROW_INTERNAL();
              _tmpName = tmpMeta12;
              _tmpValue = tmpMeta14;

              if((stringEqual(_tmpName, _OMC_LIT35)))
              {
                if(((!(stringEqual(_tmpValue, _OMC_LIT157))) && (!(stringEqual(_tmpValue, _OMC_LIT36)))))
                {
                  if(_printWarning)
                  {
                    tmpMeta16 = stringAppend(_OMC_LIT164,_tmpValue);
                    tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT165);
                    _msg = tmpMeta17;

                    omc_Error_addCompilerWarning(threadData, _msg);
                  }
                }
              }
              else
              {
                if(_printWarning)
                {
                  tmpMeta18 = stringAppend(_OMC_LIT162,_tmpName);
                  tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT163);
                  _msg = tmpMeta19;

                  omc_Error_addCompilerWarning(threadData, _msg);
                }
              }

              tmpMeta21 = mmc_mk_box2(0, _tmpName, _tmpValue);
              tmpMeta20 = mmc_mk_cons(tmpMeta21, _nameValueTuples);
              _nameValueTuples = tmpMeta20;
            }
          }

          _nameValueTuples = listReverseInPlace(_nameValueTuples);

          tmpMeta23 = mmc_mk_box2(3, &SimCode_FmiSimulationFlags_FMI__SIMULATION__FLAGS__desc, _nameValueTuples);
          _fmiSimulationFlags = mmc_mk_some(tmpMeta23);
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _fmiSimulationFlags;
}
modelica_metatype boxptr_SimCodeUtil_createFMISimulationFlags(threadData_t *threadData, modelica_metatype _printWarning)
{
  modelica_integer tmp1;
  modelica_metatype _fmiSimulationFlags = NULL;
  tmp1 = mmc_unbox_integer(_printWarning);
  _fmiSimulationFlags = omc_SimCodeUtil_createFMISimulationFlags(threadData, tmp1);
  /* skip box _fmiSimulationFlags; Option<SimCode.FmiSimulationFlags> */
  return _fmiSimulationFlags;
}

DLLDirection
modelica_string omc_SimCodeUtil_derivativeMatrixString(threadData_t *threadData, modelica_metatype _matrix)
{
  modelica_string _s = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _s = _OMC_LIT31;
  {
    modelica_metatype _col;
    for (tmpMeta1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_matrix), 2))); !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _col = MMC_CAR(tmpMeta1);
      tmpMeta2 = stringAppend(_s,omc_SimCodeUtil_omsiFuncEqnString(threadData, _col));
      _s = tmpMeta2;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _s;
}

DLLDirection
modelica_string omc_SimCodeUtil_omsiFuncEqnString(threadData_t *threadData, modelica_metatype _omsiFunc)
{
  modelica_string _s = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _s = _OMC_LIT31;
  {
    modelica_metatype _eqs;
    for (tmpMeta1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 2))); !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqs = MMC_CAR(tmpMeta1);
      tmpMeta2 = stringAppend(_s,omc_SimCodeUtil_simEqSystemString(threadData, _eqs));
      tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT48);
      _s = tmpMeta3;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _s;
}

DLLDirection
void omc_SimCodeUtil_dumpOMSIFunc(threadData_t *threadData, modelica_metatype _omsiFunc, modelica_string _head)
{
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_head,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta1),stdout);

  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_string tmp6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_string tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT173),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT174),stdout);

          omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 2))), _OMC_LIT48);

          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 3))), _OMC_LIT175);

          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 5))), _OMC_LIT176);

          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 4))), _OMC_LIT177);

          tmp6 = modelica_integer_to_modelica_string(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 6)))), ((modelica_integer) 0), 1 /* true */);
          tmpMeta7 = stringAppend(_OMC_LIT178,tmp6);
          tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta8),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT179),stdout);

          tmp9 = modelica_integer_to_modelica_string(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunc), 8)))), ((modelica_integer) 0), 1 /* true */);
          tmpMeta10 = stringAppend(_OMC_LIT180,tmp9);
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta11),stdout);
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT181),stdout);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
void omc_SimCodeUtil_dumpOMSIData(threadData_t *threadData, modelica_metatype _omsiData, modelica_string _head)
{
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_head,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta1),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT182),stdout);

  omc_SimCodeUtil_dumpOMSIFunc(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiData), 2))), _OMC_LIT31);

  fputs(MMC_STRINGDATA(_OMC_LIT174),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT183),stdout);

  omc_SimCodeUtil_dumpOMSIFunc(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiData), 3))), _OMC_LIT31);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpVarMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_integer _noIn, modelica_integer *out_noOut)
{
  modelica_string _s = NULL;
  modelica_integer _noOut;
  modelica_integer _i1;
  modelica_integer _i2;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _s has no default value.
  // _noOut has no default value.
  // _i1 has no default value.
  // _i2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _i1 = tmp3  /* pattern as ty=Integer */;
  _i2 = tmp5  /* pattern as ty=Integer */;

  tmpMeta6 = stringAppend(intString(_noIn),_OMC_LIT184);
  tmpMeta7 = stringAppend(tmpMeta6,intString(_i2));
  tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT185);
  tmpMeta9 = stringAppend(tmpMeta8,intString(_i1));
  _s = tmpMeta9;

  _noOut = ((modelica_integer) 1) + _noIn;
  _return: OMC_LABEL_UNUSED
  if (out_noOut) { *out_noOut = _noOut; }
  return _s;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpVarMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_metatype _noIn, modelica_metatype *out_noOut)
{
  modelica_integer tmp1;
  modelica_integer _noOut;
  modelica_string _s = NULL;
  tmp1 = mmc_unbox_integer(_noIn);
  _s = omc_SimCodeUtil_dumpVarMappingTuple(threadData, _tpl, tmp1, &_noOut);
  /* skip box _s; String */
  if (out_noOut) { *out_noOut = mmc_mk_icon(_noOut); }
  return _s;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpEqMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_integer _noIn, modelica_integer *out_noOut)
{
  modelica_string _s = NULL;
  modelica_integer _noOut;
  modelica_integer _i1;
  modelica_metatype _lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _s has no default value.
  // _noOut has no default value.
  // _i1 has no default value.
  // _lst has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _i1 = tmp3  /* pattern as ty=Integer */;
  _lst = tmpMeta4;

  tmpMeta5 = stringAppend(intString(_noIn),_OMC_LIT184);
  tmpMeta6 = stringAppend(tmpMeta5,stringDelimitList(omc_List_map(threadData, _lst, boxvar_intString), _OMC_LIT186));
  tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT185);
  tmpMeta8 = stringAppend(tmpMeta7,intString(_i1));
  _s = tmpMeta8;

  _noOut = ((modelica_integer) 1) + _noIn;
  _return: OMC_LABEL_UNUSED
  if (out_noOut) { *out_noOut = _noOut; }
  return _s;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpEqMappingTuple(threadData_t *threadData, modelica_metatype _tpl, modelica_metatype _noIn, modelica_metatype *out_noOut)
{
  modelica_integer tmp1;
  modelica_integer _noOut;
  modelica_string _s = NULL;
  tmp1 = mmc_unbox_integer(_noIn);
  _s = omc_SimCodeUtil_dumpEqMappingTuple(threadData, _tpl, tmp1, &_noOut);
  /* skip box _s; String */
  if (out_noOut) { *out_noOut = mmc_mk_icon(_noOut); }
  return _s;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpVarMapping(threadData_t *threadData, modelica_metatype _varMapping)
{
  modelica_metatype _lst = NULL;
  modelica_metatype _s = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lst has no default value.
  // _s has no default value.
  _lst = listReverse(_varMapping);

  fputs(MMC_STRINGDATA(_OMC_LIT187),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT188),stdout);

  _s = omc_List_mapFold(threadData, _lst, boxvar_SimCodeUtil_dumpVarMappingTuple, mmc_mk_integer(((modelica_integer) 1)), NULL);

  fputs(MMC_STRINGDATA(stringDelimitList(_s, _OMC_LIT48)),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT189),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpEqMapping(threadData_t *threadData, modelica_metatype _eqMapping)
{
  modelica_metatype _lst = NULL;
  modelica_metatype _s = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lst has no default value.
  // _s has no default value.
  _lst = listReverse(_eqMapping);

  fputs(MMC_STRINGDATA(_OMC_LIT187),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT190),stdout);

  _s = omc_List_mapFold(threadData, _lst, boxvar_SimCodeUtil_dumpEqMappingTuple, mmc_mk_integer(((modelica_integer) 1)), NULL);

  fputs(MMC_STRINGDATA(stringDelimitList(_s, _OMC_LIT48)),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT189),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpBackendMapping(threadData_t *threadData, modelica_metatype _mapIn)
{
  modelica_metatype _eqMatch = NULL;
  modelica_metatype _varMatch = NULL;
  modelica_metatype _tree = NULL;
  modelica_metatype _eqMapping = NULL;
  modelica_metatype _varMapping = NULL;
  modelica_metatype _m = NULL;
  modelica_metatype _mt = NULL;
  modelica_metatype _simVarMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqMatch has no default value.
  // _varMatch has no default value.
  // _tree has no default value.
  // _eqMapping has no default value.
  // _varMapping has no default value.
  // _m has no default value.
  // _mt has no default value.
  // _simVarMapping has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _mapIn;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 6));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  _m = tmpMeta2;
  _mt = tmpMeta3;
  _eqMapping = tmpMeta4;
  _varMapping = tmpMeta5;
  _eqMatch = tmpMeta6;
  _varMatch = tmpMeta7;
  _tree = tmpMeta8;
  _simVarMapping = tmpMeta9;

  omc_SimCodeUtil_dumpEqMapping(threadData, _eqMapping);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_dumpIdxScVarMapping0(threadData_t *threadData, modelica_metatype _iVar, modelica_integer _iIdx)
{
  modelica_integer _oIdx;
  modelica_metatype _name = NULL;
  modelica_string _refString = NULL;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oIdx has no default value.
  // _name has no default value.
  // _refString has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _name = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta8 = stringAppend(_OMC_LIT191,intString(_iIdx));
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT192);
          fputs(MMC_STRINGDATA(tmpMeta9),stdout);

          _refString = omc_ComponentReferenceBasics_printComponentRefStr(threadData, _name);

          tmpMeta10 = stringAppend(_refString,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta10),stdout);
          tmp1 = ((modelica_integer) 1) + _iIdx;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1) + _iIdx;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oIdx = tmp1;
  _return: OMC_LABEL_UNUSED
  return _oIdx;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dumpIdxScVarMapping0(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _iIdx)
{
  modelica_integer tmp1;
  modelica_integer _oIdx;
  modelica_metatype out_oIdx;
  tmp1 = mmc_unbox_integer(_iIdx);
  _oIdx = omc_SimCodeUtil_dumpIdxScVarMapping0(threadData, _iVar, tmp1);
  out_oIdx = mmc_mk_icon(_oIdx);
  return out_oIdx;
}

DLLDirection
void omc_SimCodeUtil_dumpIdxScVarMapping(threadData_t *threadData, modelica_metatype _iMapping)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  fputs(MMC_STRINGDATA(_OMC_LIT193),stdout);

  omc_Array_fold(threadData, _iMapping, boxvar_SimCodeUtil_dumpIdxScVarMapping0, mmc_mk_integer(((modelica_integer) 1)));
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4(threadData_t *threadData, modelica_metatype _iEqSystemOpt, modelica_metatype _iResList)
{
  modelica_metatype _oResList = NULL;
  modelica_metatype _eqSys = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oResList has no default value.
  // _eqSys has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iEqSystemOpt;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _eqSys = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_cons(_eqSys, _iResList);
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iResList;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oResList = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oResList;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray)
{
  modelica_metatype _oEqArray = NULL;
  modelica_integer _eqSysIdx;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEqArray has no default value.
  // _eqSysIdx has no default value.
  _eqSysIdx = omc_SimCodeUtil_simEqSystemIndex(threadData, _iEqSystem);

  _oEqArray = arrayUpdate(_iEqArray, _eqSysIdx, mmc_mk_none());
  _return: OMC_LABEL_UNUSED
  return _oEqArray;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray)
{
  modelica_metatype _oEqArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEqArray has no default value.
  _oEqArray = omc_List_fold(threadData, _iEqSystem, boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem3, _iEqArray);
  _return: OMC_LABEL_UNUSED
  return _oEqArray;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iEqArray)
{
  modelica_metatype _oEqArray = NULL;
  modelica_integer _eqSysIdx;
  modelica_metatype _eqSys = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEqArray has no default value.
  // _eqSysIdx has no default value.
  // _eqSys has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iEqSystem;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _eqSysIdx = tmp3  /* pattern as ty=Integer */;
  _eqSys = tmpMeta4;

  _oEqArray = arrayUpdate(_iEqArray, _eqSysIdx, mmc_mk_some(_eqSys));
  _return: OMC_LABEL_UNUSED
  return _oEqArray;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0(threadData_t *threadData, modelica_metatype _iEqSystem, modelica_metatype _iMappingWithHighestIdx)
{
  modelica_metatype _outMappingWithHighestIdx = NULL;
  modelica_integer _index;
  modelica_integer _highestIdx;
  modelica_metatype _allEqIdxMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMappingWithHighestIdx has no default value.
  // _index has no default value.
  // _highestIdx has no default value.
  // _allEqIdxMapping has no default value.
  _index = omc_SimCodeUtil_simEqSystemIndex(threadData, _iEqSystem);

  /* Pattern-matching assignment */
  tmpMeta1 = _iMappingWithHighestIdx;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp4 = mmc_unbox_integer(tmpMeta3);
  _allEqIdxMapping = tmpMeta2;
  _highestIdx = tmp4  /* pattern as ty=Integer */;

  tmpMeta6 = mmc_mk_box2(0, mmc_mk_integer(_index), _iEqSystem);
  tmpMeta5 = mmc_mk_cons(tmpMeta6, _allEqIdxMapping);
  _allEqIdxMapping = tmpMeta5;

  _highestIdx = modelica_integer_max((modelica_integer)(_highestIdx),(modelica_integer)(_index));

  tmpMeta7 = mmc_mk_box2(0, _allEqIdxMapping, mmc_mk_integer(_highestIdx));
  _outMappingWithHighestIdx = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  return _outMappingWithHighestIdx;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getDaeEqsNotPartOfOdeSystem(threadData_t *threadData, modelica_metatype _iSimCode)
{
  modelica_metatype _oEqs = NULL;
  modelica_metatype _allEqs = NULL;
  modelica_metatype _allEqIdxMapping = NULL;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _odeEquations = NULL;
  modelica_integer _highestIdx;
  modelica_metatype _tmpEqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEqs has no default value.
  // _allEqs has no default value.
  // _allEqIdxMapping has no default value.
  // _allEquations has no default value.
  // _odeEquations has no default value.
  // _highestIdx has no default value.
  // _tmpEqs has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iSimCode;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  _allEquations = tmpMeta2;
  _odeEquations = tmpMeta3;

  /* Pattern-matching assignment */
  tmpMeta4 = omc_List_fold(threadData, _allEquations, boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem0, _OMC_LIT194);
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  _allEqIdxMapping = tmpMeta5;
  _highestIdx = tmp7  /* pattern as ty=Integer */;

  _allEqs = arrayCreate(_highestIdx, mmc_mk_none());

  _allEqs = omc_List_fold(threadData, _allEqIdxMapping, boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem1, _allEqs);

  _allEqs = omc_List_fold(threadData, _odeEquations, boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem2, _allEqs);

  tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpEqs = tmpMeta8;

  _tmpEqs = omc_Array_fold(threadData, _allEqs, boxvar_SimCodeUtil_getDaeEqsNotPartOfOdeSystem4, _tmpEqs);

  _oEqs = listReverseInPlace(_tmpEqs);
  _return: OMC_LABEL_UNUSED
  return _oEqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getRemovedEquationSimEqSysIdxes(threadData_t *threadData, modelica_metatype _simCode)
{
  modelica_metatype _simEqSysIdcs = NULL;
  modelica_metatype _remEqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEqSysIdcs has no default value.
  // _remEqs has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _simCode;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 20));
  _remEqs = tmpMeta2;

  _simEqSysIdcs = omc_List_map(threadData, _remEqs, boxvar_SimCodeUtil_simEqSystemIndex);
  _return: OMC_LABEL_UNUSED
  return _simEqSysIdcs;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getMixedindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _mIdx;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _mIdx has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSys;
    {
      modelica_integer _idx;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _idx has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          
          _idx = tmp7  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _idx;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) -1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _mIdx = tmp1;
  _return: OMC_LABEL_UNUSED
  return _mIdx;
}
modelica_metatype boxptr_SimCodeUtil_getMixedindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _mIdx;
  modelica_metatype out_mIdx;
  _mIdx = omc_SimCodeUtil_getMixedindex(threadData, _simEqSys);
  out_mIdx = mmc_mk_icon(_mIdx);
  return out_mIdx;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getNLSindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _nlsIdx;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nlsIdx has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSys;
    {
      modelica_integer _idx;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _idx has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _idx = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _idx;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) -1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _nlsIdx = tmp1;
  _return: OMC_LABEL_UNUSED
  return _nlsIdx;
}
modelica_metatype boxptr_SimCodeUtil_getNLSindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _nlsIdx;
  modelica_metatype out_nlsIdx;
  _nlsIdx = omc_SimCodeUtil_getNLSindex(threadData, _simEqSys);
  out_nlsIdx = mmc_mk_icon(_nlsIdx);
  return out_nlsIdx;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getLSindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _lsIdx;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lsIdx has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSys;
    {
      modelica_integer _idx;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _idx has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 11));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _idx = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _idx;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) -1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _lsIdx = tmp1;
  _return: OMC_LABEL_UNUSED
  return _lsIdx;
}
modelica_metatype boxptr_SimCodeUtil_getLSindex(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_integer _lsIdx;
  modelica_metatype out_lsIdx;
  _lsIdx = omc_SimCodeUtil_getLSindex(threadData, _simEqSys);
  out_lsIdx = mmc_mk_icon(_lsIdx);
  return out_lsIdx;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getMaxSimEqSystemIndex(threadData_t *threadData, modelica_metatype _simCode)
{
  modelica_integer _idxOut;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _jacobianEquations = NULL;
  modelica_metatype _equationsForZeroCrossings = NULL;
  modelica_metatype _algorithmAndEquationAsserts = NULL;
  modelica_metatype _removedEquations = NULL;
  modelica_metatype _parameterEquations = NULL;
  modelica_metatype _maxValueEquations = NULL;
  modelica_metatype _minValueEquations = NULL;
  modelica_metatype _nominalValueEquations = NULL;
  modelica_metatype _startValueEquations = NULL;
  modelica_metatype _initialEquations = NULL;
  modelica_metatype _odeEquations = NULL;
  modelica_metatype _algebraicEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_metatype tmpMeta29;
  modelica_metatype tmpMeta30;
  modelica_metatype tmpMeta31;
  modelica_metatype tmpMeta32;
  modelica_metatype tmpMeta33;
  modelica_metatype tmpMeta34;
  modelica_metatype tmpMeta35;
  modelica_metatype tmpMeta36;
  modelica_metatype tmpMeta37;
  modelica_metatype tmpMeta38;
  modelica_metatype tmpMeta39;
  modelica_metatype tmpMeta40;
  modelica_metatype tmpMeta41;
  modelica_metatype tmpMeta42;
  modelica_metatype tmpMeta43;
  modelica_metatype tmpMeta44;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _idxOut = ((modelica_integer) 0);
  // _allEquations has no default value.
  // _jacobianEquations has no default value.
  // _equationsForZeroCrossings has no default value.
  // _algorithmAndEquationAsserts has no default value.
  // _removedEquations has no default value.
  // _parameterEquations has no default value.
  // _maxValueEquations has no default value.
  // _minValueEquations has no default value.
  // _nominalValueEquations has no default value.
  // _startValueEquations has no default value.
  // _initialEquations has no default value.
  // _odeEquations has no default value.
  // _algebraicEquations has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _simCode;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 10));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 12));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 15));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 16));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 17));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 18));
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 19));
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 20));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 21));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 22));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 23));
  _allEquations = tmpMeta2;
  _odeEquations = tmpMeta3;
  _algebraicEquations = tmpMeta4;
  _initialEquations = tmpMeta5;
  _startValueEquations = tmpMeta6;
  _nominalValueEquations = tmpMeta7;
  _minValueEquations = tmpMeta8;
  _maxValueEquations = tmpMeta9;
  _parameterEquations = tmpMeta10;
  _removedEquations = tmpMeta11;
  _algorithmAndEquationAsserts = tmpMeta12;
  _equationsForZeroCrossings = tmpMeta13;
  _jacobianEquations = tmpMeta14;

  {
    modelica_metatype _eq;
    for (tmpMeta15 = _jacobianEquations; !listEmpty(tmpMeta15); tmpMeta15=MMC_CDR(tmpMeta15))
    {
      _eq = MMC_CAR(tmpMeta15);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta17 = _equationsForZeroCrossings; !listEmpty(tmpMeta17); tmpMeta17=MMC_CDR(tmpMeta17))
    {
      _eq = MMC_CAR(tmpMeta17);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta19 = _algorithmAndEquationAsserts; !listEmpty(tmpMeta19); tmpMeta19=MMC_CDR(tmpMeta19))
    {
      _eq = MMC_CAR(tmpMeta19);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta21 = _removedEquations; !listEmpty(tmpMeta21); tmpMeta21=MMC_CDR(tmpMeta21))
    {
      _eq = MMC_CAR(tmpMeta21);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta23 = _parameterEquations; !listEmpty(tmpMeta23); tmpMeta23=MMC_CDR(tmpMeta23))
    {
      _eq = MMC_CAR(tmpMeta23);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta25 = _maxValueEquations; !listEmpty(tmpMeta25); tmpMeta25=MMC_CDR(tmpMeta25))
    {
      _eq = MMC_CAR(tmpMeta25);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta27 = _minValueEquations; !listEmpty(tmpMeta27); tmpMeta27=MMC_CDR(tmpMeta27))
    {
      _eq = MMC_CAR(tmpMeta27);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta29 = _nominalValueEquations; !listEmpty(tmpMeta29); tmpMeta29=MMC_CDR(tmpMeta29))
    {
      _eq = MMC_CAR(tmpMeta29);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta31 = _nominalValueEquations; !listEmpty(tmpMeta31); tmpMeta31=MMC_CDR(tmpMeta31))
    {
      _eq = MMC_CAR(tmpMeta31);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta33 = _startValueEquations; !listEmpty(tmpMeta33); tmpMeta33=MMC_CDR(tmpMeta33))
    {
      _eq = MMC_CAR(tmpMeta33);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta35 = _initialEquations; !listEmpty(tmpMeta35); tmpMeta35=MMC_CDR(tmpMeta35))
    {
      _eq = MMC_CAR(tmpMeta35);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta37 = _allEquations; !listEmpty(tmpMeta37); tmpMeta37=MMC_CDR(tmpMeta37))
    {
      _eq = MMC_CAR(tmpMeta37);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta39 = _jacobianEquations; !listEmpty(tmpMeta39); tmpMeta39=MMC_CDR(tmpMeta39))
    {
      _eq = MMC_CAR(tmpMeta39);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta41 = _jacobianEquations; !listEmpty(tmpMeta41); tmpMeta41=MMC_CDR(tmpMeta41))
    {
      _eq = MMC_CAR(tmpMeta41);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }

  {
    modelica_metatype _eq;
    for (tmpMeta43 = _jacobianEquations; !listEmpty(tmpMeta43); tmpMeta43=MMC_CDR(tmpMeta43))
    {
      _eq = MMC_CAR(tmpMeta43);
      _idxOut = modelica_integer_max((modelica_integer)(_idxOut),(modelica_integer)(omc_SimCodeUtil_simEqSystemIndex(threadData, _eq)));
    }
  }
  _return: OMC_LABEL_UNUSED
  return _idxOut;
}
modelica_metatype boxptr_SimCodeUtil_getMaxSimEqSystemIndex(threadData_t *threadData, modelica_metatype _simCode)
{
  modelica_integer _idxOut;
  modelica_metatype out_idxOut;
  _idxOut = omc_SimCodeUtil_getMaxSimEqSystemIndex(threadData, _simCode);
  out_idxOut = mmc_mk_icon(_idxOut);
  return out_idxOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_replaceSimEqSysIndex(threadData_t *threadData, modelica_metatype _simEqSysIn, modelica_integer _inputIndex)
{
  modelica_metatype _simEqSysOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEqSysOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSysIn;
    {
      modelica_metatype _lSystem = NULL;
      modelica_metatype _nlSystem = NULL;
      modelica_metatype _simEqSys = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _lSystem has no default value.
      // _nlSystem has no default value.
      // _simEqSys has no default value.
      tmp4 = 0;
      for (; tmp4 < 14; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_simEqSys), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta6;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_simEqSys), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta7;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_simEqSys), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta8;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_simEqSys), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta9;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_simEqSys), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta10;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_simEqSys), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta11;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,5) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_simEqSys), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta12;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_simEqSys), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta13;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_simEqSys), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta14;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _simEqSys = tmp4_1;
          _lSystem = tmpMeta15;
          /* Pattern matching succeeded */
          tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(14));
          memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_lSystem), 14*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[2] = mmc_mk_integer(_inputIndex);
          _lSystem = tmpMeta16;

          tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_simEqSys), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[2] = _lSystem;
          _simEqSys = tmpMeta17;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _simEqSys = tmp4_1;
          _nlSystem = tmpMeta18;
          /* Pattern matching succeeded */
          tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(12));
          memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_nlSystem), 12*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[2] = mmc_mk_integer(_inputIndex);
          _nlSystem = tmpMeta19;

          tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_simEqSys), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[2] = _nlSystem;
          _simEqSys = tmpMeta20;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta21 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta21), MMC_UNTAGPTR(_simEqSys), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta21))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta21;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_simEqSys), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta22;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,8) == 0) goto tmp3_end;
          
          _simEqSys = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta23 = MMC_TAGPTR(mmc_alloc_words(10));
          memcpy(MMC_UNTAGPTR(tmpMeta23), MMC_UNTAGPTR(_simEqSys), 10*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta23))[2] = mmc_mk_integer(_inputIndex);
          _simEqSys = tmpMeta23;
          tmpMeta1 = _simEqSys;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _simEqSysOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simEqSysOut;
}
modelica_metatype boxptr_SimCodeUtil_replaceSimEqSysIndex(threadData_t *threadData, modelica_metatype _simEqSysIn, modelica_metatype _inputIndex)
{
  modelica_integer tmp1;
  modelica_metatype _simEqSysOut = NULL;
  tmp1 = mmc_unbox_integer(_inputIndex);
  _simEqSysOut = omc_SimCodeUtil_replaceSimEqSysIndex(threadData, _simEqSysIn, tmp1);
  /* skip box _simEqSysOut; SimCode.SimEqSystem */
  return _simEqSysOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_replaceModelInfo(threadData_t *threadData, modelica_metatype _modelInfoIn, modelica_metatype _simCodeIn)
{
  modelica_metatype _simCodeOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simCodeOut = _simCodeIn;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simCodeOut), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[2] = _modelInfoIn;
  _simCodeOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simCodeOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_replaceODEandALLequations(threadData_t *threadData, modelica_metatype _allEqs, modelica_metatype _odeEqs, modelica_metatype _simCodeIn)
{
  modelica_metatype __omcQ_24mrfa_5F2 = NULL;
  modelica_metatype __omcQ_24mrfa_5F3 = NULL;
  modelica_metatype _simCodeOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F2 has no default value.
  // __omcQ_24mrfa_5F3 has no default value.
  _simCodeOut = _simCodeIn;
  __omcQ_24mrfa_5F2 = _allEqs;

  __omcQ_24mrfa_5F3 = _odeEqs;

  tmpMeta1 = mmc_mk_box(53, 3, &SimCode_SimCode_SIMCODE__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 7))), __omcQ_24mrfa_5F2, __omcQ_24mrfa_5F3, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 32))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 33))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 34))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 35))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 36))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 37))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 38))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 39))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 40))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 41))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 42))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 43))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 44))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 45))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 46))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 47))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 48))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 49))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 50))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 51))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 52))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 53))));
  _simCodeOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simCodeOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addSimEqSysToInitialEquations(threadData_t *threadData, modelica_metatype _simEqSys, modelica_metatype _simCodeIn)
{
  modelica_metatype _simCodeOut = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simCodeOut = _simCodeIn;
  tmpMeta2 = mmc_mk_cons(_simEqSys, MMC_REFSTRUCTLIT(mmc_nil));
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simCodeOut), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[12] = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 12))), tmpMeta2);
  _simCodeOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simCodeOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addSimEqSysToODEquations(threadData_t *threadData, modelica_metatype _simEqSys, modelica_integer _sysIdx, modelica_metatype _simCodeIn)
{
  modelica_metatype __omcQ_24mrfa_5F4 = NULL;
  modelica_metatype __omcQ_24mrfa_5F5 = NULL;
  modelica_metatype _simCodeOut = NULL;
  modelica_metatype _odes = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F4 has no default value.
  // __omcQ_24mrfa_5F5 has no default value.
  _simCodeOut = _simCodeIn;
  // _odes has no default value.
  _odes = listGet((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 9))), _sysIdx);

  tmpMeta1 = mmc_mk_cons(_simEqSys, _odes);
  _odes = tmpMeta1;

  __omcQ_24mrfa_5F4 = omc_List_set(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 9))), _sysIdx, _odes);

  tmpMeta2 = mmc_mk_cons(_simEqSys, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 8))));
  __omcQ_24mrfa_5F5 = tmpMeta2;

  tmpMeta3 = mmc_mk_box(53, 3, &SimCode_SimCode_SIMCODE__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 7))), __omcQ_24mrfa_5F5, __omcQ_24mrfa_5F4, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 32))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 33))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 34))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 35))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 36))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 37))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 38))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 39))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 40))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 41))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 42))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 43))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 44))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 45))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 46))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 47))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 48))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 49))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 50))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 51))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 52))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 53))));
  _simCodeOut = tmpMeta3;
  _return: OMC_LABEL_UNUSED
  return _simCodeOut;
}
modelica_metatype boxptr_SimCodeUtil_addSimEqSysToODEquations(threadData_t *threadData, modelica_metatype _simEqSys, modelica_metatype _sysIdx, modelica_metatype _simCodeIn)
{
  modelica_integer tmp1;
  modelica_metatype _simCodeOut = NULL;
  tmp1 = mmc_unbox_integer(_sysIdx);
  _simCodeOut = omc_SimCodeUtil_addSimEqSysToODEquations(threadData, _simEqSys, tmp1, _simCodeIn);
  /* skip box _simCodeOut; SimCode.SimCode */
  return _simCodeOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addSimVarToAlgVars(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _simCodeIn)
{
  modelica_metatype _simCodeOut = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simCodeOut = _simCodeIn;
  // _modelInfo has no default value.
  // _vars has no default value.
  _modelInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCodeOut), 2)));

  _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

  tmpMeta2 = mmc_mk_cons(_simVar, MMC_REFSTRUCTLIT(mmc_nil));
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(32));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_vars), 32*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[4] = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 4))), tmpMeta2);
  _vars = tmpMeta1;

  tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(23));
  memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[11] = _vars;
  _modelInfo = tmpMeta3;

  tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_simCodeOut), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[2] = _modelInfo;
  _simCodeOut = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  return _simCodeOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_replaceSimVarIndex(threadData_t *threadData, modelica_integer _idx, modelica_metatype _simVarIn)
{
  modelica_metatype _simVarOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simVarOut = _simVarIn;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simVarOut), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[7] = mmc_mk_integer(_idx);
  _simVarOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simVarOut;
}
modelica_metatype boxptr_SimCodeUtil_replaceSimVarIndex(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _simVarIn)
{
  modelica_integer tmp1;
  modelica_metatype _simVarOut = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  _simVarOut = omc_SimCodeUtil_replaceSimVarIndex(threadData, tmp1, _simVarIn);
  /* skip box _simVarOut; SimCodeVar.SimVar */
  return _simVarOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_replaceSimVarName(threadData_t *threadData, modelica_metatype _cref, modelica_metatype _simVarIn)
{
  modelica_metatype __omcQ_24mrfa_5F6 = NULL;
  modelica_metatype __omcQ_24mrfa_5F7 = NULL;
  modelica_metatype _simVarOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F6 has no default value.
  // __omcQ_24mrfa_5F7 has no default value.
  _simVarOut = _simVarIn;
  __omcQ_24mrfa_5F6 = _cref;

  __omcQ_24mrfa_5F7 = omc_ComponentReference_getArrayCref(threadData, _cref);

  tmpMeta1 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, __omcQ_24mrfa_5F6, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 14))), __omcQ_24mrfa_5F7, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVarOut), 32))));
  _simVarOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simVarOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimEqSystemCrefsLHS(threadData_t *threadData, modelica_metatype _simEqSys)
{
  modelica_metatype _crefsOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _crefsOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSys;
    {
      modelica_metatype _lhs = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _crefs2 = NULL;
      modelica_metatype _simVars = NULL;
      int tmp4;
      // _lhs has no default value.
      // _cref has no default value.
      // _crefs has no default value.
      // _crefs2 has no default value.
      // _simVars has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT195),stdout);
          tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta5;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cref = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_cons(_cref, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cref = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = mmc_mk_cons(_cref, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _lhs = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta11 = mmc_mk_cons(omc_Expression_expCref(threadData, _lhs), MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta11;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta12;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT196),stdout);
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta13;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT197),stdout);
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta14;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT198),stdout);
          tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 5));
          
          _simVars = tmpMeta16;
          /* Pattern matching succeeded */
          {
            modelica_metatype __omcQ_24tmpVar31;
            modelica_metatype* tmp18;
            modelica_metatype tmpMeta19;
            modelica_metatype __omcQ_24tmpVar30;
            modelica_integer tmp20;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _simVars;
            tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar31 = tmpMeta19; /* defaultValue */
            tmp18 = &__omcQ_24tmpVar31;
            while(1) {
              tmp20 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp20--;
              }
              if (tmp20 == 0) {
                __omcQ_24tmpVar30 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2)));
                *tmp18 = mmc_mk_cons(__omcQ_24tmpVar30,0);
                tmp18 = &MMC_CDR(*tmp18);
              } else if (tmp20 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp18 = mmc_mk_nil();
            tmpMeta17 = __omcQ_24tmpVar31;
          }
          _crefs2 = tmpMeta17;
          tmpMeta1 = listAppend(_crefs2, _crefs2);
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 4));
          
          _crefs = tmpMeta22;
          /* Pattern matching succeeded */
          tmpMeta1 = _crefs;
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _simVars = tmpMeta23;
          /* Pattern matching succeeded */
          {
            modelica_metatype __omcQ_24tmpVar33;
            modelica_metatype* tmp25;
            modelica_metatype tmpMeta26;
            modelica_metatype __omcQ_24tmpVar32;
            modelica_integer tmp27;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _simVars;
            tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar33 = tmpMeta26; /* defaultValue */
            tmp25 = &__omcQ_24tmpVar33;
            while(1) {
              tmp27 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp27--;
              }
              if (tmp27 == 0) {
                __omcQ_24tmpVar32 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2)));
                *tmp25 = mmc_mk_cons(__omcQ_24tmpVar32,0);
                tmp25 = &MMC_CDR(*tmp25);
              } else if (tmp27 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp25 = mmc_mk_nil();
            tmpMeta24 = __omcQ_24tmpVar33;
          }
          tmpMeta1 = tmpMeta24;
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          if (listEmpty(tmpMeta28)) goto tmp3_end;
          tmpMeta29 = MMC_CAR(tmpMeta28);
          tmpMeta30 = MMC_CDR(tmpMeta28);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,0,3) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          if (!listEmpty(tmpMeta30)) goto tmp3_end;
          
          _lhs = tmpMeta31;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_Expression_getAllCrefs(threadData, _lhs);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _crefsOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _crefsOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getAssignedCrefsOfSimEq(threadData_t *threadData, modelica_integer _idx, modelica_metatype _simCode)
{
  modelica_metatype _crefsOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _crefsOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simCode;
    {
      modelica_metatype _simEqSyst = NULL;
      modelica_metatype _allEqs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _simEqSyst has no default value.
      // _allEqs has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _allEqs = tmpMeta6;
          /* Pattern matching succeeded */
          _simEqSyst = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_idx), _allEqs, boxvar_SimCodeUtil_indexIsEqual);
          tmpMeta1 = omc_SimCodeUtil_getSimEqSystemCrefsLHS(threadData, _simEqSyst);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _crefsOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _crefsOut;
}
modelica_metatype boxptr_SimCodeUtil_getAssignedCrefsOfSimEq(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _simCode)
{
  modelica_integer tmp1;
  modelica_metatype _crefsOut = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  _crefsOut = omc_SimCodeUtil_getAssignedCrefsOfSimEq(threadData, tmp1, _simCode);
  /* skip box _crefsOut; list<DAE.ComponentRef> */
  return _crefsOut;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findBEqs(threadData_t *threadData, modelica_integer _bEq, modelica_metatype _eqTpl)
{
  modelica_boolean _b;
  modelica_metatype _bEq1 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _bEq1 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _eqTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _bEq1 = tmpMeta2;

  _b = listMember(mmc_mk_integer(_bEq), _bEq1);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findBEqs(threadData_t *threadData, modelica_metatype _bEq, modelica_metatype _eqTpl)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_bEq);
  _b = omc_SimCodeUtil_findBEqs(threadData, tmp1, _eqTpl);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findSimEqs(threadData_t *threadData, modelica_integer _simEq, modelica_metatype _eqTpl)
{
  modelica_boolean _b;
  modelica_integer _simEq1;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _simEq1 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _eqTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  _simEq1 = tmp3  /* pattern as ty=Integer */;

  _b = (_simEq == _simEq1);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findSimEqs(threadData_t *threadData, modelica_metatype _simEq, modelica_metatype _eqTpl)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_simEq);
  _b = omc_SimCodeUtil_findSimEqs(threadData, tmp1, _eqTpl);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findBackendVar(threadData_t *threadData, modelica_integer _bVar, modelica_metatype _varTpl)
{
  modelica_boolean _b;
  modelica_integer _bVar1;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _bVar1 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _varTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  _bVar1 = tmp3  /* pattern as ty=Integer */;

  _b = (_bVar == _bVar1);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findBackendVar(threadData_t *threadData, modelica_metatype _bVar, modelica_metatype _varTpl)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_bVar);
  _b = omc_SimCodeUtil_findBackendVar(threadData, tmp1, _varTpl);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_findSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _varTpl)
{
  modelica_boolean _b;
  modelica_integer _simVar1;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _simVar1 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _varTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  _simVar1 = tmp3  /* pattern as ty=Integer */;

  _b = (_simVar == _simVar1);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_findSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _varTpl)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_simVar);
  _b = omc_SimCodeUtil_findSimVar(threadData, tmp1, _varTpl);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimEqsForBackendEqs(threadData_t *threadData, modelica_integer _bEq, modelica_metatype _map)
{
  modelica_integer _simEq;
  modelica_metatype _eqMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEq has no default value.
  // _eqMapping has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _eqMapping = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_bEq), _eqMapping, boxvar_SimCodeUtil_findBEqs);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _simEq = tmp5  /* pattern as ty=Integer */;
  _return: OMC_LABEL_UNUSED
  return _simEq;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimEqsForBackendEqs(threadData_t *threadData, modelica_metatype _bEq, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_integer _simEq;
  modelica_metatype out_simEq;
  tmp1 = mmc_unbox_integer(_bEq);
  _simEq = omc_SimCodeUtil_getSimEqsForBackendEqs(threadData, tmp1, _map);
  out_simEq = mmc_mk_icon(_simEq);
  return out_simEq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getBackendEqsForSimEq(threadData_t *threadData, modelica_integer _simEq, modelica_metatype _map)
{
  modelica_metatype _bEqs = NULL;
  modelica_metatype _eqMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _bEqs has no default value.
  // _eqMapping has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _eqMapping = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_simEq), _eqMapping, boxvar_SimCodeUtil_findSimEqs);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  _bEqs = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  return _bEqs;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getBackendEqsForSimEq(threadData_t *threadData, modelica_metatype _simEq, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_metatype _bEqs = NULL;
  tmp1 = mmc_unbox_integer(_simEq);
  _bEqs = omc_SimCodeUtil_getBackendEqsForSimEq(threadData, tmp1, _map);
  /* skip box _bEqs; list<#Integer> */
  return _bEqs;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimVarForBackendVar(threadData_t *threadData, modelica_integer _bVar, modelica_metatype _map)
{
  modelica_integer _simVar;
  modelica_metatype _varMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simVar has no default value.
  // _varMapping has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  _varMapping = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_bVar), _varMapping, boxvar_SimCodeUtil_findBackendVar);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _simVar = tmp5  /* pattern as ty=Integer */;
  _return: OMC_LABEL_UNUSED
  return _simVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimVarForBackendVar(threadData_t *threadData, modelica_metatype _bVar, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_integer _simVar;
  modelica_metatype out_simVar;
  tmp1 = mmc_unbox_integer(_bVar);
  _simVar = omc_SimCodeUtil_getSimVarForBackendVar(threadData, tmp1, _map);
  out_simVar = mmc_mk_icon(_simVar);
  return out_simVar;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getBackendVarForSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _map)
{
  modelica_integer _bVar;
  modelica_metatype _varMapping = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _bVar has no default value.
  // _varMapping has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  _varMapping = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_simVar), _varMapping, boxvar_SimCodeUtil_findSimVar);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _bVar = tmp5  /* pattern as ty=Integer */;
  _return: OMC_LABEL_UNUSED
  return _bVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getBackendVarForSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_integer _bVar;
  modelica_metatype out_bVar;
  tmp1 = mmc_unbox_integer(_simVar);
  _bVar = omc_SimCodeUtil_getBackendVarForSimVar(threadData, tmp1, _map);
  out_bVar = mmc_mk_icon(_bVar);
  return out_bVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectReqSimEqs(threadData_t *threadData, modelica_integer _eq, modelica_metatype _tree, modelica_metatype _eqsIn)
{
  modelica_metatype _eqsOut = NULL;
  modelica_metatype _preEqs = NULL;
  modelica_metatype _reqEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqsOut has no default value.
  // _preEqs has no default value.
  // _reqEqs has no default value.
  _preEqs = arrayGet(_tree, _eq);

  omc_List_intersection1OnTrue(threadData, _preEqs, _eqsIn, boxvar_intEq ,&_preEqs ,NULL);

  _reqEqs = listAppend(_preEqs, _eqsIn);

  _eqsOut = omc_List_fold1(threadData, _preEqs, boxvar_SimCodeUtil_collectReqSimEqs, _tree, _reqEqs);
  _return: OMC_LABEL_UNUSED
  return _eqsOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_collectReqSimEqs(threadData_t *threadData, modelica_metatype _eq, modelica_metatype _tree, modelica_metatype _eqsIn)
{
  modelica_integer tmp1;
  modelica_metatype _eqsOut = NULL;
  tmp1 = mmc_unbox_integer(_eq);
  _eqsOut = omc_SimCodeUtil_collectReqSimEqs(threadData, tmp1, _tree, _eqsIn);
  /* skip box _eqsOut; list<#Integer> */
  return _eqsOut;
}

DLLDirection
modelica_integer omc_SimCodeUtil_getAssignedSimEqSysIdx(threadData_t *threadData, modelica_integer _simVarIdx, modelica_metatype _map)
{
  modelica_integer _simEqSysIdx;
  modelica_integer _bVarIdx;
  modelica_integer _bEqIdx;
  modelica_metatype _varMatch = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEqSysIdx has no default value.
  // _bVarIdx has no default value.
  // _bEqIdx has no default value.
  // _varMatch has no default value.
  _bVarIdx = omc_SimCodeUtil_getBackendVarForSimVar(threadData, _simVarIdx, _map);

  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  _varMatch = tmpMeta2;

  _bEqIdx = mmc_unbox_integer(arrayGet(_varMatch, _bVarIdx));

  _simEqSysIdx = omc_SimCodeUtil_getSimEqsForBackendEqs(threadData, _bEqIdx, _map);
  _return: OMC_LABEL_UNUSED
  return _simEqSysIdx;
}
modelica_metatype boxptr_SimCodeUtil_getAssignedSimEqSysIdx(threadData_t *threadData, modelica_metatype _simVarIdx, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_integer _simEqSysIdx;
  modelica_metatype out_simEqSysIdx;
  tmp1 = mmc_unbox_integer(_simVarIdx);
  _simEqSysIdx = omc_SimCodeUtil_getAssignedSimEqSysIdx(threadData, tmp1, _map);
  out_simEqSysIdx = mmc_mk_icon(_simEqSysIdx);
  return out_simEqSysIdx;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getReqSimEqsForSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _map)
{
  modelica_metatype _simEqs = NULL;
  modelica_integer _bVar;
  modelica_integer _bEq;
  modelica_metatype _beqs = NULL;
  modelica_metatype _eqMatch = NULL;
  modelica_metatype _varMatch = NULL;
  modelica_metatype _tree = NULL;
  modelica_metatype _m = NULL;
  modelica_metatype _mt = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEqs has no default value.
  // _bVar has no default value.
  // _bEq has no default value.
  // _beqs has no default value.
  // _eqMatch has no default value.
  // _varMatch has no default value.
  // _tree has no default value.
  // _m has no default value.
  // _mt has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 6));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  _m = tmpMeta2;
  _mt = tmpMeta3;
  _eqMatch = tmpMeta4;
  _varMatch = tmpMeta5;
  _tree = tmpMeta6;

  _bVar = omc_SimCodeUtil_getBackendVarForSimVar(threadData, _simVar, _map);

  _bEq = mmc_unbox_integer(arrayGet(_varMatch, _bVar));

  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _beqs = omc_SimCodeUtil_collectReqSimEqs(threadData, _bEq, _tree, tmpMeta7);

  _simEqs = omc_List_map1(threadData, _beqs, boxvar_SimCodeUtil_getSimEqsForBackendEqs, _map);

  _simEqs = omc_List_unique(threadData, _simEqs);
  _return: OMC_LABEL_UNUSED
  return _simEqs;
}
modelica_metatype boxptr_SimCodeUtil_getReqSimEqsForSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _map)
{
  modelica_integer tmp1;
  modelica_metatype _simEqs = NULL;
  tmp1 = mmc_unbox_integer(_simVar);
  _simEqs = omc_SimCodeUtil_getReqSimEqsForSimVar(threadData, tmp1, _map);
  /* skip box _simEqs; list<#Integer> */
  return _simEqs;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_indexIsEqual(threadData_t *threadData, modelica_integer _idx, modelica_metatype _ses)
{
  modelica_boolean _b;
  modelica_integer _idx2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _idx2 has no default value.
  _idx2 = omc_SimCodeUtil_simEqSystemIndex(threadData, _ses);

  _b = (_idx == _idx2);
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_indexIsEqual(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _ses)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_idx);
  _b = omc_SimCodeUtil_indexIsEqual(threadData, tmp1, _ses);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimVarMappingOfBackendMapping(threadData_t *threadData, modelica_metatype _iBackendMappingOpt)
{
  modelica_metatype _oSimVarMapping = NULL;
  modelica_metatype _simVarMapping = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSimVarMapping has no default value.
  // _simVarMapping has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iBackendMappingOpt;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,8) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 9));
          _simVarMapping = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _simVarMapping;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = arrayCreate(((modelica_integer) 0), tmpMeta8);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oSimVarMapping = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oSimVarMapping;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimEqSysForIndex(threadData_t *threadData, modelica_integer _idx, modelica_metatype _allSimEqs)
{
  modelica_metatype _outSimEq = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEq has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          /* Pattern matching succeeded */
          _outSimEq = omc_List_getMemberOnTrue(threadData, mmc_mk_integer(_idx), _allSimEqs, boxvar_SimCodeUtil_indexIsEqual);
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT199),stdout);

          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _outSimEq;
}
modelica_metatype boxptr_SimCodeUtil_getSimEqSysForIndex(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _allSimEqs)
{
  modelica_integer tmp1;
  modelica_metatype _outSimEq = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  _outSimEq = omc_SimCodeUtil_getSimEqSysForIndex(threadData, tmp1, _allSimEqs);
  /* skip box _outSimEq; SimCode.SimEqSystem */
  return _outSimEq;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getReqSimEqSysForSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _simCode)
{
  modelica_metatype _ses = NULL;
  modelica_metatype _sesIdcs = NULL;
  modelica_metatype _sesLst = NULL;
  modelica_metatype _bmap = NULL;
  modelica_metatype _bmapOpt = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ses has no default value.
  // _sesIdcs has no default value.
  // _sesLst has no default value.
  // _bmap has no default value.
  // _bmapOpt has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _simCode;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 46));
  _sesLst = tmpMeta2;
  _bmapOpt = tmpMeta3;

  _bmap = omc_Util_getOption(threadData, _bmapOpt);

  _sesIdcs = omc_SimCodeUtil_getReqSimEqsForSimVar(threadData, _simVar, _bmap);

  _ses = omc_List_map1(threadData, _sesIdcs, boxvar_SimCodeUtil_getSimEqSysForIndex, _sesLst);
  _return: OMC_LABEL_UNUSED
  return _ses;
}
modelica_metatype boxptr_SimCodeUtil_getReqSimEqSysForSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _simCode)
{
  modelica_integer tmp1;
  modelica_metatype _ses = NULL;
  tmp1 = mmc_unbox_integer(_simVar);
  _ses = omc_SimCodeUtil_getReqSimEqSysForSimVar(threadData, tmp1, _simCode);
  /* skip box _ses; list<SimCode.SimEqSystem> */
  return _ses;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimEqsOfSimVar(threadData_t *threadData, modelica_integer _simVar, modelica_metatype _map, modelica_integer _opt)
{
  modelica_metatype _simEqs = NULL;
  modelica_integer _bVar;
  modelica_metatype _bEqs = NULL;
  modelica_metatype _eqMapping = NULL;
  modelica_metatype _varMapping = NULL;
  modelica_metatype _m = NULL;
  modelica_metatype _mt = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simEqs has no default value.
  // _bVar has no default value.
  // _bEqs has no default value.
  // _eqMapping has no default value.
  // _varMapping has no default value.
  // _m has no default value.
  // _mt has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  _m = tmpMeta2;
  _mt = tmpMeta3;
  _eqMapping = tmpMeta4;
  _varMapping = tmpMeta5;

  _bVar = omc_SimCodeUtil_getBackendVarForSimVar(threadData, _simVar, _map);

  _bEqs = arrayGet(_mt, _bVar);

  _bEqs = ((_opt == ((modelica_integer) 2))?omc_List_filter1OnTrue(threadData, _bEqs, boxvar_intGt, mmc_mk_integer(((modelica_integer) 0))):_bEqs);

  _bEqs = ((_opt == ((modelica_integer) 3))?omc_List_filter1OnTrue(threadData, _bEqs, boxvar_intLt, mmc_mk_integer(((modelica_integer) 0))):_bEqs);

  if((!omc_List_isMemberOnTrue(threadData, mmc_mk_integer(_opt), _OMC_LIT203, boxvar_intEq)))
  {
    fputs(MMC_STRINGDATA(_OMC_LIT200),stdout);
  }

  _bEqs = omc_List_map(threadData, _bEqs, boxvar_intAbs);

  _simEqs = omc_List_map1(threadData, _bEqs, boxvar_SimCodeUtil_getSimEqsForBackendEqs, _map);

  _simEqs = omc_List_unique(threadData, _simEqs);
  _return: OMC_LABEL_UNUSED
  return _simEqs;
}
modelica_metatype boxptr_SimCodeUtil_getSimEqsOfSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _map, modelica_metatype _opt)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _simEqs = NULL;
  tmp1 = mmc_unbox_integer(_simVar);
  tmp2 = mmc_unbox_integer(_opt);
  _simEqs = omc_SimCodeUtil_getSimEqsOfSimVar(threadData, tmp1, _map, tmp2);
  /* skip box _simEqs; list<#Integer> */
  return _simEqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimVarsInSimEq(threadData_t *threadData, modelica_integer _simEq, modelica_metatype _map, modelica_integer _opt)
{
  modelica_metatype _simVars = NULL;
  modelica_metatype _bVars = NULL;
  modelica_metatype _bEqs = NULL;
  modelica_metatype _bVarsLst = NULL;
  modelica_metatype _eqMapping = NULL;
  modelica_metatype _varMapping = NULL;
  modelica_metatype _m = NULL;
  modelica_metatype _mt = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simVars has no default value.
  // _bVars has no default value.
  // _bEqs has no default value.
  // _bVarsLst has no default value.
  // _eqMapping has no default value.
  // _varMapping has no default value.
  // _m has no default value.
  // _mt has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _map;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  _m = tmpMeta2;
  _mt = tmpMeta3;
  _eqMapping = tmpMeta4;
  _varMapping = tmpMeta5;

  _bEqs = omc_SimCodeUtil_getBackendEqsForSimEq(threadData, _simEq, _map);

  _bVarsLst = omc_List_map1(threadData, _bEqs, boxvar_Array_getIndexFirst, _m);

  _bVars = omc_List_flatten(threadData, _bVarsLst);

  _bVars = ((_opt == ((modelica_integer) 2))?omc_List_filter1OnTrue(threadData, _bVars, boxvar_intGt, mmc_mk_integer(((modelica_integer) 0))):_bVars);

  _bVars = ((_opt == ((modelica_integer) 3))?omc_List_filter1OnTrue(threadData, _bVars, boxvar_intLt, mmc_mk_integer(((modelica_integer) 0))):_bVars);

  if((!omc_List_isMemberOnTrue(threadData, mmc_mk_integer(_opt), _OMC_LIT203, boxvar_intEq)))
  {
    fputs(MMC_STRINGDATA(_OMC_LIT204),stdout);
  }

  _bVars = omc_List_unique(threadData, _bVars);

  _bVars = omc_List_map(threadData, _bVars, boxvar_intAbs);

  _simVars = omc_List_map1(threadData, _bVars, boxvar_SimCodeUtil_getSimVarForBackendVar, _map);
  _return: OMC_LABEL_UNUSED
  return _simVars;
}
modelica_metatype boxptr_SimCodeUtil_getSimVarsInSimEq(threadData_t *threadData, modelica_metatype _simEq, modelica_metatype _map, modelica_metatype _opt)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _simVars = NULL;
  tmp1 = mmc_unbox_integer(_simEq);
  tmp2 = mmc_unbox_integer(_opt);
  _simVars = omc_SimCodeUtil_getSimVarsInSimEq(threadData, tmp1, _map, tmp2);
  /* skip box _simVars; list<#Integer> */
  return _simVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendEqIdcs(threadData_t *threadData, modelica_integer _iCurrentIdx, modelica_metatype _iEqIdx, modelica_metatype _iSccIdc)
{
  modelica_metatype _oSccIdc = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSccIdc has no default value.
  tmpMeta2 = mmc_mk_box2(0, mmc_mk_integer(_iCurrentIdx), _iEqIdx);
  tmpMeta1 = mmc_mk_cons(tmpMeta2, _iSccIdc);
  _oSccIdc = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oSccIdc;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendEqIdcs(threadData_t *threadData, modelica_metatype _iCurrentIdx, modelica_metatype _iEqIdx, modelica_metatype _iSccIdc)
{
  modelica_integer tmp1;
  modelica_metatype _oSccIdc = NULL;
  tmp1 = mmc_unbox_integer(_iCurrentIdx);
  _oSccIdc = omc_SimCodeUtil_appendEqIdcs(threadData, tmp1, _iEqIdx, _iSccIdc);
  /* skip box _oSccIdc; list<tuple<#Integer, list<#Integer>>> */
  return _oSccIdc;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setEqMapping(threadData_t *threadData, modelica_metatype _simEqs, modelica_metatype _bEq, modelica_metatype _mapIn)
{
  modelica_metatype _mapOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _mapOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _mapIn;
    {
      modelica_metatype _eqMatch = NULL;
      modelica_metatype _varMatch = NULL;
      modelica_metatype _tree = NULL;
      modelica_metatype _eqMapping = NULL;
      modelica_metatype _varMapping = NULL;
      modelica_metatype _m = NULL;
      modelica_metatype _mt = NULL;
      modelica_metatype _simVarMapping = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqMatch has no default value.
      // _varMatch has no default value.
      // _tree has no default value.
      // _eqMapping has no default value.
      // _varMapping has no default value.
      // _m has no default value.
      // _mt has no default value.
      // _simVarMapping has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          _m = tmpMeta6;
          _mt = tmpMeta7;
          _eqMapping = tmpMeta8;
          _varMapping = tmpMeta9;
          _eqMatch = tmpMeta10;
          _varMatch = tmpMeta11;
          _tree = tmpMeta12;
          _simVarMapping = tmpMeta13;
          /* Pattern matching succeeded */
          _eqMapping = omc_List_fold1(threadData, _simEqs, boxvar_SimCodeUtil_appendEqIdcs, _bEq, _eqMapping);
          tmpMeta14 = mmc_mk_box9(3, &SimCode_BackendMapping_BACKENDMAPPING__desc, _m, _mt, _eqMapping, _varMapping, _eqMatch, _varMatch, _tree, _simVarMapping);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _mapIn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _mapOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _mapOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeVarMapTuple(threadData_t *threadData, modelica_metatype _sVar, modelica_metatype _bVar, modelica_metatype _foldIn)
{
  modelica_metatype _foldOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _foldOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _sVar;
    tmp4_2 = _bVar;
    {
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_metatype _rest1 = NULL;
      modelica_metatype _rest2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _i1 has no default value.
      // _i2 has no default value.
      // _rest1 has no default value.
      // _rest2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _foldIn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmp8 = mmc_unbox_integer(tmpMeta6);
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_2);
          tmpMeta10 = MMC_CDR(tmp4_2);
          tmp11 = mmc_unbox_integer(tmpMeta9);
          _i1 = tmp8  /* pattern as ty=Integer */;
          _rest1 = tmpMeta7;
          _i2 = tmp11  /* pattern as ty=Integer */;
          _rest2 = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_box2(0, mmc_mk_integer(_i1), mmc_mk_integer(_i2));
          tmpMeta12 = mmc_mk_cons(tmpMeta13, _foldIn);
          /* Tail recursive call */
          _sVar = _rest1;
          _bVar = _rest2;
          _foldIn = tmpMeta12;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _foldOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _foldOut;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getSimVarIndex(threadData_t *threadData, modelica_metatype _var, modelica_metatype _varInfo, modelica_metatype _htStates)
{
  modelica_integer _idx;
  modelica_integer _offset;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _idx has no default value.
  // _offset has no default value.
  if(omc_BaseHashTable_hasKey(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), _htStates))
  {
    _idx = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 7))));
  }
  else
  {
    _offset = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 6))));

    _idx = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 7))));

    _idx = _idx + (((modelica_integer) 2)) * (_offset);
  }
  _return: OMC_LABEL_UNUSED
  return _idx;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimVarIndex(threadData_t *threadData, modelica_metatype _var, modelica_metatype _varInfo, modelica_metatype _htStates)
{
  modelica_integer _idx;
  modelica_metatype out_idx;
  _idx = omc_SimCodeUtil_getSimVarIndex(threadData, _var, _varInfo, _htStates);
  out_idx = mmc_mk_icon(_idx);
  return out_idx;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_fillSimVarMapping(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iSimVarMapping, modelica_integer _iVarIdx)
{
  modelica_integer _oVarIdx;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVarIdx has no default value.
  tmpMeta1 = mmc_mk_cons(_iSimVar, MMC_REFSTRUCTLIT(mmc_nil));
  arrayUpdate(_iSimVarMapping, _iVarIdx, tmpMeta1);

  _oVarIdx = ((modelica_integer) 1) + _iVarIdx;
  _return: OMC_LABEL_UNUSED
  return _oVarIdx;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillSimVarMapping(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iSimVarMapping, modelica_metatype _iVarIdx)
{
  modelica_integer tmp1;
  modelica_integer _oVarIdx;
  modelica_metatype out_oVarIdx;
  tmp1 = mmc_unbox_integer(_iVarIdx);
  _oVarIdx = omc_SimCodeUtil_fillSimVarMapping(threadData, _iSimVar, _iSimVarMapping, tmp1);
  out_oVarIdx = mmc_mk_icon(_oVarIdx);
  return out_oVarIdx;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setBackendVarMapping(threadData_t *threadData, modelica_metatype _dae, modelica_metatype _ht, modelica_metatype _modelInfo, modelica_metatype _bmapIn)
{
  modelica_metatype _bmapOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _bmapOut has no default value.
  { /* matchcontinue expression */
    {
      modelica_metatype _eqMatch = NULL;
      modelica_metatype _varMatch = NULL;
      modelica_metatype _tree = NULL;
      modelica_metatype _varInfo = NULL;
      modelica_metatype _allVars = NULL;
      modelica_metatype _bVarIdcs = NULL;
      modelica_metatype _simVarIdcs = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _simVars = NULL;
      modelica_metatype _eqMapping = NULL;
      modelica_metatype _varMapping = NULL;
      modelica_metatype _m = NULL;
      modelica_metatype _mt = NULL;
      modelica_metatype _simVarMapping = NULL;
      modelica_metatype _htStates = NULL;
      modelica_integer _size;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqMatch has no default value.
      // _varMatch has no default value.
      // _tree has no default value.
      // _varInfo has no default value.
      // _allVars has no default value.
      // _bVarIdcs has no default value.
      // _simVarIdcs has no default value.
      // _eqs has no default value.
      // _vars has no default value.
      // _crefs has no default value.
      // _simVars has no default value.
      // _eqMapping has no default value.
      // _varMapping has no default value.
      // _m has no default value.
      // _mt has no default value.
      // _simVarMapping has no default value.
      // _htStates has no default value.
      // _size has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = _bmapIn;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,8) == 0) goto goto_2;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 6));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 7));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 8));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 9));
          _m = tmpMeta7;
          _mt = tmpMeta8;
          _eqMapping = tmpMeta9;
          _varMapping = tmpMeta10;
          _eqMatch = tmpMeta11;
          _varMatch = tmpMeta12;
          _tree = tmpMeta13;
          _simVarMapping = tmpMeta14;

          /* Pattern-matching assignment */
          tmpMeta15 = _dae;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          _eqs = tmpMeta16;

          _vars = omc_BackendVariable_equationSystemsVarsLst(threadData, _eqs);

          _crefs = omc_List_map(threadData, _vars, boxvar_BackendVariable_varCref);

          _size = listLength(_crefs);

          _bVarIdcs = omc_List_intRange(threadData, _size);

          _simVars = omc_List_map1(threadData, _crefs, boxvar_BaseHashTable_get, _ht);

          /* Pattern-matching assignment */
          tmpMeta17 = _modelInfo;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 10));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 11));
          _varInfo = tmpMeta18;
          _allVars = tmpMeta19;

          _htStates = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_allVars), 2))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, omc_HashTableCrefSimVar_emptyHashTableSized(threadData, ((modelica_integer) 1) + ((modelica_integer)floor((1.4) * (((modelica_real)_size))))));

          _simVarIdcs = omc_List_map2(threadData, _simVars, boxvar_SimCodeUtil_getSimVarIndex, _varInfo, _htStates);

          tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
          _varMapping = omc_SimCodeUtil_makeVarMapTuple(threadData, _simVarIdcs, _bVarIdcs, tmpMeta20);

          omc_List_fold1(threadData, _simVars, boxvar_SimCodeUtil_fillSimVarMapping, _simVarMapping, mmc_mk_integer(((modelica_integer) 1)));
          tmpMeta21 = mmc_mk_box9(3, &SimCode_BackendMapping_BACKENDMAPPING__desc, _m, _mt, _eqMapping, _varMapping, _eqMatch, _varMatch, _tree, _simVarMapping);
          tmpMeta1 = tmpMeta21;
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT205;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _bmapOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _bmapOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpSystMapping(threadData_t *threadData, modelica_metatype _dae, modelica_boolean _isInitial)
{
  modelica_metatype _outTpl = NULL;
  modelica_integer _sizeV;
  modelica_integer _sizeE;
  modelica_metatype _ass1 = NULL;
  modelica_metatype _ass2 = NULL;
  modelica_metatype _m = NULL;
  modelica_metatype _mt = NULL;
  modelica_metatype _matching = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _sizeV has no default value.
  // _sizeE has no default value.
  // _ass1 has no default value.
  // _ass2 has no default value.
  // _m has no default value.
  // _mt has no default value.
  // _matching has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = _dae;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          if (optionNone(tmpMeta7)) goto goto_2;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          if (optionNone(tmpMeta9)) goto goto_2;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 7));
          _m = tmpMeta8;
          _mt = tmpMeta10;
          _matching = tmpMeta11;

          /* Pattern-matching assignment */
          tmpMeta12 = _matching;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,3) == 0) goto goto_2;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          _ass1 = tmpMeta13;
          _ass2 = tmpMeta14;

          _sizeE = omc_BackendDAEUtil_equationArraySizeDAE(threadData, _dae);

          _sizeV = omc_BackendVariable_daenumVariables(threadData, _dae);
          tmpMeta15 = mmc_mk_box6(0, mmc_mk_integer(_sizeE), mmc_mk_integer(_sizeV), _m, _mt, _ass2, _ass1);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta16 = _dae;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 4));
          if (!optionNone(tmpMeta17)) goto goto_2;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 5));
          if (!optionNone(tmpMeta18)) goto goto_2;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 7));
          _matching = tmpMeta19;

          /* Pattern-matching assignment */
          tmpMeta20 = _matching;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,1,3) == 0) goto goto_2;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 3));
          _ass1 = tmpMeta21;
          _ass2 = tmpMeta22;

          omc_BackendDAEUtil_getAdjacencyMatrix(threadData, _dae, _OMC_LIT133, mmc_mk_none(), _isInitial ,&_m ,&_mt);

          _sizeE = omc_BackendDAEUtil_equationArraySizeDAE(threadData, _dae);

          _sizeV = omc_BackendVariable_daenumVariables(threadData, _dae);
          tmpMeta23 = mmc_mk_box6(0, mmc_mk_integer(_sizeE), mmc_mk_integer(_sizeV), _m, _mt, _ass2, _ass1);
          tmpMeta1 = tmpMeta23;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpSystMapping(threadData_t *threadData, modelica_metatype _dae, modelica_metatype _isInitial)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_isInitial);
  _outTpl = omc_SimCodeUtil_setUpSystMapping(threadData, _dae, tmp1);
  /* skip box _outTpl; tuple<#Integer, #Integer, array<list<#Integer>>, array<list<#Integer>>, array<#Integer>, array<#Integer>> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addIntLst(threadData_t *threadData, modelica_metatype _lstIn, modelica_integer _x)
{
  modelica_metatype _lstOut = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lstOut has no default value.
  _lstOut = omc_List_map1(threadData, _lstIn, boxvar_intAdd, mmc_mk_integer(_x));
  _return: OMC_LABEL_UNUSED
  return _lstOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_addIntLst(threadData_t *threadData, modelica_metatype _lstIn, modelica_metatype _x)
{
  modelica_integer tmp1;
  modelica_metatype _lstOut = NULL;
  tmp1 = mmc_unbox_integer(_x);
  _lstOut = omc_SimCodeUtil_addIntLst(threadData, _lstIn, tmp1);
  /* skip box _lstOut; list<#Integer> */
  return _lstOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateInMatching(threadData_t *threadData, modelica_integer _idx, modelica_integer _offset, modelica_metatype _matchingAppend, modelica_metatype _matchingIn)
{
  modelica_metatype _matchingOut = NULL;
  modelica_integer _entry;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _matchingOut has no default value.
  // _entry has no default value.
  _entry = mmc_unbox_integer(arrayGet(_matchingAppend, _idx));

  _matchingOut = arrayUpdate(_matchingIn, _idx + _offset, mmc_mk_integer(_entry));
  _return: OMC_LABEL_UNUSED
  return _matchingOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateInMatching(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _offset, modelica_metatype _matchingAppend, modelica_metatype _matchingIn)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _matchingOut = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  tmp2 = mmc_unbox_integer(_offset);
  _matchingOut = omc_SimCodeUtil_updateInMatching(threadData, tmp1, tmp2, _matchingAppend, _matchingIn);
  /* skip box _matchingOut; array<#Integer> */
  return _matchingOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateInAdjacencyMatrix(threadData_t *threadData, modelica_integer _idx, modelica_integer _offset, modelica_metatype _mAppend, modelica_metatype _mIn)
{
  modelica_metatype _mOut = NULL;
  modelica_metatype _entry = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _mOut has no default value.
  // _entry has no default value.
  _entry = arrayGet(_mAppend, _idx);

  _mOut = arrayUpdate(_mIn, _idx + _offset, _entry);
  _return: OMC_LABEL_UNUSED
  return _mOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateInAdjacencyMatrix(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _offset, modelica_metatype _mAppend, modelica_metatype _mIn)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _mOut = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  tmp2 = mmc_unbox_integer(_offset);
  _mOut = omc_SimCodeUtil_updateInAdjacencyMatrix(threadData, tmp1, tmp2, _mAppend, _mIn);
  /* skip box _mOut; array<list<#Integer>> */
  return _mOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendAdjacencyMatrices(threadData_t *threadData, modelica_metatype _tplIn, modelica_metatype _foldIn)
{
  modelica_metatype _foldOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _foldOut has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _tplIn;
    tmp4_2 = _foldIn;
    {
      modelica_integer _sizeE;
      modelica_integer _sizeV;
      modelica_integer _addV;
      modelica_integer _addE;
      modelica_metatype _eqMatch = NULL;
      modelica_metatype _varMatch = NULL;
      modelica_metatype _eqMatchIn = NULL;
      modelica_metatype _varMatchIn = NULL;
      modelica_metatype _mIn = NULL;
      modelica_metatype _m = NULL;
      modelica_metatype _mtIn = NULL;
      modelica_metatype _mt = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _sizeE has no default value.
      // _sizeV has no default value.
      // _addV has no default value.
      // _addE has no default value.
      // _eqMatch has no default value.
      // _varMatch has no default value.
      // _eqMatchIn has no default value.
      // _varMatchIn has no default value.
      // _mIn has no default value.
      // _m has no default value.
      // _mtIn has no default value.
      // _mt has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _addE = tmp7  /* pattern as ty=Integer */;
          _addV = tmp9  /* pattern as ty=Integer */;
          _m = tmpMeta10;
          _mt = tmpMeta11;
          _eqMatch = tmpMeta12;
          _varMatch = tmpMeta13;
          _sizeE = tmp15  /* pattern as ty=Integer */;
          _sizeV = tmp17  /* pattern as ty=Integer */;
          _mIn = tmpMeta18;
          _mtIn = tmpMeta19;
          _eqMatchIn = tmpMeta20;
          _varMatchIn = tmpMeta21;
          /* Pattern matching succeeded */
          _m = omc_Array_map1(threadData, _m, boxvar_SimCodeUtil_addIntLst, mmc_mk_integer(_sizeV));

          _mt = omc_Array_map1(threadData, _mt, boxvar_SimCodeUtil_addIntLst, mmc_mk_integer(_sizeE));

          _eqMatch = omc_Array_map1(threadData, _eqMatch, boxvar_intAdd, mmc_mk_integer(_sizeV));

          _varMatch = omc_Array_map1(threadData, _varMatch, boxvar_intAdd, mmc_mk_integer(_sizeE));

          _mIn = omc_List_fold2(threadData, omc_List_intRange(threadData, _addE), boxvar_SimCodeUtil_updateInAdjacencyMatrix, mmc_mk_integer(_sizeE), _m, _mIn);

          _mtIn = omc_List_fold2(threadData, omc_List_intRange(threadData, _addV), boxvar_SimCodeUtil_updateInAdjacencyMatrix, mmc_mk_integer(_sizeV), _mt, _mtIn);

          _eqMatchIn = omc_List_fold2(threadData, omc_List_intRange(threadData, _addE), boxvar_SimCodeUtil_updateInMatching, mmc_mk_integer(_sizeE), _eqMatch, _eqMatchIn);

          _varMatchIn = omc_List_fold2(threadData, omc_List_intRange(threadData, _addV), boxvar_SimCodeUtil_updateInMatching, mmc_mk_integer(_sizeV), _varMatch, _varMatchIn);
          tmpMeta22 = mmc_mk_box6(0, mmc_mk_integer(_sizeE + _addE), mmc_mk_integer(_sizeV + _addV), _mIn, _mtIn, _eqMatchIn, _varMatchIn);
          tmpMeta1 = tmpMeta22;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _foldOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _foldOut;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_setUpEqTree__Help(threadData_t *threadData, modelica_integer _iVal, modelica_integer _iRef)
{
  modelica_boolean _oBool;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oBool has no default value.
  _oBool = ((_iVal > ((modelica_integer) 0)) && (_iVal != _iRef));
  _return: OMC_LABEL_UNUSED
  return _oBool;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpEqTree__Help(threadData_t *threadData, modelica_metatype _iVal, modelica_metatype _iRef)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_boolean _oBool;
  modelica_metatype out_oBool;
  tmp1 = mmc_unbox_integer(_iVal);
  tmp2 = mmc_unbox_integer(_iRef);
  _oBool = omc_SimCodeUtil_setUpEqTree__Help(threadData, tmp1, tmp2);
  out_oBool = mmc_mk_icon(_oBool);
  return out_oBool;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpEqTree(threadData_t *threadData, modelica_integer _beq, modelica_metatype _m, modelica_metatype _mt, modelica_metatype _eqMatch, modelica_metatype _varMatch, modelica_metatype _treeIn)
{
  modelica_metatype _treeOut = NULL;
  modelica_integer _assVar;
  modelica_metatype _preEqs = NULL;
  modelica_metatype _depVars = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _treeOut has no default value.
  // _assVar has no default value.
  // _preEqs has no default value.
  // _depVars has no default value.
  _assVar = mmc_unbox_integer(arrayGet(_eqMatch, _beq));

  _depVars = arrayGet(_m, _beq);

  _depVars = omc_List_filter1OnTrue(threadData, _depVars, boxvar_SimCodeUtil_setUpEqTree__Help, mmc_mk_integer(_assVar));

  _preEqs = omc_List_map1(threadData, _depVars, boxvar_Array_getIndexFirst, _varMatch);

  arrayUpdate(_treeIn, _beq, listAppend(arrayGet(_treeIn,_beq) /* DAE.ASUB */, _preEqs));

  _treeOut = _treeIn;
  _return: OMC_LABEL_UNUSED
  return _treeOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setUpEqTree(threadData_t *threadData, modelica_metatype _beq, modelica_metatype _m, modelica_metatype _mt, modelica_metatype _eqMatch, modelica_metatype _varMatch, modelica_metatype _treeIn)
{
  modelica_integer tmp1;
  modelica_metatype _treeOut = NULL;
  tmp1 = mmc_unbox_integer(_beq);
  _treeOut = omc_SimCodeUtil_setUpEqTree(threadData, tmp1, _m, _mt, _eqMatch, _varMatch, _treeIn);
  /* skip box _treeOut; array<list<#Integer>> */
  return _treeOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setUpBackendMapping(threadData_t *threadData, modelica_metatype _dae)
{
  modelica_metatype _mapping = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _mapping has no default value.
  { /* matchcontinue expression */
    {
      modelica_integer _sizeE;
      modelica_integer _sizeV;
      modelica_metatype _eqMatch = NULL;
      modelica_metatype _varMatch = NULL;
      modelica_metatype _tree = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _m = NULL;
      modelica_metatype _mt = NULL;
      modelica_metatype _varMap = NULL;
      modelica_metatype _eqMap = NULL;
      modelica_metatype _simVarMapping = NULL;
      modelica_metatype _tpl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _sizeE has no default value.
      // _sizeV has no default value.
      // _eqMatch has no default value.
      // _varMatch has no default value.
      // _tree has no default value.
      // _eqs has no default value.
      // _m has no default value.
      // _mt has no default value.
      // _varMap has no default value.
      // _eqMap has no default value.
      // _simVarMapping has no default value.
      // _tpl has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = _dae;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          _eqs = tmpMeta7;

          _tpl = omc_List_map1(threadData, _eqs, boxvar_SimCodeUtil_setUpSystMapping, mmc_mk_boolean(omc_BackendDAEUtil_isInitializationDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dae), 3))))));

          _sizeE = mmc_unbox_integer(omc_List_applyAndFold(threadData, _tpl, boxvar_intAdd, boxvar_Util_tuple61, mmc_mk_integer(((modelica_integer) 0))));

          _sizeV = mmc_unbox_integer(omc_List_applyAndFold(threadData, _tpl, boxvar_intAdd, boxvar_Util_tuple62, mmc_mk_integer(((modelica_integer) 0))));

          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _eqMap = tmpMeta8;

          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          _varMap = tmpMeta9;

          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          _simVarMapping = arrayCreate(_sizeV, tmpMeta10);

          _eqMatch = arrayCreate(_sizeE, mmc_mk_integer(((modelica_integer) 0)));

          _varMatch = arrayCreate(_sizeV, mmc_mk_integer(((modelica_integer) 0)));

          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          _m = arrayCreate(_sizeE, tmpMeta11);

          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          _mt = arrayCreate(_sizeV, tmpMeta12);

          /* Pattern-matching assignment */
          tmpMeta13 = mmc_mk_box6(0, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), _m, _mt, _eqMatch, _varMatch);
          tmpMeta14 = omc_List_fold(threadData, _tpl, boxvar_SimCodeUtil_appendAdjacencyMatrices, tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 4));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 5));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 6));
          _m = tmpMeta15;
          _mt = tmpMeta16;
          _eqMatch = tmpMeta17;
          _varMatch = tmpMeta18;

          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          _tree = arrayCreate(_sizeE, tmpMeta19);

          _tree = omc_List_fold4(threadData, omc_List_intRange(threadData, _sizeE), boxvar_SimCodeUtil_setUpEqTree, _m, _mt, _eqMatch, _varMatch, _tree);

          _tree = omc_Array_map(threadData, _tree, boxvar_List_unique);
          tmpMeta20 = mmc_mk_box9(3, &SimCode_BackendMapping_BACKENDMAPPING__desc, _m, _mt, _eqMap, _varMap, _eqMatch, _varMatch, _tree, _simVarMapping);
          tmpMeta1 = tmpMeta20;
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT205;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _mapping = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _mapping;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_equationIndexEqual(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _isEqual;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isEqual has no default value.
  _isEqual = (omc_SimCodeUtil_simEqSystemIndex(threadData, _eq1) == omc_SimCodeUtil_simEqSystemIndex(threadData, _eq2));
  _return: OMC_LABEL_UNUSED
  return _isEqual;
}
modelica_metatype boxptr_SimCodeUtil_equationIndexEqual(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _isEqual;
  modelica_metatype out_isEqual;
  _isEqual = omc_SimCodeUtil_equationIndexEqual(threadData, _eq1, _eq2);
  out_isEqual = mmc_mk_icon(_isEqual);
  return out_isEqual;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_enumerationTypeExists(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inType)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _var;
    tmp4_2 = _inType;
    {
      modelica_metatype _ty = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ty has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,5,5) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,5) == 0) goto tmp3_end;
          
          _ty = tmpMeta6;
          /* Pattern matching succeeded */
          tmp1 = omc_AbsynUtil_pathEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ty), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inType), 3))));
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_enumerationTypeExists(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inType)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_enumerationTypeExists(threadData, _var, _inType);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getEnumerationTypesHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inAccumVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVars = _inAccumVars;
  {
    modelica_metatype _var;
    for (tmpMeta1 = _inVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      { /* match expression */
        modelica_metatype tmp4_1;
        tmp4_1 = _var;
        {
          volatile mmc_switch_type tmp4;
          int tmp5;
          tmp4 = 0;
          for (; tmp4 < 2; tmp4++) {
            switch (MMC_SWITCH_CAST(tmp4)) {
            case 0: {
              modelica_metatype tmpMeta6;
              
              /* Pattern matching succeeded */
              if((omc_Types_isEnumeration(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 13)))) && (!omc_List_exist1(threadData, _outVars, boxvar_SimCodeUtil_enumerationTypeExists, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 13)))))))
              {
                tmpMeta6 = mmc_mk_cons(_var, _outVars);
                _outVars = tmpMeta6;
              }
              goto tmp3_done;
            }
            case 1: {
              
              /* Pattern matching succeeded */
              goto tmp3_done;
            }
            }
            goto tmp3_end;
            tmp3_end: ;
          }
          goto goto_2;
          goto_2:;
          MMC_THROW_INTERNAL();
          goto tmp3_done;
          tmp3_done:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getEnumerationTypes(threadData_t *threadData, modelica_metatype _inVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVars;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 2))), tmpMeta6);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 3))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 4))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 5))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 6))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 7))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 8))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 9))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 10))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 11))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 12))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 13))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 14))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 15))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 16))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 17))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 18))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 19))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 20))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 21))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 22))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 23))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 28))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 24))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 25))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 26))), _outVars);

          _outVars = omc_SimCodeUtil_getEnumerationTypesHelper(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 27))), _outVars);
          tmpMeta1 = listReverse(_outVars);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllSCVarMapping1(threadData_t *threadData, modelica_metatype _iSimVarIdxTpl, modelica_metatype _iMapping)
{
  modelica_metatype _outMapping = NULL;
  modelica_integer _simVarIdx;
  modelica_metatype _simVar = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMapping has no default value.
  // _simVarIdx has no default value.
  // _simVar has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iSimVarIdxTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _simVarIdx = tmp3  /* pattern as ty=Integer */;
  _simVar = tmpMeta4;

  _outMapping = arrayUpdate(_iMapping, _simVarIdx, mmc_mk_some(_simVar));
  _return: OMC_LABEL_UNUSED
  return _outMapping;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllSCVarMapping0(threadData_t *threadData, modelica_metatype _iSimVar, modelica_integer _iOffset, modelica_metatype __omcQ_24in_5FiMapping, modelica_integer __omcQ_24in_5FhighestIdx, modelica_integer *out_highestIdx)
{
  modelica_metatype _iMapping = NULL;
  modelica_integer _highestIdx;
  modelica_integer _simVarIdx;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _iMapping = __omcQ_24in_5FiMapping;
  _highestIdx = __omcQ_24in_5FhighestIdx;
  // _simVarIdx has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iSimVar;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  _simVarIdx = tmp3  /* pattern as ty=Integer */;

  _simVarIdx = ((modelica_integer) 1) + _simVarIdx + _iOffset;

  _highestIdx = ((_simVarIdx > _highestIdx)?_simVarIdx:_highestIdx);

  tmpMeta5 = mmc_mk_box2(0, mmc_mk_integer(_simVarIdx), _iSimVar);
  tmpMeta4 = mmc_mk_cons(tmpMeta5, _iMapping);
  _iMapping = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  if (out_highestIdx) { *out_highestIdx = _highestIdx; }
  return _iMapping;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllSCVarMapping0(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iOffset, modelica_metatype __omcQ_24in_5FiMapping, modelica_metatype __omcQ_24in_5FhighestIdx, modelica_metatype *out_highestIdx)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _highestIdx;
  modelica_metatype _iMapping = NULL;
  tmp1 = mmc_unbox_integer(_iOffset);
  tmp2 = mmc_unbox_integer(__omcQ_24in_5FhighestIdx);
  _iMapping = omc_SimCodeUtil_createAllSCVarMapping0(threadData, _iSimVar, tmp1, __omcQ_24in_5FiMapping, tmp2, &_highestIdx);
  /* skip box _iMapping; list<tuple<#Integer, SimCodeVar.SimVar>> */
  if (out_highestIdx) { *out_highestIdx = mmc_mk_icon(_highestIdx); }
  return _iMapping;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createIdxSCVarMapping(threadData_t *threadData, modelica_metatype _simVars)
{
  modelica_metatype _outMapping = NULL;
  modelica_integer _numStateVars;
  modelica_metatype _stateVars = NULL;
  modelica_metatype _derivativeVars = NULL;
  modelica_metatype _algVars = NULL;
  modelica_metatype _discreteAlgVars = NULL;
  modelica_metatype _intAlgVars = NULL;
  modelica_metatype _boolAlgVars = NULL;
  modelica_metatype _inputVars = NULL;
  modelica_metatype _outputVars = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype _intAliasVars = NULL;
  modelica_metatype _boolAliasVars = NULL;
  modelica_metatype _paramVars = NULL;
  modelica_metatype _intParamVars = NULL;
  modelica_metatype _boolParamVars = NULL;
  modelica_metatype _stringAlgVars = NULL;
  modelica_metatype _stringParamVars = NULL;
  modelica_metatype _stringAliasVars = NULL;
  modelica_metatype _extObjVars = NULL;
  modelica_metatype _constVars = NULL;
  modelica_metatype _intConstVars = NULL;
  modelica_metatype _boolConstVars = NULL;
  modelica_metatype _stringConstVars = NULL;
  modelica_metatype _jacobianVars = NULL;
  modelica_metatype _seedVars = NULL;
  modelica_metatype _realOptimizeConstraintsVars = NULL;
  modelica_metatype _realOptimizeFinalConstraintsVars = NULL;
  modelica_metatype _idxSimVarMappingTplList = NULL;
  modelica_integer _highestIdx;
  modelica_integer _varCount;
  modelica_metatype _mappingArray = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_integer tmp29;
  modelica_metatype tmpMeta30;
  modelica_metatype tmpMeta31;
  modelica_metatype tmpMeta32;
  modelica_integer tmp33;
  modelica_metatype tmpMeta34;
  modelica_metatype tmpMeta35;
  modelica_integer tmp36;
  modelica_metatype tmpMeta37;
  modelica_metatype tmpMeta38;
  modelica_integer tmp39;
  modelica_metatype tmpMeta40;
  modelica_metatype tmpMeta41;
  modelica_integer tmp42;
  modelica_metatype tmpMeta43;
  modelica_metatype tmpMeta44;
  modelica_integer tmp45;
  modelica_metatype tmpMeta46;
  modelica_metatype tmpMeta47;
  modelica_integer tmp48;
  modelica_metatype tmpMeta49;
  modelica_metatype tmpMeta50;
  modelica_integer tmp51;
  modelica_metatype tmpMeta52;
  modelica_metatype tmpMeta53;
  modelica_integer tmp54;
  modelica_metatype tmpMeta55;
  modelica_metatype tmpMeta56;
  modelica_integer tmp57;
  modelica_metatype tmpMeta58;
  modelica_metatype tmpMeta59;
  modelica_integer tmp60;
  modelica_metatype tmpMeta61;
  modelica_metatype tmpMeta62;
  modelica_integer tmp63;
  modelica_metatype tmpMeta64;
  modelica_metatype tmpMeta65;
  modelica_integer tmp66;
  modelica_metatype tmpMeta67;
  modelica_metatype tmpMeta68;
  modelica_integer tmp69;
  modelica_metatype tmpMeta70;
  modelica_metatype tmpMeta71;
  modelica_integer tmp72;
  modelica_metatype tmpMeta73;
  modelica_metatype tmpMeta74;
  modelica_integer tmp75;
  modelica_metatype tmpMeta76;
  modelica_metatype tmpMeta77;
  modelica_integer tmp78;
  modelica_metatype tmpMeta79;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMapping has no default value.
  // _numStateVars has no default value.
  // _stateVars has no default value.
  // _derivativeVars has no default value.
  // _algVars has no default value.
  // _discreteAlgVars has no default value.
  // _intAlgVars has no default value.
  // _boolAlgVars has no default value.
  // _inputVars has no default value.
  // _outputVars has no default value.
  // _aliasVars has no default value.
  // _intAliasVars has no default value.
  // _boolAliasVars has no default value.
  // _paramVars has no default value.
  // _intParamVars has no default value.
  // _boolParamVars has no default value.
  // _stringAlgVars has no default value.
  // _stringParamVars has no default value.
  // _stringAliasVars has no default value.
  // _extObjVars has no default value.
  // _constVars has no default value.
  // _intConstVars has no default value.
  // _boolConstVars has no default value.
  // _stringConstVars has no default value.
  // _jacobianVars has no default value.
  // _seedVars has no default value.
  // _realOptimizeConstraintsVars has no default value.
  // _realOptimizeFinalConstraintsVars has no default value.
  // _idxSimVarMappingTplList has no default value.
  // _highestIdx has no default value.
  // _varCount has no default value.
  // _mappingArray has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _simVars;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 6));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 10));
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 11));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 12));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 13));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 14));
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 15));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 16));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 17));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 18));
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 19));
  tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 20));
  tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 21));
  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 22));
  tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 23));
  tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 24));
  tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 25));
  tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 26));
  tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 27));
  _stateVars = tmpMeta2;
  _derivativeVars = tmpMeta3;
  _algVars = tmpMeta4;
  _discreteAlgVars = tmpMeta5;
  _intAlgVars = tmpMeta6;
  _boolAlgVars = tmpMeta7;
  _inputVars = tmpMeta8;
  _outputVars = tmpMeta9;
  _aliasVars = tmpMeta10;
  _intAliasVars = tmpMeta11;
  _boolAliasVars = tmpMeta12;
  _paramVars = tmpMeta13;
  _intParamVars = tmpMeta14;
  _boolParamVars = tmpMeta15;
  _stringAlgVars = tmpMeta16;
  _stringParamVars = tmpMeta17;
  _stringAliasVars = tmpMeta18;
  _extObjVars = tmpMeta19;
  _constVars = tmpMeta20;
  _intConstVars = tmpMeta21;
  _boolConstVars = tmpMeta22;
  _stringConstVars = tmpMeta23;
  _jacobianVars = tmpMeta24;
  _seedVars = tmpMeta25;
  _realOptimizeConstraintsVars = tmpMeta26;
  _realOptimizeFinalConstraintsVars = tmpMeta27;

  _numStateVars = listLength(_stateVars);

  _varCount = ((modelica_integer) 0);

  /* Pattern-matching tuple assignment */
  tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta31 = omc_List_fold21(threadData, _stateVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), tmpMeta30, mmc_mk_integer(((modelica_integer) 0)), &tmpMeta28);
  _idxSimVarMappingTplList = tmpMeta31;
  tmp29 = mmc_unbox_integer(tmpMeta28);
  _highestIdx = tmp29  /* pattern as ty=Integer */;

  _varCount = _varCount + _numStateVars;

  /* Pattern-matching tuple assignment */
  tmpMeta34 = omc_List_fold21(threadData, _derivativeVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta32);
  _idxSimVarMappingTplList = tmpMeta34;
  tmp33 = mmc_unbox_integer(tmpMeta32);
  _highestIdx = tmp33  /* pattern as ty=Integer */;

  _varCount = _varCount + _numStateVars;

  /* Pattern-matching tuple assignment */
  tmpMeta37 = omc_List_fold21(threadData, _algVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta35);
  _idxSimVarMappingTplList = tmpMeta37;
  tmp36 = mmc_unbox_integer(tmpMeta35);
  _highestIdx = tmp36  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_algVars);

  /* Pattern-matching tuple assignment */
  tmpMeta40 = omc_List_fold21(threadData, _discreteAlgVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta38);
  _idxSimVarMappingTplList = tmpMeta40;
  tmp39 = mmc_unbox_integer(tmpMeta38);
  _highestIdx = tmp39  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_discreteAlgVars);

  /* Pattern-matching tuple assignment */
  tmpMeta43 = omc_List_fold21(threadData, _intAlgVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta41);
  _idxSimVarMappingTplList = tmpMeta43;
  tmp42 = mmc_unbox_integer(tmpMeta41);
  _highestIdx = tmp42  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_intAlgVars);

  /* Pattern-matching tuple assignment */
  tmpMeta46 = omc_List_fold21(threadData, _boolAlgVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta44);
  _idxSimVarMappingTplList = tmpMeta46;
  tmp45 = mmc_unbox_integer(tmpMeta44);
  _highestIdx = tmp45  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_boolAlgVars);

  /* Pattern-matching tuple assignment */
  tmpMeta49 = omc_List_fold21(threadData, _stringAlgVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta47);
  _idxSimVarMappingTplList = tmpMeta49;
  tmp48 = mmc_unbox_integer(tmpMeta47);
  _highestIdx = tmp48  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_stringAlgVars);

  /* Pattern-matching tuple assignment */
  tmpMeta52 = omc_List_fold21(threadData, _inputVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta50);
  _idxSimVarMappingTplList = tmpMeta52;
  tmp51 = mmc_unbox_integer(tmpMeta50);
  _highestIdx = tmp51  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_inputVars);

  /* Pattern-matching tuple assignment */
  tmpMeta55 = omc_List_fold21(threadData, _outputVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta53);
  _idxSimVarMappingTplList = tmpMeta55;
  tmp54 = mmc_unbox_integer(tmpMeta53);
  _highestIdx = tmp54  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_outputVars);

  /* Pattern-matching tuple assignment */
  tmpMeta58 = omc_List_fold21(threadData, _aliasVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta56);
  _idxSimVarMappingTplList = tmpMeta58;
  tmp57 = mmc_unbox_integer(tmpMeta56);
  _highestIdx = tmp57  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_aliasVars);

  /* Pattern-matching tuple assignment */
  tmpMeta61 = omc_List_fold21(threadData, _intAliasVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta59);
  _idxSimVarMappingTplList = tmpMeta61;
  tmp60 = mmc_unbox_integer(tmpMeta59);
  _highestIdx = tmp60  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_intAliasVars);

  /* Pattern-matching tuple assignment */
  tmpMeta64 = omc_List_fold21(threadData, _boolAliasVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta62);
  _idxSimVarMappingTplList = tmpMeta64;
  tmp63 = mmc_unbox_integer(tmpMeta62);
  _highestIdx = tmp63  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_boolAliasVars);

  /* Pattern-matching tuple assignment */
  tmpMeta67 = omc_List_fold21(threadData, _stringAliasVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta65);
  _idxSimVarMappingTplList = tmpMeta67;
  tmp66 = mmc_unbox_integer(tmpMeta65);
  _highestIdx = tmp66  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_stringAliasVars);

  /* Pattern-matching tuple assignment */
  tmpMeta70 = omc_List_fold21(threadData, _paramVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta68);
  _idxSimVarMappingTplList = tmpMeta70;
  tmp69 = mmc_unbox_integer(tmpMeta68);
  _highestIdx = tmp69  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_paramVars);

  /* Pattern-matching tuple assignment */
  tmpMeta73 = omc_List_fold21(threadData, _intParamVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta71);
  _idxSimVarMappingTplList = tmpMeta73;
  tmp72 = mmc_unbox_integer(tmpMeta71);
  _highestIdx = tmp72  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_intParamVars);

  /* Pattern-matching tuple assignment */
  tmpMeta76 = omc_List_fold21(threadData, _boolParamVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta74);
  _idxSimVarMappingTplList = tmpMeta76;
  tmp75 = mmc_unbox_integer(tmpMeta74);
  _highestIdx = tmp75  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_boolParamVars);

  /* Pattern-matching tuple assignment */
  tmpMeta79 = omc_List_fold21(threadData, _stringParamVars, boxvar_SimCodeUtil_createAllSCVarMapping0, mmc_mk_integer(_varCount), _idxSimVarMappingTplList, mmc_mk_integer(_highestIdx), &tmpMeta77);
  _idxSimVarMappingTplList = tmpMeta79;
  tmp78 = mmc_unbox_integer(tmpMeta77);
  _highestIdx = tmp78  /* pattern as ty=Integer */;

  _varCount = _varCount + listLength(_stringParamVars);

  _mappingArray = arrayCreate(_highestIdx, mmc_mk_none());

  _mappingArray = omc_List_fold(threadData, _idxSimVarMappingTplList, boxvar_SimCodeUtil_createAllSCVarMapping1, _mappingArray);

  _outMapping = _mappingArray;
  _return: OMC_LABEL_UNUSED
  return _outMapping;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_isVarIndexListConsecutive(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName)
{
  modelica_boolean _oIsConsecutive;
  modelica_metatype _varName = NULL;
  modelica_integer _arrayIdx;
  modelica_integer _idx;
  modelica_integer _arraySize;
  modelica_integer _currentIndex;
  modelica_metatype _varIndices = NULL;
  modelica_boolean _consecutive;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oIsConsecutive has no default value.
  _varName = _iVarName;
  // _arrayIdx has no default value.
  // _idx has no default value.
  // _arraySize has no default value.
  _currentIndex = ((modelica_integer) -1);
  // _varIndices has no default value.
  _consecutive = 1 /* true */;
  _varName = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _varName);

  if(omc_BaseHashTable_hasKey(threadData, _varName, _iVarToArrayIndexMapping))
  {
    /* Pattern-matching assignment */
    tmpMeta1 = omc_BaseHashTable_get(threadData, _varName, _iVarToArrayIndexMapping);
    tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
    _varIndices = tmpMeta2;

    _arraySize = arrayLength(_varIndices);

    tmp3 = ((modelica_integer) 0); tmp4 = 1; tmp5 = ((modelica_integer) -1) + _arraySize;
    if(!(((tmp4 > 0) && (tmp3 > tmp5)) || ((tmp4 < 0) && (tmp3 < tmp5))))
    {
      modelica_integer _arrayIdx;
      for(_arrayIdx = ((modelica_integer) 0); in_range_integer(_arrayIdx, tmp3, tmp5); _arrayIdx += tmp4)
      {
        _idx = mmc_unbox_integer(arrayGet(_varIndices, _arraySize - _arrayIdx));

        if((_idx < ((modelica_integer) 0)))
        {
          if((_currentIndex == ((modelica_integer) -1)))
          {
            _currentIndex = ((modelica_integer) -1) - _idx;
          }
          else
          {
            _consecutive = (_consecutive && (_currentIndex == (-_idx)));

            _currentIndex = ((modelica_integer) -1) - _idx;
          }
        }
        else
        {
          if((_idx == ((modelica_integer) 0)))
          {
            _currentIndex = ((modelica_integer) -2);

            _consecutive = 0 /* false */;
          }
          else
          {
            if((_currentIndex == ((modelica_integer) -1)))
            {
              _currentIndex = ((modelica_integer) -1) + _idx;
            }
            else
            {
              _consecutive = (_consecutive && (_currentIndex == _idx));

              _currentIndex = ((modelica_integer) -1) + _idx;
            }
          }
        }
      }
    }
  }

  _oIsConsecutive = _consecutive;
  _return: OMC_LABEL_UNUSED
  return _oIsConsecutive;
}
modelica_metatype boxptr_SimCodeUtil_isVarIndexListConsecutive(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName)
{
  modelica_boolean _oIsConsecutive;
  modelica_metatype out_oIsConsecutive;
  _oIsConsecutive = omc_SimCodeUtil_isVarIndexListConsecutive(threadData, _iVarToArrayIndexMapping, _iVarName);
  out_oIsConsecutive = mmc_mk_icon(_oIsConsecutive);
  return out_oIsConsecutive;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_convertIndexToColumnMajor(threadData_t *threadData, modelica_integer _idx, modelica_metatype _arrayDimensions)
{
  modelica_integer _idxOut;
  modelica_integer _idx0;
  modelica_integer _ndim;
  modelica_integer _length;
  modelica_integer _idxi;
  modelica_integer _fac;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _idxOut has no default value.
  // _idx0 has no default value.
  // _ndim has no default value.
  // _length has no default value.
  // _idxi has no default value.
  // _fac has no default value.
  _ndim = listLength(_arrayDimensions);

  _length = mmc_unbox_integer(omc_List_fold(threadData, _arrayDimensions, boxvar_intMul, mmc_mk_integer(((modelica_integer) 1))));

  _idx0 = ((modelica_integer) -1) + _idx;

  _idxOut = ((modelica_integer) 1);

  _fac = ((modelica_integer) 1);

  {
    modelica_metatype _dimi;
    for (tmpMeta1 = _arrayDimensions; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _dimi = MMC_CAR(tmpMeta1);
      tmp2 = mmc_unbox_integer(_dimi);
      if (tmp2 == 0) {MMC_THROW_INTERNAL();}
      _length = modelica_div_integer(_length,tmp2).quot;

      tmp3 = _length;
      if (tmp3 == 0) {MMC_THROW_INTERNAL();}
      _idxi = modelica_div_integer(_idx0,tmp3).quot;

      _idx0 = _idx0 - ((_idxi) * (_length));

      _idxOut = _idxOut + (_idxi) * (_fac);

      _fac = (_fac) * (mmc_unbox_integer(_dimi));
    }
  }
  _return: OMC_LABEL_UNUSED
  return _idxOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_convertIndexToColumnMajor(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _arrayDimensions)
{
  modelica_integer tmp1;
  modelica_integer _idxOut;
  modelica_metatype out_idxOut;
  tmp1 = mmc_unbox_integer(_idx);
  _idxOut = omc_SimCodeUtil_convertIndexToColumnMajor(threadData, tmp1, _arrayDimensions);
  out_idxOut = mmc_mk_icon(_idxOut);
  return out_idxOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getVarIndexInfosByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_boolean _iColumnMajor, modelica_string _iIndexForUndefinedReferences, modelica_string *out_oConcreteVarIndex)
{
  modelica_metatype _oVarIndexList = NULL;
  modelica_string _oConcreteVarIndex = NULL;
  modelica_metatype _varName = NULL;
  modelica_integer _arrayIdx;
  modelica_integer _idx;
  modelica_integer _arraySize;
  modelica_integer _concreteVarIndex;
  modelica_metatype _varIndices = NULL;
  modelica_metatype _tmpVarIndexListNew = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _arraySubscripts = NULL;
  modelica_metatype _arrayDimensions = NULL;
  modelica_metatype _arrayDimensionsReverse = NULL;
  modelica_metatype tmpMeta2;
  modelica_boolean _toColumnMajor;
  modelica_boolean _isContiguous;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_integer tmp10;
  modelica_integer tmp11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVarIndexList has no default value.
  _oConcreteVarIndex = _OMC_LIT31;
  _varName = _iVarName;
  // _arrayIdx has no default value.
  // _idx has no default value.
  // _arraySize has no default value.
  // _concreteVarIndex has no default value.
  // _varIndices has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpVarIndexListNew = tmpMeta1;
  // _arraySubscripts has no default value.
  // _arrayDimensions has no default value.
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _arrayDimensionsReverse = tmpMeta2;
  // _toColumnMajor has no default value.
  // _isContiguous has no default value.
  _arraySubscripts = omc_ComponentReference_crefLastSubs(threadData, _varName);

  _varName = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _varName);

  if(omc_BaseHashTable_hasKey(threadData, _varName, _iVarToArrayIndexMapping))
  {
    /* Pattern-matching assignment */
    tmpMeta3 = omc_BaseHashTable_get(threadData, _varName, _iVarToArrayIndexMapping);
    tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
    tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
    _arrayDimensions = tmpMeta4;
    _varIndices = tmpMeta5;

    _isContiguous = (arrayLength(_varIndices) == ((modelica_integer) 1));

    if(_isContiguous)
    {
      _arraySize = mmc_unbox_integer(omc_List_fold(threadData, _arrayDimensions, boxvar_intMul, mmc_mk_integer(((modelica_integer) 1))));
    }
    else
    {
      _arraySize = arrayLength(_varIndices);
    }

    _concreteVarIndex = omc_SimCodeUtilShared_getScalarElementIndex(threadData, _arraySubscripts, _arrayDimensions);

    _toColumnMajor = (_iColumnMajor && (listLength(_arrayDimensions) > ((modelica_integer) 1)));

    if(_toColumnMajor)
    {
      _concreteVarIndex = omc_SimCodeUtil_convertIndexToColumnMajor(threadData, _concreteVarIndex, _arrayDimensions);

      _arrayDimensionsReverse = listReverse(_arrayDimensions);
    }

    tmp9 = ((modelica_integer) 0); tmp10 = 1; tmp11 = ((modelica_integer) -1) + _arraySize;
    if(!(((tmp10 > 0) && (tmp9 > tmp11)) || ((tmp10 < 0) && (tmp9 < tmp11))))
    {
      modelica_integer _arrayIdx;
      for(_arrayIdx = ((modelica_integer) 0); in_range_integer(_arrayIdx, tmp9, tmp11); _arrayIdx += tmp10)
      {
        _idx = _arraySize - _arrayIdx;

        if(_toColumnMajor)
        {
          _idx = omc_SimCodeUtil_convertIndexToColumnMajor(threadData, _idx, _arrayDimensionsReverse);
        }

        if(_isContiguous)
        {
          _idx = ((modelica_integer) -1) + mmc_unbox_integer(arrayGet(_varIndices, ((modelica_integer) 1))) + _idx;
        }
        else
        {
          _idx = mmc_unbox_integer(arrayGet(_varIndices, _idx));
        }

        if((_idx < ((modelica_integer) 0)))
        {
          tmpMeta6 = mmc_mk_cons(intString(((modelica_integer) -1) - _idx), _tmpVarIndexListNew);
          _tmpVarIndexListNew = tmpMeta6;
        }
        else
        {
          if((_idx == ((modelica_integer) 0)))
          {
            tmpMeta7 = mmc_mk_cons(_iIndexForUndefinedReferences, _tmpVarIndexListNew);
            _tmpVarIndexListNew = tmpMeta7;
          }
          else
          {
            tmpMeta8 = mmc_mk_cons(intString(((modelica_integer) -1) + _idx), _tmpVarIndexListNew);
            _tmpVarIndexListNew = tmpMeta8;
          }
        }
      }
    }

    if((omc_SimCodeUtil_isVarIndexListConsecutive(threadData, _iVarToArrayIndexMapping, _iVarName) && _toColumnMajor))
    {
      _concreteVarIndex = omc_SimCodeUtil_convertIndexToColumnMajor(threadData, _concreteVarIndex, _arrayDimensions);
    }

    _oConcreteVarIndex = listGet(_tmpVarIndexListNew, _concreteVarIndex);
  }

  if(listEmpty(_tmpVarIndexListNew))
  {
    tmpMeta13 = stringAppend(_OMC_LIT209,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _varName));
    tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT210);
    tmpMeta12 = mmc_mk_cons(tmpMeta14, MMC_REFSTRUCTLIT(mmc_nil));
    omc_Error_addMessage(threadData, _OMC_LIT208, tmpMeta12);

    tmpMeta15 = mmc_mk_cons(_iIndexForUndefinedReferences, MMC_REFSTRUCTLIT(mmc_nil));
    _tmpVarIndexListNew = tmpMeta15;

    _oConcreteVarIndex = _iIndexForUndefinedReferences;
  }

  _oVarIndexList = _tmpVarIndexListNew;
  _return: OMC_LABEL_UNUSED
  if (out_oConcreteVarIndex) { *out_oConcreteVarIndex = _oConcreteVarIndex; }
  return _oVarIndexList;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getVarIndexInfosByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_metatype _iColumnMajor, modelica_metatype _iIndexForUndefinedReferences, modelica_metatype *out_oConcreteVarIndex)
{
  modelica_integer tmp1;
  modelica_metatype _oVarIndexList = NULL;
  tmp1 = mmc_unbox_integer(_iColumnMajor);
  _oVarIndexList = omc_SimCodeUtil_getVarIndexInfosByMapping(threadData, _iVarToArrayIndexMapping, _iVarName, tmp1, _iIndexForUndefinedReferences, out_oConcreteVarIndex);
  /* skip box _oVarIndexList; list<String> */
  /* skip box _oConcreteVarIndex; String */
  return _oVarIndexList;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_providesDirectionalDerivative(threadData_t *threadData, modelica_metatype _inSimCode)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inSimCode;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 47));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 4));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_SimCodeUtil_providesDirectionalDerivative(threadData_t *threadData, modelica_metatype _inSimCode)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_providesDirectionalDerivative(threadData, _inSimCode);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_string omc_SimCodeUtil_getVarIndexByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_boolean _iColumnMajor, modelica_string _iIndexForUndefinedReferences)
{
  modelica_string _oConcreteVarIndex = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oConcreteVarIndex has no default value.
  omc_SimCodeUtil_getVarIndexInfosByMapping(threadData, _iVarToArrayIndexMapping, _iVarName, _iColumnMajor, _iIndexForUndefinedReferences ,&_oConcreteVarIndex);
  _return: OMC_LABEL_UNUSED
  return _oConcreteVarIndex;
}
modelica_metatype boxptr_SimCodeUtil_getVarIndexByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_metatype _iColumnMajor, modelica_metatype _iIndexForUndefinedReferences)
{
  modelica_integer tmp1;
  modelica_string _oConcreteVarIndex = NULL;
  tmp1 = mmc_unbox_integer(_iColumnMajor);
  _oConcreteVarIndex = omc_SimCodeUtil_getVarIndexByMapping(threadData, _iVarToArrayIndexMapping, _iVarName, tmp1, _iIndexForUndefinedReferences);
  /* skip box _oConcreteVarIndex; String */
  return _oConcreteVarIndex;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getVarIndexListByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_boolean _iColumnMajor, modelica_string _iIndexForUndefinedReferences)
{
  modelica_metatype _oVarIndexList = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVarIndexList has no default value.
  _oVarIndexList = omc_SimCodeUtil_getVarIndexInfosByMapping(threadData, _iVarToArrayIndexMapping, _iVarName, _iColumnMajor, _iIndexForUndefinedReferences, NULL);
  _return: OMC_LABEL_UNUSED
  return _oVarIndexList;
}
modelica_metatype boxptr_SimCodeUtil_getVarIndexListByMapping(threadData_t *threadData, modelica_metatype _iVarToArrayIndexMapping, modelica_metatype _iVarName, modelica_metatype _iColumnMajor, modelica_metatype _iIndexForUndefinedReferences)
{
  modelica_integer tmp1;
  modelica_metatype _oVarIndexList = NULL;
  tmp1 = mmc_unbox_integer(_iColumnMajor);
  _oVarIndexList = omc_SimCodeUtil_getVarIndexListByMapping(threadData, _iVarToArrayIndexMapping, _iVarName, tmp1, _iIndexForUndefinedReferences);
  /* skip box _oVarIndexList; list<String> */
  return _oVarIndexList;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getHideResult(threadData_t *threadData, modelica_metatype _hideResultExp, modelica_metatype _name, modelica_metatype _source)
{
  modelica_metatype _hideResult = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _hideResult has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _hideResultExp;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!optionNone(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,3,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          if (0 /* false */ != tmp8) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT211;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,3,1) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          if (1 /* true */ != tmp11) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT212;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          
          /* Pattern matching succeeded */
          tmpMeta12 = mmc_mk_cons(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _name), MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addSourceMessage(threadData, _OMC_LIT214, tmpMeta12, omc_ElementSource_getInfo(threadData, _source));
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _hideResult = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _hideResult;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_eqSystemWCET(threadData_t *threadData, modelica_metatype _eqs)
{
  modelica_metatype _tpl = NULL;
  modelica_integer _i;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _tpl has no default value.
  // _i has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = mmc_mk_cons(_eqs, MMC_REFSTRUCTLIT(mmc_nil));
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  omc_SimCodeUtil_traverseExpsEqSystems(threadData, tmpMeta3, boxvar_Expression_complexityTraverse, mmc_mk_integer(((modelica_integer) 0)), tmpMeta4, &tmpMeta1);
  tmp2 = mmc_unbox_integer(tmpMeta1);
  _i = tmp2  /* pattern as ty=Integer */;

  tmpMeta5 = mmc_mk_box2(0, _eqs, mmc_mk_integer(_i));
  _tpl = tmpMeta5;
  _return: OMC_LABEL_UNUSED
  return _tpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimCodeLiterals(threadData_t *threadData, modelica_metatype _simCode, modelica_metatype _literals)
{
  modelica_metatype _outSimCode = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSimCode = _simCode;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[3] = _literals;
  _outSimCode = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outSimCode;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystem(threadData_t *threadData, modelica_metatype _eq, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa)
{
  modelica_metatype _oeq = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oeq has no default value.
  // _oa has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _eq;
    tmp4_2 = _ia;
    {
      modelica_metatype _a = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _exp_ = NULL;
      modelica_metatype _leftexp = NULL;
      modelica_metatype _eq_ = NULL;
      modelica_integer _index;
      modelica_integer _res_index;
      modelica_metatype _cons = NULL;
      modelica_metatype _eqAttr = NULL;
      int tmp4;
      // _a has no default value.
      // _cr has no default value.
      // _source has no default value.
      // _exp has no default value.
      // _exp_ has no default value.
      // _leftexp has no default value.
      // _eq_ has no default value.
      // _index has no default value.
      // _res_index has no default value.
      // _cons has no default value.
      // _eqAttr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_integer tmp6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp6 = mmc_unbox_integer(tmpMeta5);
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _index = tmp6  /* pattern as ty=Integer */;
          _res_index = tmp8  /* pattern as ty=Integer */;
          _exp = tmpMeta9;
          _source = tmpMeta10;
          _eqAttr = tmpMeta11;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _exp_ = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);

          if(referenceEq(_exp, _exp_))
          {
            _eq_ = _eq;
          }
          else
          {
            tmpMeta12 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_index), mmc_mk_integer(_res_index), _exp_, _source, _eqAttr);
            _eq_ = tmpMeta12;
          }
          tmpMeta[0+0] = _eq_;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          
          _index = tmp14  /* pattern as ty=Integer */;
          _res_index = tmp16  /* pattern as ty=Integer */;
          _exp = tmpMeta17;
          _source = tmpMeta18;
          _eqAttr = tmpMeta19;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _exp_ = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);

          if(referenceEq(_exp, _exp_))
          {
            _eq_ = _eq;
          }
          else
          {
            tmpMeta20 = mmc_mk_box7(4, &SimCode_SimEqSystem_SES__FOR__RESIDUAL__desc, mmc_mk_integer(_index), mmc_mk_integer(_res_index), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), _exp_, _source, _eqAttr);
            _eq_ = tmpMeta20;
          }
          tmpMeta[0+0] = _eq_;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _index = tmp22  /* pattern as ty=Integer */;
          _res_index = tmp24  /* pattern as ty=Integer */;
          _exp = tmpMeta25;
          _source = tmpMeta26;
          _eqAttr = tmpMeta27;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _exp_ = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);

          if(referenceEq(_exp, _exp_))
          {
            _eq_ = _eq;
          }
          else
          {
            tmpMeta28 = mmc_mk_box8(5, &SimCode_SimEqSystem_SES__GENERIC__RESIDUAL__desc, mmc_mk_integer(_index), mmc_mk_integer(_res_index), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 5))), _exp_, _source, _eqAttr);
            _eq_ = tmpMeta28;
          }
          tmpMeta[0+0] = _eq_;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _index = tmp30  /* pattern as ty=Integer */;
          _cr = tmpMeta31;
          _exp = tmpMeta32;
          _source = tmpMeta33;
          _eqAttr = tmpMeta34;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _exp_ = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);

          if(referenceEq(_exp, _exp_))
          {
            _eq_ = _eq;
          }
          else
          {
            tmpMeta35 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_index), _cr, _exp_, _source, _eqAttr);
            _eq_ = tmpMeta35;
          }
          tmpMeta[0+0] = _eq_;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp37 = mmc_unbox_integer(tmpMeta36);
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          
          _index = tmp37  /* pattern as ty=Integer */;
          _cr = tmpMeta38;
          _exp = tmpMeta39;
          _source = tmpMeta40;
          _cons = tmpMeta41;
          _eqAttr = tmpMeta42;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _exp_ = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);

          if(referenceEq(_exp, _exp_))
          {
            _eq_ = _eq;
          }
          else
          {
            tmpMeta43 = mmc_mk_box7(7, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__CONSTRAINTS__desc, mmc_mk_integer(_index), _cr, _exp_, _source, _cons, _eqAttr);
            _eq_ = tmpMeta43;
          }
          tmpMeta[0+0] = _eq_;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta44;
          modelica_integer tmp45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp45 = mmc_unbox_integer(tmpMeta44);
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _index = tmp45  /* pattern as ty=Integer */;
          _leftexp = tmpMeta46;
          _exp = tmpMeta47;
          _source = tmpMeta48;
          _eqAttr = tmpMeta49;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          _leftexp = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _leftexp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _leftexp, _a ,&_a);

          _exp = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _exp, _a ,&_a) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _exp, _a ,&_a);
          tmpMeta50 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_index), _leftexp, _exp, _source, _eqAttr);
          tmpMeta[0+0] = tmpMeta50;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 12: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,5) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 13: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 14: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 15: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 16: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 17: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 18: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 19: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,8) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 20: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,7) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 21: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,2) == 0) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _eq;
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT215, _OMC_LIT216);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oeq = tmpMeta[0+0];
  _oa = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _oeq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystems(threadData_t *threadData, modelica_metatype _ieqs, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype _acc, modelica_metatype *out_oa)
{
  modelica_metatype _oeqs = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype _teq = NULL;
  modelica_metatype _racc = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oeqs has no default value.
  _oa = _ia;
  // _teq has no default value.
  _racc = _acc;
  {
    modelica_metatype _eq;
    for (tmpMeta1 = _ieqs; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eq = MMC_CAR(tmpMeta1);
      _teq = omc_SimCodeUtil_traverseExpsEqSystem(threadData, _eq, ((modelica_fnptr) _func), _oa ,&_oa);

      tmpMeta2 = mmc_mk_cons(_teq, _racc);
      _racc = tmpMeta2;
    }
  }

  _oeqs = listReverse(_racc);
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _oeqs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsEqSystemsList(threadData_t *threadData, modelica_metatype _ieqs, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype _acc, modelica_metatype *out_oa)
{
  modelica_metatype _oeqs = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oeqs has no default value.
  // _oa has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _ieqs;
    tmp4_2 = _ia;
    {
      modelica_metatype _eq = NULL;
      modelica_metatype _a = NULL;
      modelica_metatype _eqs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eq has no default value.
      // _a has no default value.
      // _eqs has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = listReverse(_acc);
          tmpMeta[0+1] = _a;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          
          _eq = tmpMeta6;
          _eqs = tmpMeta7;
          _a = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _eq = omc_SimCodeUtil_traverseExpsEqSystems(threadData, _eq, ((modelica_fnptr) _func), _a, tmpMeta8 ,&_a);
          tmpMeta9 = mmc_mk_cons(_eq, _acc);
          /* Tail recursive call */
          _ieqs = _eqs;
          _ia = _a;
          _acc = tmpMeta9;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oeqs = tmpMeta[0+0];
  _oa = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _oeqs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsSubPartition(threadData_t *threadData, modelica_metatype _subPartition, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa)
{
  modelica_metatype _outSubPartition = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSubPartition = _subPartition;
  // _oa has no default value.
  // _eqs has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartition), 3))), ((modelica_fnptr) _func), _ia, tmpMeta1 ,&_oa);

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(7));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_outSubPartition), 7*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[3] = _eqs;
  _outSubPartition = tmpMeta2;

  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartition), 4))), ((modelica_fnptr) _func), _oa, tmpMeta3 ,&_oa);

  tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(7));
  memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_outSubPartition), 7*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[4] = _eqs;
  _outSubPartition = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _outSubPartition;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseExpsPartition(threadData_t *threadData, modelica_metatype _simPartition, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa)
{
  modelica_metatype __omcQ_24mrfa_5F8 = NULL;
  modelica_metatype __omcQ_24mrfa_5F9 = NULL;
  modelica_metatype _outSimPartition = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype _clk = NULL;
  modelica_metatype _subPartitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F8 has no default value.
  // __omcQ_24mrfa_5F9 has no default value.
  _outSimPartition = _simPartition;
  // _oa has no default value.
  // _clk has no default value.
  // _subPartitions has no default value.
  /* Pattern-matching tuple assignment */
  tmpMeta2 = mmc_mk_box2(7, &DAE_Exp_CLKCONST__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simPartition), 2))));
  tmpMeta3 = mmc_mk_box2(7, &DAE_Exp_CLKCONST__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simPartition), 2))));
  tmpMeta4 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), tmpMeta3, _ia, &tmpMeta1) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, tmpMeta2, _ia, &tmpMeta1);
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta4,4,1) == 0) MMC_THROW_INTERNAL();
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  _clk = tmpMeta5;
  _oa = tmpMeta1;

  _subPartitions = omc_List_map1Fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simPartition), 3))), boxvar_SimCodeUtil_traverseExpsSubPartition, ((modelica_fnptr) _func), _oa ,&_oa);

  __omcQ_24mrfa_5F8 = _clk;

  __omcQ_24mrfa_5F9 = _subPartitions;

  tmpMeta6 = mmc_mk_box3(3, &SimCode_ClockedPartition_CLOCKED__PARTITION__desc, __omcQ_24mrfa_5F8, __omcQ_24mrfa_5F9);
  _outSimPartition = tmpMeta6;
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _outSimPartition;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_traverseExpsSimCode(threadData_t *threadData, modelica_metatype _simCode, modelica_fnptr _func, modelica_metatype _ia, modelica_metatype *out_oa)
{
  modelica_metatype _outSimCode = NULL;
  modelica_metatype _oa = NULL;
  modelica_metatype _literals = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _eqs1 = NULL;
  modelica_metatype _partitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSimCode = _simCode;
  // _oa has no default value.
  // _literals has no default value.
  // _eqs has no default value.
  // _eqs1 has no default value.
  // _partitions has no default value.
  _literals = omc_List_mapFold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 3))), ((modelica_fnptr) _func), _ia ,&_oa);

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[3] = _literals;
  _outSimCode = tmpMeta1;

  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 8))), ((modelica_fnptr) _func), _oa, tmpMeta2 ,&_oa);

  tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[8] = _eqs;
  _outSimCode = tmpMeta3;

  _partitions = omc_List_map1Fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 11))), boxvar_SimCodeUtil_traverseExpsPartition, ((modelica_fnptr) _func), _oa ,&_oa);

  tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[11] = _partitions;
  _outSimCode = tmpMeta4;

  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs1 = omc_SimCodeUtil_traverseExpsEqSystemsList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 9))), ((modelica_fnptr) _func), _oa, tmpMeta5 ,&_oa);

  tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[9] = _eqs1;
  _outSimCode = tmpMeta6;

  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs1 = omc_SimCodeUtil_traverseExpsEqSystemsList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 10))), ((modelica_fnptr) _func), _oa, tmpMeta7 ,&_oa);

  tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[10] = _eqs1;
  _outSimCode = tmpMeta8;

  tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 12))), ((modelica_fnptr) _func), _oa, tmpMeta9 ,&_oa);

  tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[12] = _eqs;
  _outSimCode = tmpMeta10;

  tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 14))), ((modelica_fnptr) _func), _oa, tmpMeta11 ,&_oa);

  tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[14] = _eqs;
  _outSimCode = tmpMeta12;

  tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 15))), ((modelica_fnptr) _func), _oa, tmpMeta13 ,&_oa);

  tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[15] = _eqs;
  _outSimCode = tmpMeta14;

  tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 16))), ((modelica_fnptr) _func), _oa, tmpMeta15 ,&_oa);

  tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[16] = _eqs;
  _outSimCode = tmpMeta16;

  tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 17))), ((modelica_fnptr) _func), _oa, tmpMeta17 ,&_oa);

  tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[17] = _eqs;
  _outSimCode = tmpMeta18;

  tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 18))), ((modelica_fnptr) _func), _oa, tmpMeta19 ,&_oa);

  tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[18] = _eqs;
  _outSimCode = tmpMeta20;

  tmpMeta21 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 19))), ((modelica_fnptr) _func), _oa, tmpMeta21 ,&_oa);

  tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[19] = _eqs;
  _outSimCode = tmpMeta22;

  tmpMeta23 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 20))), ((modelica_fnptr) _func), _oa, tmpMeta23 ,&_oa);

  tmpMeta24 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta24), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta24))[20] = _eqs;
  _outSimCode = tmpMeta24;

  tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 21))), ((modelica_fnptr) _func), _oa, tmpMeta25 ,&_oa);

  tmpMeta26 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta26), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta26))[21] = _eqs;
  _outSimCode = tmpMeta26;

  tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 23))), ((modelica_fnptr) _func), _oa, tmpMeta27 ,&_oa);

  tmpMeta28 = MMC_TAGPTR(mmc_alloc_words(54));
  memcpy(MMC_UNTAGPTR(tmpMeta28), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta28))[23] = _eqs;
  _outSimCode = tmpMeta28;
  _return: OMC_LABEL_UNUSED
  if (out_oa) { *out_oa = _oa; }
  return _outSimCode;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_calcPriority(threadData_t *threadData, modelica_metatype _eqs)
{
  modelica_metatype _prio = NULL;
  modelica_integer _i;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _prio has no default value.
  // _i has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  omc_SimCodeUtil_traverseExpsEqSystems(threadData, _eqs, boxvar_Expression_complexityTraverse, mmc_mk_integer(((modelica_integer) 1)), tmpMeta3, &tmpMeta1);
  tmp2 = mmc_unbox_integer(tmpMeta1);
  _i = tmp2  /* pattern as ty=Integer */;

  tmpMeta4 = mmc_mk_box2(0, mmc_mk_integer(_i), _eqs);
  _prio = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  return _prio;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeEqualLengthLists2(threadData_t *threadData, modelica_metatype _elt, modelica_metatype _iq)
{
  modelica_metatype _oq = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oq has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _elt;
    tmp4_2 = _iq;
    {
      modelica_metatype _l1 = NULL;
      modelica_metatype _l2 = NULL;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_metatype _q = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _l1 has no default value.
      // _l2 has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _q has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _i1 = tmp7  /* pattern as ty=Integer */;
          _l1 = tmpMeta8;
          _q = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta13 = omc_PriorityQueue_deleteAndReturnMin(threadData, _q, &tmpMeta9);
          _q = tmpMeta13;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          _i2 = tmp11  /* pattern as ty=Integer */;
          _l2 = tmpMeta12;
          tmpMeta14 = mmc_mk_box2(0, mmc_mk_integer(_i1 + _i2), listAppend(_l2, _l1));
          tmpMeta1 = omc_PriorityQueue_insert(threadData, tmpMeta14, _q);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oq = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeEqualLengthLists(threadData_t *threadData, modelica_metatype _inLst, modelica_integer _i)
{
  modelica_metatype _olst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _olst has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_integer tmp4_2;
    tmp4_1 = _inLst;
    tmp4_2 = _i;
    {
      modelica_metatype _l = NULL;
      modelica_metatype _q = NULL;
      modelica_metatype _prios = NULL;
      modelica_metatype _lst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _l has no default value.
      // _q has no default value.
      // _prios has no default value.
      // _lst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_boolean tmp6;
          modelica_metatype tmpMeta7;
          
          _lst = tmp4_1;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp6 = omc_Flags_isSet(threadData, _OMC_LIT219);
          if (0 /* false */ != tmp6) goto goto_2;

          _l = omc_List_flatten(threadData, _lst);
          tmpMeta7 = mmc_mk_cons(_l, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          if (0 != tmp4_2) goto tmp3_end;
          
          _lst = tmp4_1;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _lst;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (1 != tmp4_2) goto tmp3_end;
          
          _lst = tmp4_1;
          /* Pattern matching succeeded */
          _l = omc_List_flatten(threadData, _lst);
          tmpMeta8 = mmc_mk_cons(_l, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta8;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          
          _lst = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          _q = omc_List_fold(threadData, omc_List_fill(threadData, _OMC_LIT220, _i), boxvar_PriorityQueue_insert, tmpMeta9);

          _prios = omc_List_map(threadData, _lst, boxvar_SimCodeUtil_calcPriority);

          _q = omc_List_fold(threadData, _prios, boxvar_SimCodeUtil_makeEqualLengthLists2, _q);
          tmpMeta1 = omc_List_map(threadData, omc_PriorityQueue_elements(threadData, _q), boxvar_Util_tuple22);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _olst = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _olst;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeEqualLengthLists(threadData_t *threadData, modelica_metatype _inLst, modelica_metatype _i)
{
  modelica_integer tmp1;
  modelica_metatype _olst = NULL;
  tmp1 = mmc_unbox_integer(_i);
  _olst = omc_SimCodeUtil_makeEqualLengthLists(threadData, _inLst, tmp1);
  /* skip box _olst; list<list<SimCode.SimEqSystem>> */
  return _olst;
}

DLLDirection
modelica_integer omc_SimCodeUtil_fileName2fileIndex(threadData_t *threadData, modelica_string _inFileName, modelica_metatype _inFiles)
{
  modelica_integer _outFileIndex;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFileIndex has no default value.
  { /* matchcontinue expression */
    volatile modelica_string tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inFileName;
    tmp4_2 = _inFiles;
    {
      modelica_string _file = NULL;
      modelica_metatype _files = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _file has no default value.
      // _files has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          
          _file = tmp4_1;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmp1 = omc_SimCodeUtil_getFileIndexFromFiles(threadData, _file, _files);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) -1);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outFileIndex = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outFileIndex;
}
modelica_metatype boxptr_SimCodeUtil_fileName2fileIndex(threadData_t *threadData, modelica_metatype _inFileName, modelica_metatype _inFiles)
{
  modelica_integer _outFileIndex;
  modelica_metatype out_outFileIndex;
  _outFileIndex = omc_SimCodeUtil_fileName2fileIndex(threadData, _inFileName, _inFiles);
  out_outFileIndex = mmc_mk_icon(_outFileIndex);
  return out_outFileIndex;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getFileIndexFromFiles(threadData_t *threadData, modelica_string _file, modelica_metatype _files)
{
  modelica_integer _index;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _index has no default value.
  tmpMeta1 = mmc_mk_box3(3, &SimCode_FileInfo_FILEINFO__desc, _file, mmc_mk_boolean(0 /* false */));
  _index = ((modelica_integer) -1) + omc_List_position1OnTrue(threadData, _files, boxvar_SimCodeUtil_equalFileInfo, tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return _index;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getFileIndexFromFiles(threadData_t *threadData, modelica_metatype _file, modelica_metatype _files)
{
  modelica_integer _index;
  modelica_metatype out_index;
  _index = omc_SimCodeUtil_getFileIndexFromFiles(threadData, _file, _files);
  out_index = mmc_mk_icon(_index);
  return out_index;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_greaterFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2)
{
  modelica_boolean _isGreater;
  modelica_string _f1 = NULL;
  modelica_string _f2 = NULL;
  modelica_integer _compare;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isGreater has no default value.
  // _f1 has no default value.
  // _f2 has no default value.
  // _compare has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inFileInfo1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _f1 = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = _inFileInfo2;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  _f2 = tmpMeta4;

  _compare = stringCompare(_f1, _f2);

  _isGreater = (_compare > ((modelica_integer) 0));
  _return: OMC_LABEL_UNUSED
  return _isGreater;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_greaterFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2)
{
  modelica_boolean _isGreater;
  modelica_metatype out_isGreater;
  _isGreater = omc_SimCodeUtil_greaterFileInfo(threadData, _inFileInfo1, _inFileInfo2);
  out_isGreater = mmc_mk_icon(_isGreater);
  return out_isGreater;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_equalFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2)
{
  modelica_boolean _isMatch;
  modelica_string _f1 = NULL;
  modelica_string _f2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isMatch has no default value.
  // _f1 has no default value.
  // _f2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inFileInfo1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _f1 = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = _inFileInfo2;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  _f2 = tmpMeta4;

  _isMatch = (stringEqual(_f1, _f2));
  _return: OMC_LABEL_UNUSED
  return _isMatch;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_equalFileInfo(threadData_t *threadData, modelica_metatype _inFileInfo1, modelica_metatype _inFileInfo2)
{
  modelica_boolean _isMatch;
  modelica_metatype out_isMatch;
  _isMatch = omc_SimCodeUtil_equalFileInfo(threadData, _inFileInfo1, _inFileInfo2);
  out_isMatch = mmc_mk_icon(_isMatch);
  return out_isMatch;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromAbsynInfo(threadData_t *threadData, modelica_metatype _inInfo, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype _fi = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  // _fi has no default value.
  tmpMeta1 = mmc_mk_box3(3, &SimCode_FileInfo_FILEINFO__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inInfo), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inInfo), 3))));
  _fi = tmpMeta1;

  _outFiles = omc_List_consOnTrue(threadData, (!listMember(_fi, _inFiles)), _fi, _inFiles);
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromDAEElementSource(threadData_t *threadData, modelica_metatype _inSource, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  _outFiles = omc_SimCodeUtil_getFilesFromAbsynInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSource), 2))), _inFiles);
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectAllFiles(threadData_t *threadData, modelica_metatype _inSimCode)
{
  modelica_metatype _outSimCode = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _files = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSimCode = _inSimCode;
  // _modelInfo has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _files = tmpMeta1;
  if((!omc_Config_acceptMetaModelicaGrammar(threadData)))
  {
    _modelInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 2)));

    _files = omc_SimCodeUtil_getFilesFromSimVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11))), _files);

    _files = omc_SimCodeUtil_getFilesFromFunctions(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 12))), _files);

    tmpMeta9 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 9))));
    tmpMeta8 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 20))), tmpMeta9);
    tmpMeta7 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 19))), tmpMeta8);
    tmpMeta6 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 18))), tmpMeta7);
    tmpMeta5 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 17))), tmpMeta6);
    tmpMeta4 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 16))), tmpMeta5);
    tmpMeta3 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 15))), tmpMeta4);
    tmpMeta2 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 8))), tmpMeta3);
    _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, tmpMeta2, _files);

    _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 10))), _files);

    _files = omc_SimCodeUtil_getFilesFromExtObjInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 31))), _files);

    _files = omc_SimCodeUtil_getFilesFromJacobianMatrices(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outSimCode), 35))), _files);

    _files = omc_List_sort(threadData, _files, boxvar_SimCodeUtil_greaterFileInfo);

    tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(54));
    memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_outSimCode), 54*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[2] = _modelInfo;
    _outSimCode = tmpMeta10;
  }
  _return: OMC_LABEL_UNUSED
  return _outSimCode;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromJacobianMatrix(threadData_t *threadData, modelica_metatype _inJacobianMatrices, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inJacobianMatrices;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _systems = NULL;
      modelica_metatype _vars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _rest has no default value.
      // _systems has no default value.
      // _vars has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          
          _systems = tmpMeta8;
          _vars = tmpMeta9;
          _rest = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_cons(_systems, MMC_REFSTRUCTLIT(mmc_nil));
          _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, tmpMeta10, _files);

          omc_List_mapFold(threadData, _vars, boxvar_SimCodeUtil_getFilesFromSimVar, _files ,&_files);
          /* Tail recursive call */
          _inJacobianMatrices = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromJacobianMatrices(threadData_t *threadData, modelica_metatype _inJacobianMatrices, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inJacobianMatrices;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _onemat = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _rest has no default value.
      // _onemat has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _onemat = tmpMeta8;
          _rest = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromJacobianMatrix(threadData, _onemat, _files);
          /* Tail recursive call */
          _inJacobianMatrices = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromExtObjInfo(threadData_t *threadData, modelica_metatype _inExtObjInfo, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  omc_List_mapFold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inExtObjInfo), 2))), boxvar_SimCodeUtil_getFilesFromSimVar, _inFiles ,&_outFiles);
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromWhenOperators(threadData_t *threadData, modelica_metatype _inWhenOperators, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inWhenOperators;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _source has no default value.
      // _rest has no default value.
      tmp4 = 0;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,3) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          
          _source = tmpMeta8;
          _rest = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inWhenOperators = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,3) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          
          _source = tmpMeta11;
          _rest = tmpMeta10;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inWhenOperators = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,2,4) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 5));
          
          _source = tmpMeta14;
          _rest = tmpMeta13;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inWhenOperators = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,3,2) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
          
          _source = tmpMeta17;
          _rest = tmpMeta16;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inWhenOperators = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta18 = MMC_CAR(tmp4_1);
          tmpMeta19 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,4,2) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 3));
          
          _source = tmpMeta20;
          _rest = tmpMeta19;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inWhenOperators = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatements(threadData_t *threadData, modelica_metatype _inStatements, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inStatements;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _stmts = NULL;
      modelica_metatype _elsePart = NULL;
      modelica_metatype _elseWhen = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _source has no default value.
      // _rest has no default value.
      // _stmts has no default value.
      // _elsePart has no default value.
      // _elseWhen has no default value.
      tmp4 = 0;
      for (; tmp4 < 16; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,4) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          
          _source = tmpMeta8;
          _rest = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 5));
          
          _source = tmpMeta11;
          _rest = tmpMeta10;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,2,4) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 5));
          
          _source = tmpMeta14;
          _rest = tmpMeta13;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,3,4) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 4));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 5));
          
          _stmts = tmpMeta17;
          _elsePart = tmpMeta18;
          _source = tmpMeta19;
          _rest = tmpMeta16;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);

          _files = omc_SimCodeUtil_getFilesFromStatementsElse(threadData, _elsePart, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta20 = MMC_CAR(tmp4_1);
          tmpMeta21 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,4,6) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 6));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 7));
          
          _stmts = tmpMeta22;
          _source = tmpMeta23;
          _rest = tmpMeta21;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta24 = MMC_CAR(tmp4_1);
          tmpMeta25 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,5,7) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 6));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 8));
          
          _stmts = tmpMeta26;
          _source = tmpMeta27;
          _rest = tmpMeta25;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta28 = MMC_CAR(tmp4_1);
          tmpMeta29 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta28,6,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 3));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 4));
          
          _stmts = tmpMeta30;
          _source = tmpMeta31;
          _rest = tmpMeta29;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta32 = MMC_CAR(tmp4_1);
          tmpMeta33 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,7,6) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 5));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 6));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 7));
          
          _stmts = tmpMeta34;
          _elseWhen = tmpMeta35;
          _source = tmpMeta36;
          _rest = tmpMeta33;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);

          _files = omc_SimCodeUtil_getFilesFromStatementsElseWhen(threadData, _elseWhen, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta37 = MMC_CAR(tmp4_1);
          tmpMeta38 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,8,4) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 5));
          
          _source = tmpMeta39;
          _rest = tmpMeta38;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta40 = MMC_CAR(tmp4_1);
          tmpMeta41 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,9,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 3));
          
          _source = tmpMeta42;
          _rest = tmpMeta41;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta43 = MMC_CAR(tmp4_1);
          tmpMeta44 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta43,10,3) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta43), 4));
          
          _source = tmpMeta45;
          _rest = tmpMeta44;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta46 = MMC_CAR(tmp4_1);
          tmpMeta47 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,11,2) == 0) goto tmp3_end;
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 3));
          
          _source = tmpMeta48;
          _rest = tmpMeta47;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta49 = MMC_CAR(tmp4_1);
          tmpMeta50 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta49,12,1) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          
          _source = tmpMeta51;
          _rest = tmpMeta50;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta52 = MMC_CAR(tmp4_1);
          tmpMeta53 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta52,13,1) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          
          _source = tmpMeta54;
          _rest = tmpMeta53;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta55 = MMC_CAR(tmp4_1);
          tmpMeta56 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,16,2) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 3));
          
          _stmts = tmpMeta57;
          _source = tmpMeta58;
          _rest = tmpMeta56;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          /* Tail recursive call */
          _inStatements = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatementsElseWhen(threadData_t *threadData, modelica_metatype _inStatementOpt, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inStatementOpt;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _stmt = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _stmt has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!optionNone(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          
          _stmt = tmpMeta6;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_cons(_stmt, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_SimCodeUtil_getFilesFromStatements(threadData, tmpMeta7, _files);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromStatementsElse(threadData_t *threadData, modelica_metatype _inElse, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inElse;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _stmts = NULL;
      modelica_metatype _elsePart = NULL;
      int tmp4;
      // _files has no default value.
      // _stmts has no default value.
      // _elsePart has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,3) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _stmts = tmpMeta5;
          _elsePart = tmpMeta6;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          /* Tail recursive call */
          _inElse = _elsePart;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _stmts = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getFilesFromStatements(threadData, _stmts, _files);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystems(threadData_t *threadData, modelica_metatype _inSimEqSystems, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  omc_List_mapFoldList(threadData, _inSimEqSystems, boxvar_SimCodeUtil_getFilesFromSimEqSystem, _inFiles ,&_outFiles);
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystem(threadData_t *threadData, modelica_metatype _inSimEqSystem, modelica_metatype _inFiles, modelica_metatype *out_outFiles)
{
  modelica_metatype _outSimEqSystem = NULL;
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqSystem has no default value.
  // _outFiles has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inSimEqSystem;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _statements = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _simJac = NULL;
      modelica_metatype _systems = NULL;
      modelica_metatype _system = NULL;
      modelica_metatype _systemOpt = NULL;
      modelica_metatype _whenStmtLst = NULL;
      int tmp4;
      // _files has no default value.
      // _source has no default value.
      // _statements has no default value.
      // _vars has no default value.
      // _simJac has no default value.
      // _systems has no default value.
      // _system has no default value.
      // _systemOpt has no default value.
      // _whenStmtLst has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta5;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _source = tmpMeta6;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          
          _source = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta8;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta9;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta10;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _statements = tmpMeta11;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _statements, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _statements = tmpMeta12;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromStatements(threadData, _statements, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 5));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 7));
          
          _vars = tmpMeta14;
          _simJac = tmpMeta15;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          omc_List_mapFold(threadData, _vars, boxvar_SimCodeUtil_getFilesFromSimVar, _files ,&_files);

          _systems = omc_List_map(threadData, _simJac, boxvar_Util_tuple33);

          tmpMeta16 = mmc_mk_cons(_systems, MMC_REFSTRUCTLIT(mmc_nil));
          _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, tmpMeta16, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 3));
          
          _systems = tmpMeta18;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta19 = mmc_mk_cons(_systems, MMC_REFSTRUCTLIT(mmc_nil));
          _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, tmpMeta19, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _system = tmpMeta20;
          _vars = tmpMeta21;
          _systems = tmpMeta22;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          omc_List_mapFold(threadData, _vars, boxvar_SimCodeUtil_getFilesFromSimVar, _files ,&_files);

          tmpMeta24 = mmc_mk_cons(_system, _systems);
          tmpMeta23 = mmc_mk_cons(tmpMeta24, MMC_REFSTRUCTLIT(mmc_nil));
          _files = omc_SimCodeUtil_getFilesFromSimEqSystems(threadData, tmpMeta23, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          
          _whenStmtLst = tmpMeta25;
          _systemOpt = tmpMeta26;
          _source = tmpMeta27;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, _source, _files);

          _files = omc_SimCodeUtil_getFilesFromWhenOperators(threadData, _whenStmtLst, _files);

          _files = omc_SimCodeUtil_getFilesFromSimEqSystemOpt(threadData, _systemOpt, _files);
          tmpMeta[0+0] = _inSimEqSystem;
          tmpMeta[0+1] = _files;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outSimEqSystem = tmpMeta[0+0];
  _outFiles = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outFiles) { *out_outFiles = _outFiles; }
  return _outSimEqSystem;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimEqSystemOpt(threadData_t *threadData, modelica_metatype _inSimEqSystemOpt, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inSimEqSystemOpt;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _sys = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _sys has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!optionNone(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          
          _sys = tmpMeta6;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          omc_SimCodeUtil_getFilesFromSimEqSystem(threadData, _sys, _files ,&_files);
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromFunctions(threadData_t *threadData, modelica_metatype _functions, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _functions;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _info = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _rest has no default value.
      // _info has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,7) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 8));
          
          _info = tmpMeta8;
          _rest = tmpMeta7;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromAbsynInfo(threadData, _info, _files);
          /* Tail recursive call */
          _functions = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,3,14) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 14));
          
          _info = tmpMeta11;
          _rest = tmpMeta10;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromAbsynInfo(threadData, _info, _files);
          /* Tail recursive call */
          _functions = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,4,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 6));
          
          _info = tmpMeta14;
          _rest = tmpMeta13;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          _files = omc_SimCodeUtil_getFilesFromAbsynInfo(threadData, _info, _files);
          /* Tail recursive call */
          _functions = _rest;
          _inFiles = _files;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimVars(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inFiles)
{
  modelica_metatype _outFiles = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFiles has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inSimVars;
    tmp4_2 = _inFiles;
    {
      modelica_metatype _files = NULL;
      modelica_metatype _stateVars = NULL;
      modelica_metatype _derivativeVars = NULL;
      modelica_metatype _algVars = NULL;
      modelica_metatype _discreteAlgVars = NULL;
      modelica_metatype _intAlgVars = NULL;
      modelica_metatype _boolAlgVars = NULL;
      modelica_metatype _inputVars = NULL;
      modelica_metatype _outputVars = NULL;
      modelica_metatype _aliasVars = NULL;
      modelica_metatype _intAliasVars = NULL;
      modelica_metatype _boolAliasVars = NULL;
      modelica_metatype _paramVars = NULL;
      modelica_metatype _intParamVars = NULL;
      modelica_metatype _boolParamVars = NULL;
      modelica_metatype _stringAlgVars = NULL;
      modelica_metatype _stringParamVars = NULL;
      modelica_metatype _stringAliasVars = NULL;
      modelica_metatype _extObjVars = NULL;
      modelica_metatype _constVars = NULL;
      modelica_metatype _intConstVars = NULL;
      modelica_metatype _boolConstVars = NULL;
      modelica_metatype _stringConstVars = NULL;
      modelica_metatype _jacobianVars = NULL;
      modelica_metatype _seedVars = NULL;
      modelica_metatype _realOptimizeConstraintsVars = NULL;
      modelica_metatype _realOptimizeFinalConstraintsVars = NULL;
      modelica_metatype _sensitivityVars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _files has no default value.
      // _stateVars has no default value.
      // _derivativeVars has no default value.
      // _algVars has no default value.
      // _discreteAlgVars has no default value.
      // _intAlgVars has no default value.
      // _boolAlgVars has no default value.
      // _inputVars has no default value.
      // _outputVars has no default value.
      // _aliasVars has no default value.
      // _intAliasVars has no default value.
      // _boolAliasVars has no default value.
      // _paramVars has no default value.
      // _intParamVars has no default value.
      // _boolParamVars has no default value.
      // _stringAlgVars has no default value.
      // _stringParamVars has no default value.
      // _stringAliasVars has no default value.
      // _extObjVars has no default value.
      // _constVars has no default value.
      // _intConstVars has no default value.
      // _boolConstVars has no default value.
      // _stringConstVars has no default value.
      // _jacobianVars has no default value.
      // _seedVars has no default value.
      // _realOptimizeConstraintsVars has no default value.
      // _realOptimizeFinalConstraintsVars has no default value.
      // _sensitivityVars has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 12));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 15));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 16));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 17));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 18));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 20));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 21));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 22));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 23));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 24));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 25));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 26));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 27));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 28));
          
          _stateVars = tmpMeta6;
          _derivativeVars = tmpMeta7;
          _algVars = tmpMeta8;
          _discreteAlgVars = tmpMeta9;
          _intAlgVars = tmpMeta10;
          _boolAlgVars = tmpMeta11;
          _inputVars = tmpMeta12;
          _outputVars = tmpMeta13;
          _aliasVars = tmpMeta14;
          _intAliasVars = tmpMeta15;
          _boolAliasVars = tmpMeta16;
          _paramVars = tmpMeta17;
          _intParamVars = tmpMeta18;
          _boolParamVars = tmpMeta19;
          _stringAlgVars = tmpMeta20;
          _stringParamVars = tmpMeta21;
          _stringAliasVars = tmpMeta22;
          _extObjVars = tmpMeta23;
          _constVars = tmpMeta24;
          _intConstVars = tmpMeta25;
          _boolConstVars = tmpMeta26;
          _stringConstVars = tmpMeta27;
          _jacobianVars = tmpMeta28;
          _seedVars = tmpMeta29;
          _realOptimizeConstraintsVars = tmpMeta30;
          _realOptimizeFinalConstraintsVars = tmpMeta31;
          _sensitivityVars = tmpMeta32;
          _files = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta33 = mmc_mk_cons(_stateVars, mmc_mk_cons(_derivativeVars, mmc_mk_cons(_algVars, mmc_mk_cons(_discreteAlgVars, mmc_mk_cons(_intAlgVars, mmc_mk_cons(_boolAlgVars, mmc_mk_cons(_inputVars, mmc_mk_cons(_outputVars, mmc_mk_cons(_aliasVars, mmc_mk_cons(_intAliasVars, mmc_mk_cons(_boolAliasVars, mmc_mk_cons(_paramVars, mmc_mk_cons(_intParamVars, mmc_mk_cons(_boolParamVars, mmc_mk_cons(_stringAlgVars, mmc_mk_cons(_stringParamVars, mmc_mk_cons(_stringAliasVars, mmc_mk_cons(_extObjVars, mmc_mk_cons(_constVars, mmc_mk_cons(_intConstVars, mmc_mk_cons(_boolConstVars, mmc_mk_cons(_stringConstVars, mmc_mk_cons(_jacobianVars, mmc_mk_cons(_seedVars, mmc_mk_cons(_realOptimizeConstraintsVars, mmc_mk_cons(_realOptimizeFinalConstraintsVars, mmc_mk_cons(_sensitivityVars, MMC_REFSTRUCTLIT(mmc_nil))))))))))))))))))))))))))));
          omc_List_mapFoldList(threadData, tmpMeta33, boxvar_SimCodeUtil_getFilesFromSimVar, _files ,&_files);
          tmpMeta1 = _files;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFiles = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFiles;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFilesFromSimVar(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype _inFiles, modelica_metatype *out_outFiles)
{
  modelica_metatype _var = NULL;
  modelica_metatype _outFiles = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _var = __omcQ_24in_5Fvar;
  // _outFiles has no default value.
  _outFiles = omc_SimCodeUtil_getFilesFromDAEElementSource(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 17))), _inFiles);
  _return: OMC_LABEL_UNUSED
  if (out_outFiles) { *out_outFiles = _outFiles; }
  return _var;
}

DLLDirection
modelica_integer omc_SimCodeUtil_countDynamicExternalFunctions(threadData_t *threadData, modelica_metatype _inFncLst)
{
  modelica_integer _outDynLoadFuncs;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDynLoadFuncs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inFncLst;
    {
      modelica_metatype _rest = NULL;
      modelica_integer _i;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _i has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 0);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,3,14) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 15));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          if (1 /* true */ != tmp9) goto tmp3_end;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _i = omc_SimCodeUtil_countDynamicExternalFunctions(threadData, _rest);
          tmp1 = ((modelica_integer) 1) + _i;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          _rest = tmpMeta11;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _inFncLst = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outDynLoadFuncs = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outDynLoadFuncs;
}
modelica_metatype boxptr_SimCodeUtil_countDynamicExternalFunctions(threadData_t *threadData, modelica_metatype _inFncLst)
{
  modelica_integer _outDynLoadFuncs;
  modelica_metatype out_outDynLoadFuncs;
  _outDynLoadFuncs = omc_SimCodeUtil_countDynamicExternalFunctions(threadData, _inFncLst);
  out_outDynLoadFuncs = mmc_mk_icon(_outDynLoadFuncs);
  return out_outDynLoadFuncs;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_compareSimVarTupleIndexGt(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_integer _index1;
  modelica_integer _index2;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _result has no default value.
  // _index1 has no default value.
  // _index2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _var1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 19));
  if (optionNone(tmpMeta3)) MMC_THROW_INTERNAL();
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _index1 = tmp5  /* pattern as ty=Integer */;

  /* Pattern-matching assignment */
  tmpMeta6 = _var2;
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 19));
  if (optionNone(tmpMeta8)) MMC_THROW_INTERNAL();
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  _index2 = tmp10  /* pattern as ty=Integer */;

  _result = (_index1 > _index2);
  _return: OMC_LABEL_UNUSED
  return _result;
}
modelica_metatype boxptr_SimCodeUtil_compareSimVarTupleIndexGt(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_metatype out_result;
  _result = omc_SimCodeUtil_compareSimVarTupleIndexGt(threadData, _var1, _var2);
  out_result = mmc_mk_icon(_result);
  return out_result;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_compareVarIndexGt(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_integer _index1;
  modelica_integer _index2;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_integer tmp8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _result has no default value.
  // _index1 has no default value.
  // _index2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _var1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 19));
  if (optionNone(tmpMeta2)) MMC_THROW_INTERNAL();
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
  tmp4 = mmc_unbox_integer(tmpMeta3);
  _index1 = tmp4  /* pattern as ty=Integer */;

  /* Pattern-matching assignment */
  tmpMeta5 = _var2;
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 19));
  if (optionNone(tmpMeta6)) MMC_THROW_INTERNAL();
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
  tmp8 = mmc_unbox_integer(tmpMeta7);
  _index2 = tmp8  /* pattern as ty=Integer */;

  _result = (_index1 > _index2);
  _return: OMC_LABEL_UNUSED
  return _result;
}
modelica_metatype boxptr_SimCodeUtil_compareVarIndexGt(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_metatype out_result;
  _result = omc_SimCodeUtil_compareVarIndexGt(threadData, _var1, _var2);
  out_result = mmc_mk_icon(_result);
  return out_result;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_compareSimVarName(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_metatype _name1 = NULL;
  modelica_metatype _name2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _result has no default value.
  // _name1 has no default value.
  // _name2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _var1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _name1 = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = _var2;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  _name2 = tmpMeta4;

  _result = omc_ComponentReferenceBasics_crefEqual(threadData, _name1, _name2);
  _return: OMC_LABEL_UNUSED
  return _result;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_compareSimVarName(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _result;
  modelica_metatype out_result;
  _result = omc_SimCodeUtil_compareSimVarName(threadData, _var1, _var2);
  out_result = mmc_mk_icon(_result);
  return out_result;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_dimensions(threadData_t *threadData, modelica_metatype _dae_low, modelica_integer *out_OutInteger2)
{
  modelica_integer _OutInteger1;
  modelica_integer _OutInteger2;
  modelica_integer tmp1_c0 __attribute__((unused)) = 0;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _OutInteger1 has no default value.
  // _OutInteger2 has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _dae_low;
    {
      modelica_metatype _ordered_states = NULL;
      modelica_metatype _eqsystems = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ordered_states has no default value.
      // _eqsystems has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _eqsystems = tmpMeta6;
          /* Pattern matching succeeded */
          _ordered_states = omc_SimCodeUtil_setVariableDerIndex(threadData, _dae_low, _eqsystems);
          tmp1_c0 = omc_SimCodeUtil_calculateVariableDimensions(threadData, _ordered_states, ((modelica_integer) 0), ((modelica_integer) 0), &tmp1_c1);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT221),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _OutInteger1 = tmp1_c0;
  _OutInteger2 = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_OutInteger2) { *out_OutInteger2 = _OutInteger2; }
  return _OutInteger1;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dimensions(threadData_t *threadData, modelica_metatype _dae_low, modelica_metatype *out_OutInteger2)
{
  modelica_integer _OutInteger2;
  modelica_integer _OutInteger1;
  modelica_metatype out_OutInteger1;
  _OutInteger1 = omc_SimCodeUtil_dimensions(threadData, _dae_low, &_OutInteger2);
  out_OutInteger1 = mmc_mk_icon(_OutInteger1);
  if (out_OutInteger2) { *out_OutInteger2 = mmc_mk_icon(_OutInteger2); }
  return out_OutInteger1;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_calculateVariableDimensions(threadData_t *threadData, modelica_metatype _in_vars, modelica_integer _inNvar1, modelica_integer _inNvar2, modelica_integer *out_OutInteger2)
{
  modelica_integer _OutInteger1;
  modelica_integer _OutInteger2;
  modelica_integer tmp1_c0 __attribute__((unused)) = 0;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _OutInteger1 has no default value.
  // _OutInteger2 has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _in_vars;
    {
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1_c0 = _inNvar1;
          tmp1_c1 = _inNvar2;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          if (0 != tmp9) goto tmp3_end;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _in_vars = _rest;
          _inNvar1 = ((modelica_integer) 1) + _inNvar1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          _rest = tmpMeta11;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _in_vars = _rest;
          _inNvar2 = ((modelica_integer) 1) + _inNvar2;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _OutInteger1 = tmp1_c0;
  _OutInteger2 = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_OutInteger2) { *out_OutInteger2 = _OutInteger2; }
  return _OutInteger1;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_calculateVariableDimensions(threadData_t *threadData, modelica_metatype _in_vars, modelica_metatype _inNvar1, modelica_metatype _inNvar2, modelica_metatype *out_OutInteger2)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _OutInteger2;
  modelica_integer _OutInteger1;
  modelica_metatype out_OutInteger1;
  tmp1 = mmc_unbox_integer(_inNvar1);
  tmp2 = mmc_unbox_integer(_inNvar2);
  _OutInteger1 = omc_SimCodeUtil_calculateVariableDimensions(threadData, _in_vars, tmp1, tmp2, &_OutInteger2);
  out_OutInteger1 = mmc_mk_icon(_OutInteger1);
  if (out_OutInteger2) { *out_OutInteger2 = mmc_mk_icon(_OutInteger2); }
  return out_OutInteger1;
}

static modelica_metatype closure6_ComponentReferenceBasics_crefEqual(threadData_t *thData, modelica_metatype closure, modelica_metatype inComponentRef1)
{
  modelica_metatype inComponentRef2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefEqual(thData, inComponentRef1, inComponentRef2);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData_t *threadData, modelica_metatype _inRefs, modelica_metatype _firstOrderInSec)
{
  modelica_metatype _outRefs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outRefs has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inRefs;
    {
      modelica_metatype _rest = NULL;
      modelica_integer _idx;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _idx has no default value.
      // _cr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_boolean tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          
          _cr = tmpMeta9;
          _rest = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta10 = mmc_mk_box1(0, _cr);
          tmp11 = omc_List_any(threadData, _firstOrderInSec, (modelica_fnptr) mmc_mk_box2(0,closure6_ComponentReferenceBasics_crefEqual,tmpMeta10));
          if (1 /* true */ != tmp11) goto goto_2;

          _rest = omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData, _rest, _firstOrderInSec);
          tmpMeta13 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) 2)));
          tmpMeta12 = mmc_mk_cons(tmpMeta13, _rest);
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta14 = MMC_CAR(tmp4_1);
          tmpMeta15 = MMC_CDR(tmp4_1);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 1));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          if (1 != tmp18) goto tmp3_end;
          _cr = tmpMeta16;
          _rest = tmpMeta15;
          /* Pattern matching succeeded */
          _rest = omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData, _rest, _firstOrderInSec);
          tmpMeta20 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) 1)));
          tmpMeta19 = mmc_mk_cons(tmpMeta20, _rest);
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta21 = MMC_CAR(tmp4_1);
          tmpMeta22 = MMC_CDR(tmp4_1);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          _cr = tmpMeta23;
          _idx = tmp25  /* pattern as ty=Integer */;
          _rest = tmpMeta22;
          /* Pattern matching succeeded */
          _rest = omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData, _rest, _firstOrderInSec);
          tmpMeta27 = mmc_mk_box2(0, _cr, mmc_mk_integer(_idx));
          tmpMeta26 = mmc_mk_cons(tmpMeta27, _rest);
          tmpMeta1 = tmpMeta26;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outRefs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outRefs;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_locateDerAndSerachOtherSide22(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers)
{
  modelica_integer _oi;
  modelica_metatype _firstOrderDers = NULL;
  modelica_integer tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oi has no default value.
  // _firstOrderDers has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEqns;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _cr has no default value.
      // _rest has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmp1_c0 = ((modelica_integer) 0);
          tmpMeta[0+1] = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_boolean tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,0,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          
          _e1 = tmpMeta9;
          _e2 = tmpMeta10;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp11 = omc_ExpressionBasics_expEqual(threadData, _inDer, _e1);
          if (1 /* true */ != tmp11) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta12 = omc_Expression_extractCrefsFromExp(threadData, _e1);
          if (listEmpty(tmpMeta12)) goto goto_2;
          tmpMeta13 = MMC_CAR(tmpMeta12);
          tmpMeta14 = MMC_CDR(tmpMeta12);
          if (!listEmpty(tmpMeta14)) goto goto_2;
          _cr = tmpMeta13;

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_BackendDump_debugStrExpStrExpStrExpStr(threadData, _OMC_LIT222, _inDer, _OMC_LIT223, _e1, _OMC_LIT224, _e2, _OMC_LIT48);
          }
          tmpMeta15 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmp1_c0 = ((modelica_integer) 1);
          tmpMeta[0+1] = tmpMeta15;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_boolean tmp20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta16 = MMC_CAR(tmp4_1);
          tmpMeta17 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,0,4) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
          
          _e1 = tmpMeta18;
          _e2 = tmpMeta19;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp20 = omc_ExpressionBasics_expEqual(threadData, _inDer, _e2);
          if (1 /* true */ != tmp20) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta21 = omc_Expression_extractCrefsFromExp(threadData, _e2);
          if (listEmpty(tmpMeta21)) goto goto_2;
          tmpMeta22 = MMC_CAR(tmpMeta21);
          tmpMeta23 = MMC_CDR(tmpMeta21);
          if (!listEmpty(tmpMeta23)) goto goto_2;
          _cr = tmpMeta22;

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_BackendDump_debugStrExpStrExpStrExpStr(threadData, _OMC_LIT222, _inDer, _OMC_LIT223, _e1, _OMC_LIT224, _e2, _OMC_LIT48);
          }
          tmpMeta24 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmp1_c0 = ((modelica_integer) 1);
          tmpMeta[0+1] = tmpMeta24;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta25 = MMC_CAR(tmp4_1);
          tmpMeta26 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,0,4) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 3));
          
          _e1 = tmpMeta27;
          _e2 = tmpMeta28;
          _rest = tmpMeta26;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_BackendDump_debugExpStrExpStrExpStr(threadData, _inDer, _OMC_LIT228, _e1, _OMC_LIT224, _e2, _OMC_LIT48);
          }
          tmp1_c0 = omc_SimCodeUtil_locateDerAndSerachOtherSide22(threadData, _inDer, _rest, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oi = tmp1_c0;
  _firstOrderDers = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_firstOrderDers) { *out_firstOrderDers = _firstOrderDers; }
  return _oi;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_locateDerAndSerachOtherSide22(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers)
{
  modelica_integer _oi;
  modelica_metatype out_oi;
  _oi = omc_SimCodeUtil_locateDerAndSerachOtherSide22(threadData, _inDer, _inEqns, out_firstOrderDers);
  out_oi = mmc_mk_icon(_oi);
  /* skip box _firstOrderDers; list<DAE.ComponentRef> */
  return out_oi;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_locateDerAndSerachOtherSide2(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers)
{
  modelica_integer _oi;
  modelica_metatype _firstOrderDers = NULL;
  modelica_integer tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oi has no default value.
  // _firstOrderDers has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inDer;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,6,2) == 0) goto tmp3_end;
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1_c0 = omc_SimCodeUtil_locateDerAndSerachOtherSide22(threadData, _inDer, _inEqns, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmp1_c0 = ((modelica_integer) 0);
          tmpMeta[0+1] = tmpMeta9;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oi = tmp1_c0;
  _firstOrderDers = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_firstOrderDers) { *out_firstOrderDers = _firstOrderDers; }
  return _oi;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_locateDerAndSerachOtherSide2(threadData_t *threadData, modelica_metatype _inDer, modelica_metatype _inEqns, modelica_metatype *out_firstOrderDers)
{
  modelica_integer _oi;
  modelica_metatype out_oi;
  _oi = omc_SimCodeUtil_locateDerAndSerachOtherSide2(threadData, _inDer, _inEqns, out_firstOrderDers);
  out_oi = mmc_mk_icon(_oi);
  /* skip box _firstOrderDers; list<DAE.ComponentRef> */
  return out_oi;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData_t *threadData, modelica_metatype _derExp, modelica_metatype _inEqns, modelica_metatype _inEqnsOrg, modelica_metatype *out_sysOrdOneVars)
{
  modelica_metatype _out = NULL;
  modelica_metatype _sysOrdOneVars = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _out has no default value.
  // _sysOrdOneVars has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _derExp;
    tmp4_2 = _inEqns;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _deriveVar = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _eqsOrg = NULL;
      modelica_metatype _eq = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _cr = NULL;
      modelica_integer _rec;
      modelica_integer _i1;
      modelica_metatype _highestIndex = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _deriveVar has no default value.
      // _eqs has no default value.
      // _eqsOrg has no default value.
      // _eq has no default value.
      // _crefs has no default value.
      // _cr has no default value.
      // _rec has no default value.
      // _i1 has no default value.
      // _highestIndex has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,6,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          
          _cr = tmpMeta9;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta10 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta10;
          tmpMeta[0+1] = tmpMeta11;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_boolean tmp20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          modelica_boolean tmp33;
          modelica_metatype tmpMeta34;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_2);
          tmpMeta13 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,0,4) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta16)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmpMeta16);
          tmpMeta18 = MMC_CDR(tmpMeta16);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,6,2) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          if (!listEmpty(tmpMeta18)) goto tmp3_end;
          
          _eq = tmpMeta12;
          _e1 = tmpMeta14;
          _e2 = tmpMeta15;
          _eqs = tmpMeta13;
          _deriveVar = tmpMeta17;
          _cr = tmpMeta19;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp20 = omc_ExpressionBasics_expEqual(threadData, _e1, _derExp);
          if (1 /* true */ != tmp20) goto goto_2;

          _eqsOrg = omc_List_removeOnTrue(threadData, _eq, boxvar_valueEq, _inEqnsOrg);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            tmpMeta21 = stringAppend(_OMC_LIT229,omc_ExpressionBasics_printExpStr(threadData, _derExp));
            tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT230);
            tmpMeta23 = stringAppend(tmpMeta22,omc_ExpressionBasics_printExpStr(threadData, _e2));
            tmpMeta24 = stringAppend(tmpMeta23,_OMC_LIT231);
            tmpMeta25 = stringAppend(tmpMeta24,omc_ExpressionBasics_printExpStr(threadData, _deriveVar));
            tmpMeta26 = stringAppend(tmpMeta25,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta26),stdout);
          }

          tmpMeta27 = mmc_mk_cons(_e2, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta28 = mmc_mk_box4(16, &DAE_Exp_CALL__desc, _OMC_LIT233, tmpMeta27, _OMC_LIT236);
          _rec = omc_SimCodeUtil_locateDerAndSerachOtherSide2(threadData, tmpMeta28, _eqsOrg ,&_crefs);

          /* Pattern-matching tuple assignment */
          tmpMeta29 = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _eqsOrg, NULL);
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          tmp31 = mmc_unbox_integer(tmpMeta30);
          _highestIndex = tmpMeta29;
          _i1 = tmp31  /* pattern as ty=Integer */;

          _rec = ((modelica_integer) 1) + _rec;

          tmp33 = (modelica_boolean)(_i1 > _rec);
          if(tmp33)
          {
            tmpMeta34 = _highestIndex;
          }
          else
          {
            tmpMeta32 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) -1) + _rec));
            tmpMeta34 = tmpMeta32;
          }
          _highestIndex = tmpMeta34;
          tmpMeta[0+0] = _highestIndex;
          tmpMeta[0+1] = _crefs;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_boolean tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_integer tmp54;
          modelica_metatype tmpMeta55;
          modelica_boolean tmp56;
          modelica_metatype tmpMeta57;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta35 = MMC_CAR(tmp4_2);
          tmpMeta36 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,0,4) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta39)) goto tmp3_end;
          tmpMeta40 = MMC_CAR(tmpMeta39);
          tmpMeta41 = MMC_CDR(tmpMeta39);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,6,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 2));
          if (!listEmpty(tmpMeta41)) goto tmp3_end;
          
          _eq = tmpMeta35;
          _e1 = tmpMeta37;
          _e2 = tmpMeta38;
          _eqs = tmpMeta36;
          _deriveVar = tmpMeta40;
          _cr = tmpMeta42;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp43 = omc_ExpressionBasics_expEqual(threadData, _e2, _derExp);
          if (1 /* true */ != tmp43) goto goto_2;

          _eqsOrg = omc_List_removeOnTrue(threadData, _eq, boxvar_valueEq, _inEqnsOrg);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            tmpMeta44 = stringAppend(_OMC_LIT229,omc_ExpressionBasics_printExpStr(threadData, _derExp));
            tmpMeta45 = stringAppend(tmpMeta44,_OMC_LIT230);
            tmpMeta46 = stringAppend(tmpMeta45,omc_ExpressionBasics_printExpStr(threadData, _e1));
            tmpMeta47 = stringAppend(tmpMeta46,_OMC_LIT231);
            tmpMeta48 = stringAppend(tmpMeta47,omc_ExpressionBasics_printExpStr(threadData, _deriveVar));
            tmpMeta49 = stringAppend(tmpMeta48,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta49),stdout);
          }

          tmpMeta50 = mmc_mk_cons(_e1, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta51 = mmc_mk_box4(16, &DAE_Exp_CALL__desc, _OMC_LIT233, tmpMeta50, _OMC_LIT236);
          _rec = omc_SimCodeUtil_locateDerAndSerachOtherSide2(threadData, tmpMeta51, _eqsOrg ,&_crefs);

          /* Pattern-matching tuple assignment */
          tmpMeta52 = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _eqsOrg, NULL);
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          tmp54 = mmc_unbox_integer(tmpMeta53);
          _highestIndex = tmpMeta52;
          _i1 = tmp54  /* pattern as ty=Integer */;

          _rec = ((modelica_integer) 1) + _rec;

          tmp56 = (modelica_boolean)(_i1 > _rec);
          if(tmp56)
          {
            tmpMeta57 = _highestIndex;
          }
          else
          {
            tmpMeta55 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) -1) + _rec));
            tmpMeta57 = tmpMeta55;
          }
          _highestIndex = tmpMeta57;
          tmpMeta[0+0] = _highestIndex;
          tmpMeta[0+1] = _crefs;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_boolean tmp62;
          modelica_boolean tmp63;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta58 = MMC_CAR(tmp4_2);
          tmpMeta59 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,0,4) == 0) goto tmp3_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 3));
          
          _e1 = tmpMeta60;
          _e2 = tmpMeta61;
          _eqs = tmpMeta59;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp62 = omc_ExpressionBasics_expEqual(threadData, _e1, _derExp);
          if (0 /* false */ != tmp62) goto goto_2;

          /* Pattern-matching assignment */
          tmp63 = omc_ExpressionBasics_expEqual(threadData, _e2, _derExp);
          if (0 /* false */ != tmp63) goto goto_2;
          tmpMeta[0+0] = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _inEqnsOrg, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_boolean tmp68;
          modelica_boolean tmp69;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta64 = MMC_CAR(tmp4_2);
          tmpMeta65 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta64,1,6) == 0) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 3));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 4));
          
          _e1 = tmpMeta66;
          _e2 = tmpMeta67;
          _eqs = tmpMeta65;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp68 = omc_ExpressionBasics_expEqual(threadData, _e1, _derExp);
          if (0 /* false */ != tmp68) goto goto_2;

          /* Pattern-matching assignment */
          tmp69 = omc_ExpressionBasics_expEqual(threadData, _e2, _derExp);
          if (0 /* false */ != tmp69) goto goto_2;
          tmpMeta[0+0] = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _inEqnsOrg, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_boolean tmp74;
          modelica_boolean tmp75;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta70 = MMC_CAR(tmp4_2);
          tmpMeta71 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta70,6,5) == 0) goto tmp3_end;
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 3));
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 4));
          
          _e1 = tmpMeta72;
          _e2 = tmpMeta73;
          _eqs = tmpMeta71;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp74 = omc_ExpressionBasics_expEqual(threadData, _e1, _derExp);
          if (0 /* false */ != tmp74) goto goto_2;

          /* Pattern-matching assignment */
          tmp75 = omc_ExpressionBasics_expEqual(threadData, _e2, _derExp);
          if (0 /* false */ != tmp75) goto goto_2;
          tmpMeta[0+0] = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _inEqnsOrg, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta76 = MMC_CAR(tmp4_2);
          tmpMeta77 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta76,7,5) == 0) goto tmp3_end;
          
          _eqs = tmpMeta77;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT237),stdout);
          }
          tmpMeta[0+0] = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _inEqnsOrg, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta78 = MMC_CAR(tmp4_2);
          tmpMeta79 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta78,4,5) == 0) goto tmp3_end;
          
          _eqs = tmpMeta79;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT238),stdout);
          }
          tmpMeta[0+0] = omc_SimCodeUtil_locateDerAndSerachOtherSide(threadData, _derExp, _eqs, _inEqnsOrg, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 8) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _out = tmpMeta[0+0];
  _sysOrdOneVars = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_sysOrdOneVars) { *out_sysOrdOneVars = _sysOrdOneVars; }
  return _out;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeCallDerExp(threadData_t *threadData, modelica_metatype _inVars)
{
  modelica_metatype _outDerExps = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDerExps has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inVars;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _rec = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _rec has no default value.
      // _cr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,1,3) == 0) goto tmp3_end;
          
          _cr = tmpMeta9;
          _vars = tmpMeta8;
          /* Pattern matching succeeded */
          _rec = omc_SimCodeUtil_makeCallDerExp(threadData, _vars);
          tmpMeta13 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr, _OMC_LIT86);
          tmpMeta12 = mmc_mk_cons(tmpMeta13, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta14 = mmc_mk_box4(16, &DAE_Exp_CALL__desc, _OMC_LIT233, tmpMeta12, _OMC_LIT236);
          tmpMeta11 = mmc_mk_cons(tmpMeta14, _rec);
          tmpMeta1 = tmpMeta11;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          _vars = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_makeCallDerExp(threadData, _vars);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outDerExps = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outDerExps;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_flattenEqns(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _dlow)
{
  modelica_metatype _oeqns = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oeqns has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _eqns;
    {
      modelica_metatype _eq = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _rec = NULL;
      modelica_string _str = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eq has no default value.
      // _rest has no default value.
      // _rec has no default value.
      // _str has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 7; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,0,4) == 0) goto tmp3_end;
          
          _eq = tmpMeta7;
          _rest = tmpMeta8;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          _rec = omc_SimCodeUtil_flattenEqns(threadData, _rest, _dlow);
          tmpMeta1 = omc_List_unionElt(threadData, _eq, _rec);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,5,4) == 0) goto tmp3_end;
          
          _eq = tmpMeta9;
          _rest = tmpMeta10;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _str = omc_BackendDump_equationString(threadData, _eq);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            tmpMeta11 = stringAppend(_OMC_LIT239,_str);
            tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta12),stdout);
          }
          tmpMeta1 = omc_SimCodeUtil_flattenEqns(threadData, _rest, _dlow);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmp4_1);
          tmpMeta14 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,4,5) == 0) goto tmp3_end;
          
          _eq = tmpMeta13;
          _rest = tmpMeta14;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _rec = omc_SimCodeUtil_flattenEqns(threadData, _rest, _dlow);
          tmpMeta1 = omc_List_unionElt(threadData, _eq, _rec);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,1,6) == 0) goto tmp3_end;
          
          _eq = tmpMeta15;
          _rest = tmpMeta16;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _rec = omc_SimCodeUtil_flattenEqns(threadData, _rest, _dlow);
          tmpMeta1 = omc_List_unionElt(threadData, _eq, _rec);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmp4_1);
          tmpMeta18 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,6,5) == 0) goto tmp3_end;
          
          _eq = tmpMeta17;
          _rest = tmpMeta18;
          /* Pattern matching succeeded */
          _rec = omc_SimCodeUtil_flattenEqns(threadData, _rest, _dlow);
          tmpMeta1 = omc_List_unionElt(threadData, _eq, _rec);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_boolean tmp21;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta19 = MMC_CAR(tmp4_1);
          tmpMeta20 = MMC_CDR(tmp4_1);
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp21 = omc_Flags_isSet(threadData, _OMC_LIT227);
          if (1 /* true */ != tmp21) goto goto_2;

          fputs(MMC_STRINGDATA(_OMC_LIT240),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 7) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oeqns = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oeqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableDerIndex2(threadData_t *threadData, modelica_metatype _inDlow, modelica_metatype _syst)
{
  modelica_metatype _outOrder = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outOrder has no default value.
  { /* matchcontinue expression */
    {
      modelica_metatype _dovars = NULL;
      modelica_metatype _deqns = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _derExps = NULL;
      modelica_metatype _variableIndex = NULL;
      modelica_metatype _firstOrderVars = NULL;
      modelica_metatype _firstOrderVarsFiltered = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dovars has no default value.
      // _deqns has no default value.
      // _eqns has no default value.
      // _vars has no default value.
      // _derExps has no default value.
      // _variableIndex has no default value.
      // _firstOrderVars has no default value.
      // _firstOrderVarsFiltered has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT241),stdout);
          }

          _dovars = omc_BackendVariable_daeVars(threadData, _syst);

          _deqns = omc_BackendEquation_getEqnsFromEqSystem(threadData, _syst);

          _vars = omc_BackendVariable_varList(threadData, _dovars);

          _eqns = omc_BackendEquation_equationList(threadData, _deqns);

          _derExps = omc_SimCodeUtil_makeCallDerExp(threadData, _vars);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            tmpMeta6 = stringAppend(_OMC_LIT242,stringDelimitList(omc_List_map(threadData, _derExps, boxvar_ExpressionBasics_printExpStr), _OMC_LIT243));
            tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta7),stdout);
          }

          _eqns = omc_SimCodeUtil_flattenEqns(threadData, _eqns, _inDlow);

          _variableIndex = omc_List_map2__2(threadData, _derExps, boxvar_SimCodeUtil_locateDerAndSerachOtherSide, _eqns, _eqns ,&_firstOrderVars);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT244),stdout);
          }

          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _firstOrderVarsFiltered = omc_List_fold(threadData, _firstOrderVars, boxvar_List_union, tmpMeta8);

          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT245),stdout);
          }
          tmpMeta1 = omc_SimCodeUtil_setFirstOrderInSecondOrderVarIndex(threadData, _variableIndex, _firstOrderVarsFiltered);
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT246),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outOrder = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outOrder;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableDerIndex(threadData_t *threadData, modelica_metatype _inDlow, modelica_metatype _inEqSystems)
{
  modelica_metatype _outOrder = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outOrder has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEqSystems;
    {
      modelica_metatype _variableIndex = NULL;
      modelica_metatype _variableIndex2 = NULL;
      modelica_metatype _syst = NULL;
      modelica_metatype _systs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _variableIndex has no default value.
      // _variableIndex2 has no default value.
      // _syst has no default value.
      // _systs has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          _syst = tmpMeta7;
          _systs = tmpMeta8;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT247),stdout);
          }

          _variableIndex = omc_SimCodeUtil_setVariableDerIndex2(threadData, _inDlow, _syst);

          _variableIndex2 = omc_SimCodeUtil_setVariableDerIndex(threadData, _inDlow, _systs);
          tmpMeta1 = listAppend(_variableIndex, _variableIndex2);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT248),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outOrder = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outOrder;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_adjustStatesForInlineSolver(threadData_t *threadData, modelica_metatype _inStates)
{
  modelica_metatype _outStates = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outStates = tmpMeta1;
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          /* Pattern matching succeeded */
          {
            modelica_metatype _var;
            for (tmpMeta6 = _inStates; !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
            {
              _var = MMC_CAR(tmpMeta6);
              tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(33));
              memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[2] = omc_ComponentReference_appendStringLastIdent(threadData, _OMC_LIT249, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
              _var = tmpMeta7;

              tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(33));
              memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[3] = _OMC_LIT250;
              _var = tmpMeta8;

              tmpMeta9 = mmc_mk_cons(_var, _outStates);
              _outStates = tmpMeta9;
            }
          }
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT208, _OMC_LIT252);

          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _outStates;
}

DLLDirection
modelica_integer omc_SimCodeUtil_simEqSystemIndex(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _index;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _index has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 19; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          
          _index = tmp7  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          
          _index = tmp9  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          
          _index = tmp11  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          
          _index = tmp13  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          
          _index = tmp15  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          
          _index = tmp17  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          
          _index = tmp19  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          
          _index = tmp21  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,5) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          
          _index = tmp23  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,5) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          
          _index = tmp25  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          
          _index = tmp27  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp29 = mmc_unbox_integer(tmpMeta28);
          
          _index = tmp29  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmp32 = mmc_unbox_integer(tmpMeta31);
          
          _index = tmp32  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          
          _index = tmp35  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp37 = mmc_unbox_integer(tmpMeta36);
          
          _index = tmp37  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp39 = mmc_unbox_integer(tmpMeta38);
          
          _index = tmp39  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta40;
          modelica_integer tmp41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,8) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp41 = mmc_unbox_integer(tmpMeta40);
          
          _index = tmp41  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp43 = mmc_unbox_integer(tmpMeta42);
          
          _index = tmp43  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _index;
          goto tmp3_done;
        }
        case 18: {
          
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT208, _OMC_LIT254);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _index = tmp1;
  _return: OMC_LABEL_UNUSED
  return _index;
}
modelica_metatype boxptr_SimCodeUtil_simEqSystemIndex(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _index;
  modelica_metatype out_index;
  _index = omc_SimCodeUtil_simEqSystemIndex(threadData, _eq);
  out_index = mmc_mk_icon(_index);
  return out_index;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_eqInfo(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _info = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _info has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          
          _info = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          
          _info = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          
          _info = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          
          _info = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          
          _info = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          
          _info = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          
          _info = tmpMeta18;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          
          _info = tmpMeta20;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,5) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          
          _info = tmpMeta22;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          
          _info = tmpMeta24;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 19: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,8) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          
          _info = tmpMeta26;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _info = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _info;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_functionPath(threadData_t *threadData, modelica_metatype _fn)
{
  modelica_metatype _name = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _name has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _fn;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,7) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _name;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _name;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,6) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _name;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,14) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _name;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta1 = _name;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _name = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _name;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_functionInfo(threadData_t *threadData, modelica_metatype _fn)
{
  modelica_metatype _info = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _info has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _fn;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,7) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          _info = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          
          _info = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _info = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _info;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _info = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _info;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getNominalValue(threadData_t *threadData, modelica_metatype _daelowVar)
{
  modelica_metatype _nomVal = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nomVal has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _daelowVar;
    {
      modelica_metatype _dae_var_attr = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dae_var_attr has no default value.
      // _e has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta7;
          /* Pattern matching succeeded */
          _e = omc_DAEUtil_getNominalAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _nomVal = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _nomVal;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getStartValue(threadData_t *threadData, modelica_metatype _daelowVar)
{
  modelica_metatype _initVal = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _initVal has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _daelowVar;
    {
      modelica_metatype _dae_var_attr = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _tp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dae_var_attr has no default value.
      // _e has no default value.
      // _tp has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 14; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,7,0) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,0) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta10;
          tmp4 += 10; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,6,0) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta12;
          tmp4 += 9; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,1,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta14;
          tmp4 += 8; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,19,0) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta16;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,3,0) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta18;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta19,4,0) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta20;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta21,7,0) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta22)) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
          
          _e = tmpMeta23;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))) goto tmp3_end;
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,7,0) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _tp = tmpMeta25;
          _dae_var_attr = tmpMeta26;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))) goto tmp3_end;
          _e = omc_DAEUtil_getStartAttr(threadData, _dae_var_attr, _tp);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,7,0) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta28)) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          
          _e = tmpMeta29;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_Expression_isConst(threadData, _e) && (stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))) goto tmp3_end;
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,7,0) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta31;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Check guard condition after assignments */
          if (!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119))) goto tmp3_end;
          _e = omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,9,1) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta33)) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 1));
          
          _e = tmpMeta34;
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta35;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta35;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_BackendVariable_isVarNonDiscreteAlg(threadData, _daelowVar)) goto tmp3_end;
          tmpMeta1 = mmc_mk_some(omc_DAEUtil_getStartAttrFail(threadData, _dae_var_attr));
          goto tmp3_done;
        }
        case 13: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 14) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _initVal = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _initVal;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getMinMaxValues(threadData_t *threadData, modelica_metatype _inDAELowVar, modelica_metatype *out_outMaxValue)
{
  modelica_metatype _outMinValue = NULL;
  modelica_metatype _outMaxValue = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMinValue has no default value.
  // _outMaxValue has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inDAELowVar;
    {
      modelica_metatype _dae_var_attr = NULL;
      modelica_metatype _minValue = NULL;
      modelica_metatype _maxValue = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dae_var_attr has no default value.
      // _minValue has no default value.
      // _maxValue has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta10 = omc_DAEUtil_getMinMaxValues(threadData, _dae_var_attr, &tmpMeta8);
          if (optionNone(tmpMeta10)) goto goto_2;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          _minValue = tmpMeta11;
          if (optionNone(tmpMeta8)) goto goto_2;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          _maxValue = tmpMeta9;
          tmpMeta[0+0] = mmc_mk_some(_minValue);
          tmpMeta[0+1] = mmc_mk_some(_maxValue);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,1) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta13;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_DAEUtil_getMinMaxValues(threadData, _dae_var_attr, &tmpMeta14);
          if (optionNone(tmpMeta15)) goto goto_2;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          _minValue = tmpMeta16;
          if (!optionNone(tmpMeta14)) goto goto_2;
          tmpMeta[0+0] = mmc_mk_some(_minValue);
          tmpMeta[0+1] = mmc_mk_none();
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,1,1) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          
          _dae_var_attr = tmpMeta18;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta21 = omc_DAEUtil_getMinMaxValues(threadData, _dae_var_attr, &tmpMeta19);
          if (!optionNone(tmpMeta21)) goto goto_2;
          if (optionNone(tmpMeta19)) goto goto_2;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 1));
          _maxValue = tmpMeta20;
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_some(_maxValue);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outMinValue = tmpMeta[0+0];
  _outMaxValue = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outMaxValue) { *out_outMaxValue = _outMaxValue; }
  return _outMinValue;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_extractVarUnitStr(threadData_t *threadData, modelica_metatype _exp)
{
  modelica_string _str = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_string tmp3 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _e has no default value.
  if(isSome(_exp))
  {
    /* Pattern-matching assignment */
    tmpMeta1 = _exp;
    if (optionNone(tmpMeta1)) MMC_THROW_INTERNAL();
    tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
    _e = tmpMeta2;

    _e = omc_Expression_arrayFirstScalar(threadData, _e);

    { /* match expression */
      modelica_metatype tmp6_1;
      tmp6_1 = _e;
      {
        volatile mmc_switch_type tmp6;
        int tmp7;
        tmp6 = 0;
        for (; tmp6 < 2; tmp6++) {
          switch (MMC_SWITCH_CAST(tmp6)) {
          case 0: {
            if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,2,1) == 0) goto tmp5_end;
            
            /* Pattern matching succeeded */
            tmp3 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)));
            goto tmp5_done;
          }
          case 1: {
            modelica_metatype tmpMeta8;
            
            /* Pattern matching succeeded */
            tmpMeta8 = stringAppend(_OMC_LIT255,omc_ExpressionBasics_printExpStr(threadData, _e));
            omc_Error_addInternalError(threadData, tmpMeta8, _OMC_LIT256);
            goto goto_4;
            goto tmp5_done;
          }
          }
          goto tmp5_end;
          tmp5_end: ;
        }
        goto goto_4;
        goto_4:;
        MMC_THROW_INTERNAL();
        goto tmp5_done;
        tmp5_done:;
      }
    }
    _str = tmp3;
  }
  else
  {
    _str = _OMC_LIT31;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_extractVarUnit(threadData_t *threadData, modelica_metatype _var_attr, modelica_string *out_displayUnitStr)
{
  modelica_string _unitStr = NULL;
  modelica_string _displayUnitStr = NULL;
  modelica_string tmp1_c0 __attribute__((unused)) = 0;
  modelica_string tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _unitStr has no default value.
  // _displayUnitStr has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _var_attr;
    {
      modelica_metatype _uexp = NULL;
      modelica_metatype _duexp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _uexp has no default value.
      // _duexp has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,15) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          
          _uexp = tmpMeta7;
          _duexp = tmpMeta8;
          /* Pattern matching succeeded */
          _unitStr = omc_SimCodeUtil_extractVarUnitStr(threadData, _uexp);

          _displayUnitStr = omc_SimCodeUtil_extractVarUnitStr(threadData, _duexp);
          tmp1_c0 = _unitStr;
          tmp1_c1 = _displayUnitStr;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = _OMC_LIT31;
          tmp1_c1 = _OMC_LIT31;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _unitStr = tmp1_c0;
  _displayUnitStr = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_displayUnitStr) { *out_displayUnitStr = _displayUnitStr; }
  return _unitStr;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getMatchingExpsList(threadData_t *threadData, modelica_metatype _inExps, modelica_fnptr _inFn)
{
  modelica_metatype _outExpLst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExpLst has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  omc_Expression_traverseExpList(threadData, _inExps, ((modelica_fnptr) _inFn), tmpMeta1 ,&_outExpLst);
  _return: OMC_LABEL_UNUSED
  return _outExpLst;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_traversingdlowvarToSimvar(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _var = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _sv_lst = NULL;
  modelica_metatype _sv = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _var = __omcQ_24in_5Fvar;
  // _outTpl has no default value.
  // _sv_lst has no default value.
  // _sv has no default value.
  // _vars has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _sv_lst = tmpMeta2;
  _vars = tmpMeta3;

  _sv = omc_SimCodeUtil_dlowvarToSimvar(threadData, _var, mmc_mk_none(), _vars, mmc_mk_none());

  tmpMeta4 = mmc_mk_cons(_sv, _sv_lst);
  tmpMeta5 = mmc_mk_box2(0, tmpMeta4, _vars);
  _outTpl = tmpMeta5;
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _var;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traversingdlowvarToSimvarFold(threadData_t *threadData, modelica_metatype _v, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  omc_SimCodeUtil_traversingdlowvarToSimvar(threadData, _v, _inTpl ,&_outTpl);
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateStartValue(threadData_t *threadData, modelica_metatype _var, modelica_metatype __omcQ_24in_5FstartValue, modelica_metatype _initial_, modelica_metatype _causality)
{
  modelica_metatype _startValue = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _startValue = __omcQ_24in_5FstartValue;
  if((omc_Flags_getConfigBool(threadData, _OMC_LIT260) && omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData))))
  {
    { /* match expression */
      modelica_metatype tmp4_1;
      tmp4_1 = _startValue;
      {
        volatile mmc_switch_type tmp4;
        int tmp5;
        tmp4 = 0;
        for (; tmp4 < 5; tmp4++) {
          switch (MMC_SWITCH_CAST(tmp4)) {
          case 0: {
            modelica_metatype tmpMeta6;
            if (optionNone(tmp4_1)) goto tmp3_end;
            tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
            /* Pattern matching succeeded */
            /* Check guard condition after assignments */
            if (!omc_SimCodeUtil_isInitialExactOrApprox(threadData, _initial_)) goto tmp3_end;
            tmpMeta1 = _startValue;
            goto tmp3_done;
          }
          case 1: {
            if (!optionNone(tmp4_1)) goto tmp3_end;
            /* Pattern matching succeeded */
            /* Check guard condition after assignments */
            if (!omc_SimCodeUtil_isInitialExactOrApprox(threadData, _initial_)) goto tmp3_end;
            tmpMeta1 = omc_SimCodeUtil_setDefaultStartValue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 6))));
            goto tmp3_done;
          }
          case 2: {
            modelica_metatype tmpMeta7;
            if (optionNone(tmp4_1)) goto tmp3_end;
            tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
            /* Pattern matching succeeded */
            /* Check guard condition after assignments */
            if (!omc_SimCodeUtil_isCausalityInput(threadData, _causality)) goto tmp3_end;
            tmpMeta1 = omc_SimCodeUtil_startValueIsConstOrDefault(threadData, _startValue, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 6))));
            goto tmp3_done;
          }
          case 3: {
            if (!optionNone(tmp4_1)) goto tmp3_end;
            /* Pattern matching succeeded */
            /* Check guard condition after assignments */
            if (!omc_SimCodeUtil_isCausalityInput(threadData, _causality)) goto tmp3_end;
            tmpMeta1 = omc_SimCodeUtil_setDefaultStartValue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 6))));
            goto tmp3_done;
          }
          case 4: {
            
            /* Pattern matching succeeded */
            tmpMeta1 = omc_SimCodeUtil_startValueIsConstOrDefault(threadData, _startValue, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 6))));
            goto tmp3_done;
          }
          }
          goto tmp3_end;
          tmp3_end: ;
        }
        goto goto_2;
        goto_2:;
        MMC_THROW_INTERNAL();
        goto tmp3_done;
        tmp3_done:;
      }
    }
    _startValue = tmpMeta1;
  }
  _return: OMC_LABEL_UNUSED
  return _startValue;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_startValueIsConstOrDefault(threadData_t *threadData, modelica_metatype _start_value, modelica_metatype _type_)
{
  modelica_metatype _outstart_value = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outstart_value has no default value.
  if(isNone(_start_value))
  {
    _outstart_value = mmc_mk_none();
  }
  else
  {
    if(omc_Expression_isConstValue(threadData, omc_Util_getOption(threadData, _start_value)))
    {
      _outstart_value = _start_value;
    }
    else
    {
      _outstart_value = omc_SimCodeUtil_setDefaultStartValue(threadData, _type_);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outstart_value;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setDefaultStartValue(threadData_t *threadData, modelica_metatype _type_)
{
  modelica_metatype _exp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _exp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _type_;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT262;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT264;
          goto tmp3_done;
        }
        case 6: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT266;
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT268;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_some(omc_Types_getNthEnumLiteral(threadData, _type_, ((modelica_integer) 1)));
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _exp;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isCausalityInput(threadData_t *threadData, modelica_metatype _causality)
{
  modelica_boolean _val;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _val has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _causality;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _val = tmp1;
  _return: OMC_LABEL_UNUSED
  return _val;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isCausalityInput(threadData_t *threadData, modelica_metatype _causality)
{
  modelica_boolean _val;
  modelica_metatype out_val;
  _val = omc_SimCodeUtil_isCausalityInput(threadData, _causality);
  out_val = mmc_mk_icon(_val);
  return out_val;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isInitialExactOrApprox(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _val;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _val has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _initial_;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 4: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _val = tmp1;
  _return: OMC_LABEL_UNUSED
  return _val;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isInitialExactOrApprox(threadData_t *threadData, modelica_metatype _initial_)
{
  modelica_boolean _val;
  modelica_metatype out_val;
  _val = omc_SimCodeUtil_isInitialExactOrApprox(threadData, _initial_);
  out_val = mmc_mk_icon(_val);
  return out_val;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getVariabilityAttribute(threadData_t *threadData, modelica_metatype _var)
{
  modelica_metatype _variability = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _variability has no default value.
  if(omc_BackendVariable_isParam(threadData, _var))
  {
    _variability = _OMC_LIT271;
  }
  else
  {
    if(omc_BackendVariable_isConst(threadData, _var))
    {
      _variability = _OMC_LIT270;
    }
    else
    {
      if((omc_BackendVariable_isVarDiscrete(threadData, _var) || omc_BackendVariable_isClockedStateVar(threadData, _var)))
      {
        _variability = _OMC_LIT269;
      }
      else
      {
        _variability = _OMC_LIT124;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _variability;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getInitialAttributeHelper(threadData_t *threadData, modelica_metatype _var, modelica_boolean _isFixed, modelica_metatype _iterationVars)
{
  modelica_metatype _initial_ = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _initial_ has no default value.
  if((_isFixed && omc_SimCodeUtil_startValueIsConstOrNone(threadData, _var)))
  {
    _initial_ = _OMC_LIT274;
  }
  else
  {
    if(((isSome(_iterationVars) && omc_UnorderedSet_contains(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), omc_Util_getOption(threadData, _iterationVars))) && omc_SimCodeUtil_startValueIsConstOrNone(threadData, _var)))
    {
      _initial_ = _OMC_LIT273;
    }
    else
    {
      _initial_ = _OMC_LIT272;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _initial_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getInitialAttributeHelper(threadData_t *threadData, modelica_metatype _var, modelica_metatype _isFixed, modelica_metatype _iterationVars)
{
  modelica_integer tmp1;
  modelica_metatype _initial_ = NULL;
  tmp1 = mmc_unbox_integer(_isFixed);
  _initial_ = omc_SimCodeUtil_getInitialAttributeHelper(threadData, _var, tmp1, _iterationVars);
  /* skip box _initial_; SimCodeVar.Initial */
  return _initial_;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_startValueIsConstOrNone(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _b;
  modelica_metatype _start_value = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _b = 0 /* false */;
  _start_value = omc_SimCodeUtil_getStartValue(threadData, _var);
  if((isNone(_start_value) && isNone((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 7))))))
  {
    _b = 1 /* true */;
  }
  else
  {
    if((isNone(_start_value) && isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 7))))))
    {
      _b = omc_Expression_isEvaluatedConst(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 7)))));
    }
    else
    {
      _b = omc_Expression_isEvaluatedConst(threadData, omc_Util_getOption(threadData, _start_value));
    }
  }
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_startValueIsConstOrNone(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_startValueIsConstOrNone(threadData, _var);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getInitialAttributeHelperForParameters(threadData_t *threadData, modelica_metatype _var, modelica_boolean _isFixed, modelica_metatype _iterationVars)
{
  modelica_metatype _initial_ = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _initial_ has no default value.
  if(((((!_isFixed) && isSome(_iterationVars)) && omc_UnorderedSet_contains(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), omc_Util_getOption(threadData, _iterationVars))) && omc_SimCodeUtil_startValueIsConstOrNone(threadData, _var)))
  {
    _initial_ = _OMC_LIT273;
  }
  else
  {
    _initial_ = _OMC_LIT272;
  }
  _return: OMC_LABEL_UNUSED
  return _initial_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getInitialAttributeHelperForParameters(threadData_t *threadData, modelica_metatype _var, modelica_metatype _isFixed, modelica_metatype _iterationVars)
{
  modelica_integer tmp1;
  modelica_metatype _initial_ = NULL;
  tmp1 = mmc_unbox_integer(_isFixed);
  _initial_ = omc_SimCodeUtil_getInitialAttributeHelperForParameters(threadData, _var, tmp1, _iterationVars);
  /* skip box _initial_; SimCodeVar.Initial */
  return _initial_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setInitialAttribute(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _variability, modelica_metatype _causality, modelica_boolean _isFixed, modelica_metatype _iterationVars, modelica_metatype _aliasvar, modelica_metatype _globalknownVars)
{
  modelica_metatype _initial_ = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _initial_ has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _variability;
    tmp4_2 = _causality;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 10; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,4,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelperForParameters(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelperForParameters(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelper(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelper(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 7: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelper(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 8: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_SimCodeUtil_getInitialAttributeHelper(threadData, _dlow, _isFixed, _iterationVars);
          goto tmp3_done;
        }
        case 9: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT275;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _initial_ = tmpMeta1;

  if((valueEq(_initial_, _OMC_LIT274) && (!valueEq(_aliasvar, _OMC_LIT88))))
  {
    _initial_ = _OMC_LIT272;
  }
  _return: OMC_LABEL_UNUSED
  return _initial_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_setInitialAttribute(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _variability, modelica_metatype _causality, modelica_metatype _isFixed, modelica_metatype _iterationVars, modelica_metatype _aliasvar, modelica_metatype _globalknownVars)
{
  modelica_integer tmp1;
  modelica_metatype _initial_ = NULL;
  tmp1 = mmc_unbox_integer(_isFixed);
  _initial_ = omc_SimCodeUtil_setInitialAttribute(threadData, _dlow, _variability, _causality, tmp1, _iterationVars, _aliasvar, _globalknownVars);
  /* skip box _initial_; SimCodeVar.Initial */
  return _initial_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getCausality(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inVars, modelica_boolean _isValueChangeable)
{
  modelica_metatype _caus = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _caus has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_boolean tmp4_3;
    tmp4_1 = _dlowVar;
    tmp4_2 = _inVars;
    tmp4_3 = _isValueChangeable;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _globalKnownVars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _globalKnownVars has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,0) == 0) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _OMC_LIT276;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,0,0) == 0) goto tmp3_end;
          
          _cr = tmpMeta7;
          _globalKnownVars = tmp4_2;
          /* Pattern matching succeeded */
          omc_BackendVariable_getVar(threadData, _cr, _globalKnownVars, NULL);
          tmpMeta1 = _OMC_LIT277;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          if (1 /* true */ != tmp4_3) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,7,0) == 0) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _OMC_LIT278;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta10;
          if (0 /* false */ != tmp4_3) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,7,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT279;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT93;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _caus = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _caus;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getCausality(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inVars, modelica_metatype _isValueChangeable)
{
  modelica_integer tmp1;
  modelica_metatype _caus = NULL;
  tmp1 = mmc_unbox_integer(_isValueChangeable);
  _caus = omc_SimCodeUtil_getCausality(threadData, _dlowVar, _inVars, tmp1);
  /* skip box _caus; SimCodeVar.Causality */
  return _caus;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowvarToSimvar(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _optAliasVars, modelica_metatype _inVars, modelica_metatype _iterationVars)
{
  modelica_metatype _simVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simVar has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _dlowVar;
    tmp4_2 = _inVars;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _kind = NULL;
      modelica_metatype _inst_dims = NULL;
      modelica_metatype _numArrayElement = NULL;
      modelica_metatype _dae_var_attr = NULL;
      modelica_metatype _hideResultExp = NULL;
      modelica_metatype _comment = NULL;
      modelica_metatype _tp = NULL;
      modelica_string _commentStr = NULL;
      modelica_string _unit = NULL;
      modelica_string _displayUnit = NULL;
      modelica_metatype _minValue = NULL;
      modelica_metatype _maxValue = NULL;
      modelica_metatype _initVal = NULL;
      modelica_metatype _nomVal = NULL;
      modelica_boolean _isFixed;
      modelica_metatype _type_ = NULL;
      modelica_boolean _isDiscrete;
      modelica_boolean _isValueChangeable;
      modelica_metatype _arrayCref = NULL;
      modelica_metatype _aliasvar = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _caus = NULL;
      modelica_metatype _initial_ = NULL;
      modelica_metatype _variability = NULL;
      modelica_boolean _isProtected;
      modelica_metatype _hideResult = NULL;
      modelica_boolean _encrypted;
      modelica_boolean _relativeQuantity;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _kind has no default value.
      // _inst_dims has no default value.
      // _numArrayElement has no default value.
      // _dae_var_attr has no default value.
      // _hideResultExp has no default value.
      // _comment has no default value.
      // _tp has no default value.
      // _commentStr has no default value.
      // _unit has no default value.
      // _displayUnit has no default value.
      // _minValue has no default value.
      // _maxValue has no default value.
      // _initVal has no default value.
      // _nomVal has no default value.
      // _isFixed has no default value.
      // _type_ has no default value.
      // _isDiscrete has no default value.
      // _isValueChangeable has no default value.
      // _arrayCref has no default value.
      // _aliasvar has no default value.
      // _source has no default value.
      // _vars has no default value.
      // _caus has no default value.
      // _initial_ has no default value.
      // _variability has no default value.
      // _isProtected has no default value.
      // _hideResult has no default value.
      // _encrypted has no default value.
      // _relativeQuantity has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,8,0) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          
          _cr = tmpMeta6;
          _kind = tmpMeta7;
          _tp = tmpMeta8;
          _inst_dims = tmpMeta9;
          _source = tmpMeta10;
          _dae_var_attr = tmpMeta11;
          _hideResultExp = tmpMeta12;
          _comment = tmpMeta13;
          _encrypted = tmp15  /* pattern as ty=Boolean */;
          _vars = tmp4_2;
          /* Pattern matching succeeded */
          _commentStr = omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData, _comment);

          _unit = omc_SimCodeUtil_extractVarUnit(threadData, _dae_var_attr ,&_displayUnit);

          _isProtected = omc_BackendVariable_isProtected(threadData, _dlowVar);

          _hideResult = omc_SimCodeUtil_getHideResult(threadData, _hideResultExp, _cr, _source);

          _initVal = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 7)));

          _isFixed = omc_BackendVariable_varFixed(threadData, _dlowVar);

          _type_ = _tp;

          _isDiscrete = omc_BackendVariable_isVarDiscrete(threadData, _dlowVar);

          _arrayCref = omc_ComponentReference_getArrayCref(threadData, _cr);

          _aliasvar = omc_SimCodeUtil_getAliasVar(threadData, _dlowVar, _optAliasVars);

          _numArrayElement = omc_List_map(threadData, _inst_dims, boxvar_ExpressionDump_dimensionIntString);

          _isValueChangeable = omc_BackendVariable_isChangeable(threadData, _dlowVar);

          _caus = omc_SimCodeUtil_getCausality(threadData, _dlowVar, _vars, _isValueChangeable);

          _variability = _OMC_LIT270;

          _initial_ = omc_SimCodeUtil_setInitialAttribute(threadData, _dlowVar, _variability, _caus, _isFixed, _iterationVars, _aliasvar, _vars);

          _initVal = omc_SimCodeUtil_updateStartValue(threadData, _dlowVar, _initVal, _initial_, _caus);

          if(omc_BackendVariable_isRealVar(threadData, _dlowVar))
          {
            _relativeQuantity = omc_SCodeUtil_optCommentHasBooleanNamedAnnotationFalse(threadData, _comment, _OMC_LIT280);
          }
          else
          {
            _relativeQuantity = 0 /* false */;
          }
          tmpMeta16 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _kind, _commentStr, _unit, _displayUnit, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_none(), mmc_mk_none(), _initVal, mmc_mk_none(), mmc_mk_boolean(_isFixed), _type_, mmc_mk_boolean(_isDiscrete), _arrayCref, _aliasvar, _source, mmc_mk_some(_caus), mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(_isValueChangeable), mmc_mk_boolean(_isProtected), _hideResult, mmc_mk_boolean(_encrypted), mmc_mk_none(), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 18))), mmc_mk_none(), mmc_mk_some(_variability), mmc_mk_some(_initial_), mmc_mk_none(), mmc_mk_boolean(_relativeQuantity));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,7,0) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          
          _cr = tmpMeta17;
          _kind = tmpMeta18;
          _tp = tmpMeta19;
          _inst_dims = tmpMeta20;
          _source = tmpMeta21;
          _dae_var_attr = tmpMeta22;
          _hideResultExp = tmpMeta23;
          _comment = tmpMeta24;
          _encrypted = tmp26  /* pattern as ty=Boolean */;
          _vars = tmp4_2;
          /* Pattern matching succeeded */
          _commentStr = omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData, _comment);

          _unit = omc_SimCodeUtil_extractVarUnit(threadData, _dae_var_attr ,&_displayUnit);

          _isProtected = omc_BackendVariable_isProtected(threadData, _dlowVar);

          _hideResult = omc_SimCodeUtil_getHideResult(threadData, _hideResultExp, _cr, _source);

          _minValue = omc_SimCodeUtil_getMinMaxValues(threadData, _dlowVar ,&_maxValue);

          _initVal = omc_SimCodeUtil_getStartValue(threadData, _dlowVar);

          _nomVal = omc_SimCodeUtil_getNominalValue(threadData, _dlowVar);

          _isFixed = omc_BackendVariable_varFixed(threadData, _dlowVar);

          _type_ = _tp;

          _isDiscrete = omc_BackendVariable_isVarDiscrete(threadData, _dlowVar);

          _arrayCref = omc_ComponentReference_getArrayCref(threadData, _cr);

          _aliasvar = omc_SimCodeUtil_getAliasVar(threadData, _dlowVar, _optAliasVars);

          _numArrayElement = omc_List_map(threadData, _inst_dims, boxvar_ExpressionDump_dimensionIntString);

          _isValueChangeable = omc_BackendVariable_isChangeable(threadData, _dlowVar);

          _caus = omc_SimCodeUtil_getCausality(threadData, _dlowVar, _vars, _isValueChangeable);

          _variability = _OMC_LIT271;

          _initial_ = omc_SimCodeUtil_setInitialAttribute(threadData, _dlowVar, _variability, _caus, _isFixed, _iterationVars, _aliasvar, _vars);

          _initVal = omc_SimCodeUtil_updateStartValue(threadData, _dlowVar, _initVal, _initial_, _caus);

          if(omc_BackendVariable_isRealVar(threadData, _dlowVar))
          {
            _relativeQuantity = omc_SCodeUtil_optCommentHasBooleanNamedAnnotationFalse(threadData, _comment, _OMC_LIT280);
          }
          else
          {
            _relativeQuantity = 0 /* false */;
          }
          tmpMeta27 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _kind, _commentStr, _unit, _displayUnit, mmc_mk_integer(((modelica_integer) -1)), _minValue, _maxValue, _initVal, _nomVal, mmc_mk_boolean(_isFixed), _type_, mmc_mk_boolean(_isDiscrete), _arrayCref, _aliasvar, _source, mmc_mk_some(_caus), mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(_isValueChangeable), mmc_mk_boolean(_isProtected), _hideResult, mmc_mk_boolean(_encrypted), mmc_mk_none(), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 18))), mmc_mk_none(), mmc_mk_some(_variability), mmc_mk_some(_initial_), mmc_mk_some(_cr), mmc_mk_boolean(_relativeQuantity));
          tmpMeta1 = tmpMeta27;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          modelica_metatype tmpMeta43;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,1,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          tmp37 = mmc_unbox_integer(tmpMeta36);
          
          _cr = tmpMeta28;
          _kind = tmpMeta29;
          _tp = tmpMeta30;
          _inst_dims = tmpMeta31;
          _source = tmpMeta32;
          _dae_var_attr = tmpMeta33;
          _hideResultExp = tmpMeta34;
          _comment = tmpMeta35;
          _encrypted = tmp37  /* pattern as ty=Boolean */;
          _vars = tmp4_2;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp40_1;
            tmp40_1 = omc_BackendVariable_varStateSelect(threadData, _dlowVar);
            {
              volatile mmc_switch_type tmp40;
              int tmp41;
              tmp40 = 0;
              for (; tmp40 < 2; tmp40++) {
                switch (MMC_SWITCH_CAST(tmp40)) {
                case 0: {
                  modelica_metatype tmpMeta42;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp40_1,0,0) == 0) goto tmp39_end;
                  /* Pattern matching succeeded */
                  /* Check guard condition after assignments */
                  if (!omc_BackendVariable_isNaturalState(threadData, _dlowVar)) goto tmp39_end;
                  tmpMeta42 = mmc_mk_cons(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr), MMC_REFSTRUCTLIT(mmc_nil));
                  omc_Error_addSourceMessage(threadData, _OMC_LIT283, tmpMeta42, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_source), 2))));

                  goto goto_38;
                  goto tmp39_done;
                }
                case 1: {
                  
                  /* Pattern matching succeeded */
                  goto tmp39_done;
                }
                }
                goto tmp39_end;
                tmp39_end: ;
              }
              goto goto_38;
              goto_38:;
              goto goto_2;
              goto tmp39_done;
              tmp39_done:;
            }
          }
          ;

          _commentStr = omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData, _comment);

          _unit = omc_SimCodeUtil_extractVarUnit(threadData, _dae_var_attr ,&_displayUnit);

          _isProtected = omc_BackendVariable_isProtected(threadData, _dlowVar);

          _hideResult = omc_SimCodeUtil_getHideResult(threadData, _hideResultExp, _cr, _source);

          _minValue = omc_SimCodeUtil_getMinMaxValues(threadData, _dlowVar ,&_maxValue);

          _initVal = omc_SimCodeUtil_getStartValue(threadData, _dlowVar);

          _nomVal = omc_SimCodeUtil_getNominalValue(threadData, _dlowVar);

          _isFixed = omc_BackendVariable_varFixed(threadData, _dlowVar);

          _type_ = _tp;

          _isDiscrete = omc_BackendVariable_isVarDiscrete(threadData, _dlowVar);

          _arrayCref = omc_ComponentReference_getArrayCref(threadData, _cr);

          _aliasvar = omc_SimCodeUtil_getAliasVar(threadData, _dlowVar, _optAliasVars);

          _numArrayElement = omc_List_map(threadData, _inst_dims, boxvar_ExpressionDump_dimensionIntString);

          _isValueChangeable = omc_BackendVariable_isChangeable(threadData, _dlowVar);

          _caus = omc_SimCodeUtil_getCausality(threadData, _dlowVar, _vars, _isValueChangeable);

          _variability = _OMC_LIT124;

          _initial_ = omc_SimCodeUtil_setInitialAttribute(threadData, _dlowVar, _variability, _caus, _isFixed, _iterationVars, _aliasvar, _vars);

          _initVal = omc_SimCodeUtil_updateStartValue(threadData, _dlowVar, _initVal, _initial_, _caus);

          if(omc_BackendVariable_isRealVar(threadData, _dlowVar))
          {
            _relativeQuantity = omc_SCodeUtil_optCommentHasBooleanNamedAnnotationFalse(threadData, _comment, _OMC_LIT280);
          }
          else
          {
            _relativeQuantity = 0 /* false */;
          }
          tmpMeta43 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _kind, _commentStr, _unit, _displayUnit, mmc_mk_integer(((modelica_integer) -1)), _minValue, _maxValue, _initVal, _nomVal, mmc_mk_boolean(_isFixed), _type_, mmc_mk_boolean(_isDiscrete), _arrayCref, _aliasvar, _source, mmc_mk_some(_caus), mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(_isValueChangeable), mmc_mk_boolean(_isProtected), _hideResult, mmc_mk_boolean(_encrypted), mmc_mk_none(), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 18))), mmc_mk_none(), mmc_mk_some(_variability), mmc_mk_some(_initial_), mmc_mk_some(_cr), mmc_mk_boolean(_relativeQuantity));
          tmpMeta1 = tmpMeta43;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_integer tmp53;
          modelica_metatype tmpMeta59;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 14));
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 19));
          tmp53 = mmc_unbox_integer(tmpMeta52);
          
          _cr = tmpMeta44;
          _kind = tmpMeta45;
          _tp = tmpMeta46;
          _inst_dims = tmpMeta47;
          _source = tmpMeta48;
          _dae_var_attr = tmpMeta49;
          _hideResultExp = tmpMeta50;
          _comment = tmpMeta51;
          _encrypted = tmp53  /* pattern as ty=Boolean */;
          _vars = tmp4_2;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp56_1;
            tmp56_1 = omc_BackendVariable_varStateSelect(threadData, _dlowVar);
            {
              volatile mmc_switch_type tmp56;
              int tmp57;
              tmp56 = 0;
              for (; tmp56 < 2; tmp56++) {
                switch (MMC_SWITCH_CAST(tmp56)) {
                case 0: {
                  modelica_metatype tmpMeta58;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp56_1,4,0) == 0) goto tmp55_end;
                  /* Pattern matching succeeded */
                  /* Check guard condition after assignments */
                  if (!(valueEq(_kind, _OMC_LIT87) && (!omc_ComponentReference_isPreviousCref(threadData, _cr)))) goto tmp55_end;
                  tmpMeta58 = mmc_mk_cons(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr), MMC_REFSTRUCTLIT(mmc_nil));
                  omc_Error_addSourceMessage(threadData, _OMC_LIT285, tmpMeta58, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_source), 2))));
                  goto tmp55_done;
                }
                case 1: {
                  
                  /* Pattern matching succeeded */
                  goto tmp55_done;
                }
                }
                goto tmp55_end;
                tmp55_end: ;
              }
              goto goto_54;
              goto_54:;
              goto goto_2;
              goto tmp55_done;
              tmp55_done:;
            }
          }
          ;

          _commentStr = omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData, _comment);

          _unit = omc_SimCodeUtil_extractVarUnit(threadData, _dae_var_attr ,&_displayUnit);

          _isProtected = omc_BackendVariable_isProtected(threadData, _dlowVar);

          _hideResult = omc_SimCodeUtil_getHideResult(threadData, _hideResultExp, _cr, _source);

          _minValue = omc_SimCodeUtil_getMinMaxValues(threadData, _dlowVar ,&_maxValue);

          _initVal = omc_SimCodeUtil_getStartValue(threadData, _dlowVar);

          _nomVal = omc_SimCodeUtil_getNominalValue(threadData, _dlowVar);

          _isFixed = omc_BackendVariable_varFixed(threadData, _dlowVar);

          _type_ = _tp;

          _isDiscrete = omc_BackendVariable_isVarDiscrete(threadData, _dlowVar);

          _arrayCref = omc_ComponentReference_getArrayCref(threadData, _cr);

          _aliasvar = omc_SimCodeUtil_getAliasVar(threadData, _dlowVar, _optAliasVars);

          _numArrayElement = omc_List_map(threadData, _inst_dims, boxvar_ExpressionDump_dimensionIntString);

          _isValueChangeable = omc_BackendVariable_isChangeable(threadData, _dlowVar);

          _caus = omc_SimCodeUtil_getCausality(threadData, _dlowVar, _vars, _isValueChangeable);

          _variability = omc_SimCodeUtil_getVariabilityAttribute(threadData, _dlowVar);

          _initial_ = omc_SimCodeUtil_setInitialAttribute(threadData, _dlowVar, _variability, _caus, _isFixed, _iterationVars, _aliasvar, _vars);

          _initVal = omc_SimCodeUtil_updateStartValue(threadData, _dlowVar, _initVal, _initial_, _caus);

          if(omc_BackendVariable_isRealVar(threadData, _dlowVar))
          {
            _relativeQuantity = omc_SCodeUtil_optCommentHasBooleanNamedAnnotationFalse(threadData, _comment, _OMC_LIT280);
          }
          else
          {
            _relativeQuantity = 0 /* false */;
          }
          tmpMeta59 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _kind, _commentStr, _unit, _displayUnit, mmc_mk_integer(((modelica_integer) -1)), _minValue, _maxValue, _initVal, _nomVal, mmc_mk_boolean(_isFixed), _type_, mmc_mk_boolean(_isDiscrete), _arrayCref, _aliasvar, _source, mmc_mk_some(_caus), mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(_isValueChangeable), mmc_mk_boolean(_isProtected), _hideResult, mmc_mk_boolean(_encrypted), mmc_mk_none(), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 18))), mmc_mk_none(), mmc_mk_some(_variability), mmc_mk_some(_initial_), mmc_mk_some(_cr), mmc_mk_boolean(_relativeQuantity));
          tmpMeta1 = tmpMeta59;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _simVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simVar;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_unparseCommentOptionNoAnnotationNoQuote(threadData_t *threadData, modelica_metatype _absynComment)
{
  modelica_string _commentStr = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _commentStr has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _absynComment;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          _commentStr = tmpMeta8;
          /* Pattern matching succeeded */
          tmp1 = _commentStr;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT31;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _commentStr = tmp1;
  _return: OMC_LABEL_UNUSED
  return _commentStr;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getAliasVar1(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inVar)
{
  modelica_metatype _outAlias = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outAlias has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inExp;
    {
      modelica_metatype _name = NULL;
      modelica_metatype _fname = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _name has no default value.
      // _fname has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _name = tmpMeta6;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta7 = mmc_mk_box2(4, &SimCodeVar_AliasVariable_ALIAS__desc, _name);
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,5,1) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,6,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          
          _name = tmpMeta10;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta11 = mmc_mk_box2(5, &SimCodeVar_AliasVariable_NEGATEDALIAS__desc, _name);
          tmpMeta1 = tmpMeta11;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,1) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,6,2) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          
          _name = tmpMeta14;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta15 = mmc_mk_box2(5, &SimCodeVar_AliasVariable_NEGATEDALIAS__desc, _name);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,24,1) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,6,2) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          
          _name = tmpMeta18;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta19 = mmc_mk_box2(5, &SimCodeVar_AliasVariable_NEGATEDALIAS__desc, _name);
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta21)) goto tmp3_end;
          tmpMeta22 = MMC_CAR(tmpMeta21);
          tmpMeta23 = MMC_CDR(tmpMeta21);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,6,2) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          if (!listEmpty(tmpMeta23)) goto tmp3_end;
          
          _fname = tmpMeta20;
          _name = tmpMeta24;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          omc_Builtin_isDer(threadData, _fname);

          _name = omc_ComponentReference_crefPrefixDer(threadData, _name);
          tmpMeta25 = mmc_mk_box2(4, &SimCodeVar_AliasVariable_ALIAS__desc, _name);
          tmpMeta1 = tmpMeta25;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,5,1) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,13,3) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 3));
          if (listEmpty(tmpMeta29)) goto tmp3_end;
          tmpMeta30 = MMC_CAR(tmpMeta29);
          tmpMeta31 = MMC_CDR(tmpMeta29);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,6,2) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          if (!listEmpty(tmpMeta31)) goto tmp3_end;
          
          _fname = tmpMeta28;
          _name = tmpMeta32;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          omc_Builtin_isDer(threadData, _fname);

          _name = omc_ComponentReference_crefPrefixDer(threadData, _name);
          tmpMeta33 = mmc_mk_box2(5, &SimCodeVar_AliasVariable_NEGATEDALIAS__desc, _name);
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,6,1) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,13,3) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 3));
          if (listEmpty(tmpMeta37)) goto tmp3_end;
          tmpMeta38 = MMC_CAR(tmpMeta37);
          tmpMeta39 = MMC_CDR(tmpMeta37);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,6,2) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          if (!listEmpty(tmpMeta39)) goto tmp3_end;
          
          _fname = tmpMeta36;
          _name = tmpMeta40;
          /* Pattern matching succeeded */
          omc_Builtin_isDer(threadData, _fname);

          _name = omc_ComponentReference_crefPrefixDer(threadData, _name);
          tmpMeta41 = mmc_mk_box2(5, &SimCodeVar_AliasVariable_NEGATEDALIAS__desc, _name);
          tmpMeta1 = tmpMeta41;
          goto tmp3_done;
        }
        case 7: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT88;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 8) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outAlias = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outAlias;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getAliasVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inAliasVars)
{
  modelica_metatype _outAlias = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outAlias has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inAliasVars;
    {
      modelica_metatype _name = NULL;
      modelica_metatype _aliasVars = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _name has no default value.
      // _aliasVars has no default value.
      // _var has no default value.
      // _e has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _aliasVars = tmpMeta6;
          _name = tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta8 = omc_BackendVariable_getVar(threadData, _name, _aliasVars, NULL);
          if (listEmpty(tmpMeta8)) goto goto_2;
          tmpMeta9 = MMC_CAR(tmpMeta8);
          tmpMeta10 = MMC_CDR(tmpMeta8);
          _var = tmpMeta9;

          _e = omc_BackendVariable_varBindExp(threadData, _var);

          _e = omc_ExpressionSimplify_simplify(threadData, _e, NULL);
          tmpMeta1 = omc_SimCodeUtil_getAliasVar1(threadData, _e, _var);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT88;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outAlias = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outAlias;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getArraySimVars(threadData_t *threadData, modelica_metatype _iSimVar, modelica_metatype _iArrayMapping)
{
  modelica_metatype _oArrayMapping = NULL;
  modelica_metatype _name = NULL;
  modelica_metatype _arrayCref = NULL;
  modelica_metatype _tmpArrayMapping = NULL;
  modelica_metatype _arrayVars = NULL;
  modelica_integer _index;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oArrayMapping has no default value.
  // _name has no default value.
  // _arrayCref has no default value.
  _tmpArrayMapping = _iArrayMapping;
  // _arrayVars has no default value.
  // _index has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iSimVar;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 21));
          if (listEmpty(tmpMeta9)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmpMeta9);
          tmpMeta11 = MMC_CDR(tmpMeta9);
          
          _name = tmpMeta6;
          _index = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _arrayCref = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _name);

          if(omc_BaseHashTable_hasKey(threadData, _arrayCref, _iArrayMapping))
          {
            _arrayVars = omc_BaseHashTable_get(threadData, _arrayCref, _iArrayMapping);

            tmpMeta12 = mmc_mk_cons(mmc_mk_integer(_index), _arrayVars);
            tmpMeta13 = mmc_mk_box2(0, _arrayCref, tmpMeta12);
            _tmpArrayMapping = omc_BaseHashTable_add(threadData, tmpMeta13, _tmpArrayMapping);
          }
          else
          {
            tmpMeta14 = mmc_mk_cons(mmc_mk_integer(_index), MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta15 = mmc_mk_box2(0, _arrayCref, tmpMeta14);
            _tmpArrayMapping = omc_BaseHashTable_add(threadData, tmpMeta15, _tmpArrayMapping);
          }
          tmpMeta1 = _tmpArrayMapping;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iArrayMapping;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oArrayMapping = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oArrayMapping;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createCrefToSimVarHT(threadData_t *threadData, modelica_metatype _modelInfo)
{
  modelica_metatype _outHT = NULL;
  modelica_integer _size;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _arraySimVars = NULL;
  modelica_metatype _vars = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHT has no default value.
  // _size has no default value.
  // _varInfo has no default value.
  // _arraySimVars has no default value.
  // _vars has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          /* Pattern matching succeeded */
          _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));

          _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

          _size = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 6)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 7)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 9)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 10)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 11)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 12)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 13)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 14)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 15)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 16)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 17)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 18)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 29)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 30))));

          _size = modelica_integer_max((modelica_integer)(_size),(modelica_integer)(((modelica_integer) 1023)));

          _outHT = omc_HashTableCrefSimVar_emptyHashTableSized(threadData, _size);

          _arraySimVars = omc_HashTableCrILst_emptyHashTableSized(threadData, _size);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 2))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 3))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 4))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _arraySimVars = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 4))), boxvar_SimCodeUtil_getArraySimVars, _arraySimVars);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 5))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 6))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 7))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 13))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _arraySimVars = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 13))), boxvar_SimCodeUtil_getArraySimVars, _arraySimVars);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 14))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 15))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 10))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _arraySimVars = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 10))), boxvar_SimCodeUtil_getArraySimVars, _arraySimVars);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 11))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 12))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 16))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 17))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 18))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 19))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 20))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 21))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 22))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 23))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 28))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 24))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 25))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 26))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);

          _outHT = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 27))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _outHT);
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT286, _OMC_LIT287);

          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _outHT;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_transformUnitToBaseUnit(threadData_t *threadData, modelica_metatype _unit)
{
  modelica_metatype _baseUnit = NULL;
  modelica_integer _mol;
  modelica_integer _cd;
  modelica_integer _m;
  modelica_integer _s;
  modelica_integer _A;
  modelica_integer _K;
  modelica_integer _kg;
  modelica_real _factor;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_integer tmp11;
  modelica_metatype tmpMeta12;
  modelica_integer tmp13;
  modelica_metatype tmpMeta14;
  modelica_integer tmp15;
  modelica_metatype tmpMeta16;
  modelica_real tmp17;
  modelica_real tmp18;
  modelica_real tmp19;
  modelica_real tmp20;
  modelica_real tmp21;
  modelica_real tmp22;
  modelica_real tmp23;
  modelica_real tmp24;
  modelica_metatype tmpMeta25;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _baseUnit has no default value.
  // _mol has no default value.
  // _cd has no default value.
  // _m has no default value.
  // _s has no default value.
  // _A has no default value.
  // _K has no default value.
  // _kg has no default value.
  // _factor has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _unit;
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta1,0,8) == 0) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 6));
  tmp11 = mmc_unbox_integer(tmpMeta10);
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmp13 = mmc_unbox_integer(tmpMeta12);
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmp15 = mmc_unbox_integer(tmpMeta14);
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  tmp17 = mmc_unbox_real(tmpMeta16);
  _s = tmp3  /* pattern as ty=Integer */;
  _m = tmp5  /* pattern as ty=Integer */;
  _kg = tmp7  /* pattern as ty=Integer */;
  _A = tmp9  /* pattern as ty=Integer */;
  _K = tmp11  /* pattern as ty=Integer */;
  _mol = tmp13  /* pattern as ty=Integer */;
  _cd = tmp15  /* pattern as ty=Integer */;
  _factor = tmp17  /* pattern as ty=Real */;

  tmp18 = 10.0;
  tmp19 = ((modelica_real)(((modelica_integer) -3)) * (_kg));
  if(tmp18 < 0.0 && tmp19 != 0.0)
  {
    tmp21 = modf(tmp19, &tmp22);
    
    if(tmp21 > 0.5)
    {
      tmp21 -= 1.0;
      tmp22 += 1.0;
    }
    else if(tmp21 < -0.5)
    {
      tmp21 += 1.0;
      tmp22 -= 1.0;
    }
    
    if(fabs(tmp21) < 1e-10)
      tmp20 = pow(tmp18, tmp22);
    else
    {
      tmp24 = modf(1.0/tmp19, &tmp23);
      if(tmp24 > 0.5)
      {
        tmp24 -= 1.0;
        tmp23 += 1.0;
      }
      else if(tmp24 < -0.5)
      {
        tmp24 += 1.0;
        tmp23 -= 1.0;
      }
      if(fabs(tmp24) < 1e-10 && ((unsigned long)tmp23 & 1))
      {
        tmp20 = -pow(-tmp18, tmp21)*pow(tmp18, tmp22);
      }
      else
      {
        MMC_THROW_INTERNAL();
      }
    }
  }
  else
  {
    tmp20 = pow(tmp18, tmp19);
  }
  if(isnan(tmp20) || isinf(tmp20))
  {
    MMC_THROW_INTERNAL();
  }tmpMeta25 = mmc_mk_box10(3, &SimCode_BaseUnit_BASEUNIT__desc, mmc_mk_integer(_s), mmc_mk_integer(_m), mmc_mk_integer(_kg), mmc_mk_integer(_A), mmc_mk_integer(_K), mmc_mk_integer(_mol), mmc_mk_integer(_cd), mmc_mk_real((_factor) * (tmp20)), _OMC_LIT89);
  _baseUnit = tmpMeta25;
  _return: OMC_LABEL_UNUSED
  return _baseUnit;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiUnitDefinitionsHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype __omcQ_24in_5FunitDefinitions, modelica_metatype __omcQ_24in_5FunitNameKeys, modelica_metatype *out_unitNameKeys)
{
  modelica_metatype _unitDefinitions = NULL;
  modelica_metatype _unitNameKeys = NULL;
  modelica_metatype _unit = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _unitDefinitions = __omcQ_24in_5FunitDefinitions;
  _unitNameKeys = __omcQ_24in_5FunitNameKeys;
  // _unit has no default value.
  {
    modelica_metatype _var;
    for (tmpMeta1 = _inVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 31)))))
      {
        if(((!(stringEqual((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), _OMC_LIT31))) && (!omc_BaseHashSet_has(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), _unitNameKeys))))
        {
          _unitNameKeys = omc_BaseHashSet_add(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), _unitNameKeys);

          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp4;
              int tmp5;
              tmp4 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp3_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp4 < 2; tmp4++) {
                switch (MMC_SWITCH_CAST(tmp4)) {
                case 0: {
                  modelica_metatype tmpMeta6;
                  modelica_metatype tmpMeta7;
                  /* Pattern matching succeeded */
                  _unit = omc_NFUnit_parseUnitString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), omc_NFUnit_getKnownUnits(threadData), _OMC_LIT90);

                  tmpMeta7 = mmc_mk_box3(3, &SimCode_UnitDefinition_UNITDEFINITION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), omc_SimCodeUtil_transformUnitToBaseUnit(threadData, _unit));
                  tmpMeta6 = mmc_mk_cons(tmpMeta7, _unitDefinitions);
                  _unitDefinitions = tmpMeta6;
                  goto tmp3_done;
                }
                case 1: {
                  modelica_metatype tmpMeta8;
                  modelica_metatype tmpMeta9;
                  /* Pattern matching succeeded */
                  tmpMeta9 = mmc_mk_box3(3, &SimCode_UnitDefinition_UNITDEFINITION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 5))), _OMC_LIT288);
                  tmpMeta8 = mmc_mk_cons(tmpMeta9, _unitDefinitions);
                  _unitDefinitions = tmpMeta8;
                  goto tmp3_done;
                }
                }
                goto tmp3_end;
                tmp3_end: ;
              }
              goto goto_2;
              tmp3_done:
              (void)tmp4;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp3_done2;
              goto_2:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp4 < 2) {
                goto tmp3_top;
              }
              MMC_THROW_INTERNAL();
              tmp3_done2:;
            }
          }
          ;
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_unitNameKeys) { *out_unitNameKeys = _unitNameKeys; }
  return _unitDefinitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFmiUnitDefinitions(threadData_t *threadData, modelica_metatype _simVars)
{
  modelica_metatype _unitDefinitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _unitNameKeys = NULL;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _unitDefinitions = tmpMeta1;
  // _unitNameKeys has no default value.
  _unitNameKeys = omc_HashSetString_emptyHashSet(threadData);

  tmp2 = 1; tmp3 = 1; tmp4 = 24;
  if(!(((tmp3 > 0) && (tmp2 > tmp4)) || ((tmp3 < 0) && (tmp2 < tmp4))))
  {
    modelica_integer _i;
    for(_i = 1; in_range_integer(_i, tmp2, tmp4); _i += tmp3)
    {
      _unitDefinitions = omc_SimCodeUtil_getFmiUnitDefinitionsHelper(threadData, arrayGetNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i))), _unitDefinitions, _unitNameKeys ,&_unitNameKeys);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _unitDefinitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVariableIndexHelper2(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype __omcQ_24in_5Ftpl, modelica_metatype *out_tpl)
{
  modelica_metatype _var = NULL;
  modelica_metatype _tpl = NULL;
  modelica_integer _index;
  modelica_integer _fmi_index;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _var = __omcQ_24in_5Fvar;
  _tpl = __omcQ_24in_5Ftpl;
  // _index has no default value.
  // _fmi_index has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _index = tmp3  /* pattern as ty=Integer */;
  _fmi_index = tmp5  /* pattern as ty=Integer */;

  tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[19] = mmc_mk_some(mmc_mk_integer(_index));
  _var = tmpMeta6;

  _index = _index + omc_SimCodeUtilShared_getNumElems(threadData, _var);

  if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 31)))))
  {
    tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[20] = mmc_mk_some(mmc_mk_integer(_fmi_index));
    _var = tmpMeta7;

    _fmi_index = _fmi_index + omc_SimCodeUtilShared_getNumElems(threadData, _var);
  }
  else
  {
    tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[20] = mmc_mk_none();
    _var = tmpMeta8;
  }

  tmpMeta9 = mmc_mk_box2(0, mmc_mk_integer(_index), mmc_mk_integer(_fmi_index));
  _tpl = tmpMeta9;
  _return: OMC_LABEL_UNUSED
  if (out_tpl) { *out_tpl = _tpl; }
  return _var;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_setVariableIndexHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_integer _inIndex, modelica_integer _inFMIIndex, modelica_integer *out_outIndex, modelica_integer *out_outFMIIndex)
{
  modelica_metatype _outVars = NULL;
  modelica_integer _outIndex;
  modelica_integer _outFMIIndex;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _outIndex has no default value.
  // _outFMIIndex has no default value.
  /* Pattern-matching tuple assignment */
  tmpMeta6 = mmc_mk_box2(0, mmc_mk_integer(_inIndex), mmc_mk_integer(_inFMIIndex));
  tmpMeta7 = omc_List_mapFold(threadData, _inVars, boxvar_SimCodeUtil_setVariableIndexHelper2, tmpMeta6, &tmpMeta1);
  _outVars = tmpMeta7;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _outIndex = tmp3  /* pattern as ty=Integer */;
  _outFMIIndex = tmp5  /* pattern as ty=Integer */;
  _return: OMC_LABEL_UNUSED
  if (out_outIndex) { *out_outIndex = _outIndex; }
  if (out_outFMIIndex) { *out_outFMIIndex = _outFMIIndex; }
  return _outVars;
}
modelica_metatype boxptr_SimCodeUtil_setVariableIndexHelper(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inIndex, modelica_metatype _inFMIIndex, modelica_metatype *out_outIndex, modelica_metatype *out_outFMIIndex)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _outIndex;
  modelica_integer _outFMIIndex;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_inIndex);
  tmp2 = mmc_unbox_integer(_inFMIIndex);
  _outVars = omc_SimCodeUtil_setVariableIndexHelper(threadData, _inVars, tmp1, tmp2, &_outIndex, &_outFMIIndex);
  /* skip box _outVars; list<SimCodeVar.SimVar> */
  if (out_outIndex) { *out_outIndex = mmc_mk_icon(_outIndex); }
  if (out_outFMIIndex) { *out_outFMIIndex = mmc_mk_icon(_outFMIIndex); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_setVariableIndex(threadData_t *threadData, modelica_metatype _simVars)
{
  modelica_integer _index_;
  modelica_integer _fmi_index_;
  modelica_metatype _lst = NULL;
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _index_ = ((modelica_integer) 1);
  _fmi_index_ = ((modelica_integer) 1);
  // _lst has no default value.
  tmp1 = 1; tmp2 = 1; tmp3 = 24;
  if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
  {
    modelica_integer _i;
    for(_i = 1; in_range_integer(_i, tmp1, tmp3); _i += tmp2)
    {
      _lst = omc_SimCodeUtil_setVariableIndexHelper(threadData, arrayGetNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i))), _index_, _fmi_index_ ,&_index_ ,&_fmi_index_);

      arrayUpdateNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i)), _lst);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_rewriteIndexColumnMajor(threadData_t *threadData, modelica_metatype _inVars, modelica_integer __omcQ_24in_5Findex, modelica_integer *out_index)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _index;
  modelica_metatype _subs = NULL;
  modelica_metatype _arrayDimensions = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _elementIndex;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = tmpMeta1;
  _index = __omcQ_24in_5Findex;
  // _subs has no default value.
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _arrayDimensions = tmpMeta2;
  // _elementIndex has no default value.
  {
    modelica_metatype _var;
    for (tmpMeta3 = _inVars; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _var = MMC_CAR(tmpMeta3);
      _subs = omc_ComponentReference_crefLastSubs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));

      if((listLength(_subs) > ((modelica_integer) 1)))
      {
        _arrayDimensions = omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 21))), boxvar_stringInt);

        _elementIndex = omc_SimCodeUtilShared_getScalarElementIndex(threadData, _subs, _arrayDimensions);

        tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(33));
        memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
        ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[7] = mmc_mk_integer(_index + omc_SimCodeUtil_convertIndexToColumnMajor(threadData, _elementIndex, _arrayDimensions) - _elementIndex);
        _var = tmpMeta4;
      }
      else
      {
        tmpMeta5 = MMC_TAGPTR(mmc_alloc_words(33));
        memcpy(MMC_UNTAGPTR(tmpMeta5), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
        ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta5))[7] = mmc_mk_integer(_index);
        _var = tmpMeta5;
      }

      tmpMeta6 = mmc_mk_cons(_var, _outVars);
      _outVars = tmpMeta6;

      _index = ((modelica_integer) 1) + _index;
    }
  }

  _outVars = listReverseInPlace(_outVars);
  _return: OMC_LABEL_UNUSED
  if (out_index) { *out_index = _index; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_rewriteIndexColumnMajor(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype __omcQ_24in_5Findex, modelica_metatype *out_index)
{
  modelica_integer tmp1;
  modelica_integer _index;
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5Findex);
  _outVars = omc_SimCodeUtil_rewriteIndexColumnMajor(threadData, _inVars, tmp1, &_index);
  /* skip box _outVars; list<SimCodeVar.SimVar> */
  if (out_index) { *out_index = mmc_mk_icon(_index); }
  return _outVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_rewriteIndex(threadData_t *threadData, modelica_metatype _inVars, modelica_integer __omcQ_24in_5Findex, modelica_integer *out_index)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _index;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = tmpMeta1;
  _index = __omcQ_24in_5Findex;
  {
    modelica_metatype _var;
    for (tmpMeta2 = _inVars; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _var = MMC_CAR(tmpMeta2);
      tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(33));
      memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_var), 33*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[7] = mmc_mk_integer(_index);
      _var = tmpMeta3;

      tmpMeta4 = mmc_mk_cons(_var, _outVars);
      _outVars = tmpMeta4;

      _index = ((modelica_integer) 1) + _index;
    }
  }

  _outVars = listReverseInPlace(_outVars);
  _return: OMC_LABEL_UNUSED
  if (out_index) { *out_index = _index; }
  return _outVars;
}
modelica_metatype boxptr_SimCodeUtil_rewriteIndex(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype __omcQ_24in_5Findex, modelica_metatype *out_index)
{
  modelica_integer tmp1;
  modelica_integer _index;
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5Findex);
  _outVars = omc_SimCodeUtil_rewriteIndex(threadData, _inVars, tmp1, &_index);
  /* skip box _outVars; list<SimCodeVar.SimVar> */
  if (out_index) { *out_index = mmc_mk_icon(_index); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_fixIndex(threadData_t *threadData, modelica_metatype _simVars)
{
  modelica_integer _ix;
  modelica_metatype _lst = NULL;
  modelica_boolean _isCpp;
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _ix = ((modelica_integer) 0);
  // _lst has no default value.
  _isCpp = (stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119));
  tmp1 = 1; tmp2 = 1; tmp3 = 6;
  if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
  {
    modelica_integer _i;
    for(_i = 1; in_range_integer(_i, tmp1, tmp3); _i += tmp2)
    {
      _lst = arrayGetNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i)));

      if((!_isCpp))
      {
        arrayUpdateNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i)), omc_SimCodeUtil_rewriteIndex(threadData, _lst, _ix, NULL));

        _ix = _ix + listLength(_lst);
      }
      else
      {
        arrayUpdateNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i)), omc_SimCodeUtil_rewriteIndexColumnMajor(threadData, _lst, ((modelica_integer) 0), NULL));
      }
    }
  }

  tmp4 = 7; tmp5 = 1; tmp6 = 24;
  if(!(((tmp5 > 0) && (tmp4 > tmp6)) || ((tmp5 < 0) && (tmp4 < tmp6))))
  {
    modelica_integer _i;
    for(_i = 7; in_range_integer(_i, tmp4, tmp6); _i += tmp5)
    {
      arrayUpdateNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i)), omc_SimCodeUtil_rewriteIndex(threadData, arrayGetNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_i))), ((modelica_integer) 0), NULL));
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectArrayFirstVars(threadData_t *threadData, modelica_metatype _var, modelica_metatype _iSet)
{
  modelica_metatype _oSet = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSet has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 15));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);
          tmpMeta1 = omc_BaseHashSet_add(threadData, _cr, _iSet);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iSet;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oSet = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oSet;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addSimVarArrayCref(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _arrayCref)
{
  modelica_metatype _oVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _oVar = _iVar;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_oVar), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[15] = mmc_mk_some(_arrayCref);
  _oVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setArrayElementnoFirst(threadData_t *threadData, modelica_metatype _iVar, modelica_metatype _iSet, modelica_metatype *out_oSet)
{
  modelica_metatype _oVar = NULL;
  modelica_metatype _oSet = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVar has no default value.
  // _oSet has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _iVar;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _set = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _var has no default value.
      // _set has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 15));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _iVar;
          tmpMeta[0+1] = _iSet;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_boolean tmp16;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 15));
          if (!optionNone(tmpMeta9)) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 21));
          if (listEmpty(tmpMeta10)) goto tmp3_end;
          tmpMeta11 = MMC_CAR(tmpMeta10);
          tmpMeta12 = MMC_CDR(tmpMeta10);
          
          _cr = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta13 = omc_ComponentReference_crefLastSubs(threadData, _cr);
          if (listEmpty(tmpMeta13)) goto goto_2;
          tmpMeta14 = MMC_CAR(tmpMeta13);
          tmpMeta15 = MMC_CDR(tmpMeta13);

          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);

          /* Pattern-matching assignment */
          tmp16 = omc_BaseHashSet_has(threadData, _cr, _iSet);
          if (0 /* false */ != tmp16) goto goto_2;

          _var = omc_SimCodeUtil_addSimVarArrayCref(threadData, _iVar, _cr);

          _set = omc_BaseHashSet_add(threadData, _cr, _iSet);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = _set;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVar;
          tmpMeta[0+1] = _iSet;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oVar = tmpMeta[0+0];
  _oSet = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oSet) { *out_oSet = _oSet; }
  return _oVar;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extendIncompleteArray(threadData_t *threadData, modelica_metatype _simvars)
{
  modelica_metatype _simVars = NULL;
  modelica_metatype _set = NULL;
  int tmp1;
  modelica_integer tmp2;
  int tmp3;
  modelica_integer tmp4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simVars has no default value.
  // _set has no default value.
  _set = omc_HashSet_emptyHashSet(threadData);

  {
    modelica_integer _i;
    for(tmp1 = 1; tmp1 <= size_of_dimension_base_array(_OMC_LIT289, 1); ++tmp1)
    {
      _i = integer_array_get1(_OMC_LIT289, 1, tmp1);
      _set = omc_List_fold(threadData, arrayGetNoBoundsChecking(_simvars, ((modelica_integer)((modelica_integer)_i))), boxvar_SimCodeUtil_collectArrayFirstVars, _set);
    }
  }

  {
    modelica_integer _i;
    for(tmp3 = 1; tmp3 <= size_of_dimension_base_array(_OMC_LIT289, 1); ++tmp3)
    {
      _i = integer_array_get1(_OMC_LIT289, 1, tmp3);
      _simVars = omc_List_mapFold(threadData, arrayGetNoBoundsChecking(_simvars, ((modelica_integer)((modelica_integer)_i))), boxvar_SimCodeUtil_setArrayElementnoFirst, _set ,&_set);

      arrayUpdateNoBoundsChecking(_simvars, ((modelica_integer)((modelica_integer)_i)), _simVars);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_simVarCompareByCrefSubsAtEndlLexical(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _outBool;
  modelica_metatype _cr1 = NULL;
  modelica_metatype _cr2 = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  // _cr1 has no default value.
  // _cr2 has no default value.
  _cr1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var1), 2)));

  _cr2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var2), 2)));

  _outBool = omc_ComponentReferenceBasics_crefLexicalGreaterSubsAtEnd(threadData, _cr1, _cr2);
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_SimCodeUtil_simVarCompareByCrefSubsAtEndlLexical(threadData_t *threadData, modelica_metatype _var1, modelica_metatype _var2)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_SimCodeUtil_simVarCompareByCrefSubsAtEndlLexical(threadData, _var1, _var2);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_sortSimvars(threadData_t *threadData, modelica_metatype _simvars)
{
  modelica_integer _i;
  modelica_metatype _arr = NULL;
  int tmp1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4 = 0;
  modelica_metatype tmpMeta11;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _i = ((modelica_integer) 0);
  // _arr has no default value.
  {
    modelica_integer _i;
    for(tmp1 = 1; tmp1 <= size_of_dimension_base_array(_OMC_LIT289, 1); ++tmp1)
    {
      _i = integer_array_get1(_OMC_LIT289, 1, tmp1);
      arrayUpdateNoBoundsChecking(_simvars, ((modelica_integer)((modelica_integer)_i)), omc_List_sort(threadData, arrayGetNoBoundsChecking(_simvars, ((modelica_integer)((modelica_integer)_i))), boxvar_SimCodeUtil_simVarCompareByCrefSubsAtEndlLexical));
    }
  }

  {
    modelica_metatype _v;
    for (tmpMeta3 = arrayGetNoBoundsChecking(_simvars, ((modelica_integer) 19)); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _v = MMC_CAR(tmpMeta3);
      { /* match expression */
        modelica_metatype tmp7_1;
        tmp7_1 = _v;
        {
          volatile mmc_switch_type tmp7;
          int tmp8;
          tmp7 = 0;
          for (; tmp7 < 2; tmp7++) {
            switch (MMC_SWITCH_CAST(tmp7)) {
            case 0: {
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 26));
              if (optionNone(tmpMeta9)) goto tmp6_end;
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
              
              _arr = tmpMeta10;
              /* Pattern matching succeeded */
              arrayUpdate(_arr, ((modelica_integer) 1), mmc_mk_integer(_i));
              tmp4 = ((modelica_integer) 1) + _i;
              goto tmp6_done;
            }
            case 1: {
              
              /* Pattern matching succeeded */
              omc_Error_addInternalError(threadData, _OMC_LIT290, _OMC_LIT291);
              goto goto_5;
              goto tmp6_done;
            }
            }
            goto tmp6_end;
            tmp6_end: ;
          }
          goto goto_5;
          goto_5:;
          MMC_THROW_INTERNAL();
          goto tmp6_done;
          tmp6_done:;
        }
      }
      _i = tmp4;
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isAliasVar(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _res;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 16));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _res = tmp1;
  _return: OMC_LABEL_UNUSED
  return _res;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isAliasVar(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _res;
  modelica_metatype out_res;
  _res = omc_SimCodeUtil_isAliasVar(threadData, _var);
  out_res = mmc_mk_icon(_res);
  return out_res;
}

DLLDirection
void omc_SimCodeUtil_dumpSimCodeDebug(threadData_t *threadData, modelica_metatype _simCode)
{
  modelica_metatype _jacObs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _jacObs has no default value.
  fputs(MMC_STRINGDATA(_OMC_LIT292),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT293),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 8))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT294),stdout);

  tmpMeta1 = stringAppend(_OMC_LIT295,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 9))))));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT296);
  tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT122);
  tmpMeta4 = stringAppend(tmpMeta3,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta4),stdout);

  omc_List_map1__0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 9))), boxvar_SimCodeUtil_dumpSimEqSystemLst, _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT294),stdout);

  tmpMeta5 = stringAppend(_OMC_LIT297,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 10))))));
  tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT296);
  tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT122);
  tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta8),stdout);

  omc_List_map1__0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 10))), boxvar_SimCodeUtil_dumpSimEqSystemLst, _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT294),stdout);

  tmpMeta9 = stringAppend(_OMC_LIT298,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 11))))));
  tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT299);
  fputs(MMC_STRINGDATA(tmpMeta10),stdout);

  omc_List_map__0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 11))), boxvar_SimCodeUtil_dumpClockPartition);

  fputs(MMC_STRINGDATA(_OMC_LIT294),stdout);

  tmpMeta11 = stringAppend(_OMC_LIT300,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 12))))));
  tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT47);
  tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT122);
  tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta14),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 12))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT294),stdout);

  tmpMeta15 = stringAppend(_OMC_LIT301,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 13))))));
  tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT47);
  tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT122);
  tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta18),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 13))), _OMC_LIT48);

  if((omc_Flags_getConfigEnum(threadData, _OMC_LIT320) > ((modelica_integer) 0)))
  {
    tmpMeta19 = stringAppend(_OMC_LIT302,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 51))))));
    tmpMeta20 = stringAppend(tmpMeta19,_OMC_LIT303);
    tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT122);
    tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT48);
    fputs(MMC_STRINGDATA(tmpMeta22),stdout);

    omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 51))), _OMC_LIT48);
  }

  fputs(MMC_STRINGDATA(_OMC_LIT321),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 14))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT322),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 15))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT323),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 16))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT324),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 17))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT325),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 18))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT326),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 19))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT327),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 20))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT328),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 21))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT329),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 22))), _OMC_LIT48);

  fputs(MMC_STRINGDATA(_OMC_LIT330),stdout);

  fputs(MMC_STRINGDATA(omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 6))), boxvar_SimCodeUtil_simGenericCallString, _OMC_LIT31, _OMC_LIT31, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0))),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT331),stdout);

  omc_SimCodeUtil_dumpSimEqSystemLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 23))), _OMC_LIT48);

  omc_SimCodeUtil_extObjInfoString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 31))));

  fputs(MMC_STRINGDATA(_OMC_LIT332),stdout);

  _jacObs = omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 35))), boxvar_Util_makeOption);

  omc_List_map__0(threadData, _jacObs, boxvar_SimCodeUtil_dumpJacobianMatrix);

  fputs(MMC_STRINGDATA(_OMC_LIT333),stdout);

  omc_SimCodeUtil_dumpModelInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 2))));

  omc_SimCodeUtil_dumpSimCodeDAEmodeDataString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simCode), 50))));
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_string omc_SimCodeUtil_dumpSimCodeDAEmodeDataString(threadData_t *threadData, modelica_metatype _inDaeModedata)
{
  modelica_string _str = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _str = _OMC_LIT31;
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _inDaeModedata;
    {
      modelica_metatype _dmd = NULL;
      modelica_metatype _sparsity = NULL;
      modelica_metatype _sparsityT = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _dmd has no default value.
      // _sparsity has no default value.
      // _sparsityT has no default value.
      tmp3 = 0;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (optionNone(tmp3_1)) goto tmp2_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 1));
          _dmd = tmpMeta5;
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT334),stdout);

          _str = _OMC_LIT335;

          fputs(MMC_STRINGDATA(_str),stdout);

          omc_SimCodeUtil_dumpSimEqSystemLst(threadData, omc_List_flatten(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 2)))), _OMC_LIT48);

          tmpMeta6 = stringAppend(_OMC_LIT336,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 4))))));
          tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT337);
          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 4))), tmpMeta7);

          tmpMeta8 = stringAppend(_OMC_LIT338,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 5))))));
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT337);
          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 5))), tmpMeta9);

          tmpMeta10 = stringAppend(_OMC_LIT339,intString(listLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 6))))));
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT337);
          omc_SimCodeUtil_dumpVarLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 6))), tmpMeta11);

          if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 3)))))
          {
            _str = _OMC_LIT340;

            fputs(MMC_STRINGDATA(_str),stdout);

            /* Pattern-matching assignment */
            tmpMeta12 = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dmd), 3))));
            tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 5));
            tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 6));
            _sparsity = tmpMeta13;
            _sparsityT = tmpMeta14;

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparsity);

            _str = _OMC_LIT341;

            fputs(MMC_STRINGDATA(_str),stdout);

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparsityT);
          }
          goto tmp2_done;
        }
        case 1: {
          if (!optionNone(tmp3_1)) goto tmp2_end;
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _str;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_subPartitionString(threadData_t *threadData, modelica_metatype _subPart)
{
  modelica_string _str = NULL;
  modelica_metatype _simVars = NULL;
  modelica_metatype _arePrevious = NULL;
  modelica_metatype _simVarStrings = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _simVars has no default value.
  // _arePrevious has no default value.
  // _simVarStrings has no default value.
  _simVars = omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 2))), boxvar_Util_tuple21);

  _arePrevious = omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 2))), boxvar_Util_tuple22);

  _simVarStrings = omc_List_threadMap(threadData, omc_List_map(threadData, _simVars, boxvar_SimCodeUtil_simVarString), omc_List_map(threadData, _arePrevious, boxvar_SimCodeUtil_previousString), boxvar_stringAppend);

  _str = _OMC_LIT342;

  tmpMeta1 = stringAppend(_str,stringDelimitList(_simVarStrings, _OMC_LIT48));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT48);
  _str = tmpMeta2;

  tmpMeta3 = stringAppend(_str,_OMC_LIT343);
  tmpMeta4 = stringAppend(tmpMeta3,_OMC_LIT122);
  tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT48);
  _str = tmpMeta5;

  tmpMeta6 = stringAppend(_str,stringDelimitList(omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 3))), boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT48));
  tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT48);
  _str = tmpMeta7;

  tmpMeta8 = stringAppend(_str,_OMC_LIT344);
  tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT122);
  tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT48);
  _str = tmpMeta10;

  tmpMeta11 = stringAppend(_str,stringDelimitList(omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 4))), boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT48));
  _str = tmpMeta11;

  tmpMeta12 = stringAppend(_str,_OMC_LIT345);
  tmpMeta13 = stringAppend(tmpMeta12,omc_BackendDump_subClockString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 5)))));
  tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT48);
  _str = tmpMeta14;

  tmpMeta15 = stringAppend(_str,_OMC_LIT346);
  tmpMeta16 = stringAppend(tmpMeta15,(mmc_unbox_boolean((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPart), 6))))?_OMC_LIT347:_OMC_LIT348));
  _str = tmpMeta16;
  _return: OMC_LABEL_UNUSED
  return _str;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_previousString(threadData_t *threadData, modelica_boolean _isPreviousVar)
{
  modelica_string _s = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _s has no default value.
  if(_isPreviousVar)
  {
    _s = _OMC_LIT350;
  }
  else
  {
    _s = _OMC_LIT349;
  }
  _return: OMC_LABEL_UNUSED
  return _s;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_previousString(threadData_t *threadData, modelica_metatype _isPreviousVar)
{
  modelica_integer tmp1;
  modelica_string _s = NULL;
  tmp1 = mmc_unbox_integer(_isPreviousVar);
  _s = omc_SimCodeUtil_previousString(threadData, tmp1);
  /* skip box _s; String */
  return _s;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpClockPartition(threadData_t *threadData, modelica_metatype _clockPart)
{
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_OMC_LIT351,omc_ExpressionDump_clockKindString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_clockPart), 2)))));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT122);
  tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT352);
  fputs(MMC_STRINGDATA(tmpMeta3),stdout);

  tmpMeta4 = stringAppend(stringDelimitList(omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_clockPart), 3))), boxvar_SimCodeUtil_subPartitionString), _OMC_LIT352),_OMC_LIT48);
  fputs(MMC_STRINGDATA(tmpMeta4),stdout);

  fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extObjInfoString(threadData_t *threadData, modelica_metatype _info)
{
  modelica_metatype _vars = NULL;
  modelica_metatype _aliases = NULL;
  modelica_metatype _cr1 = NULL;
  modelica_metatype _cr2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _vars has no default value.
  // _aliases has no default value.
  // _cr1 has no default value.
  // _cr2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _info;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  _vars = tmpMeta2;
  _aliases = tmpMeta3;

  omc_SimCodeUtil_dumpVarLst(threadData, _vars, _OMC_LIT353);

  if((!listEmpty(_aliases)))
  {
    tmpMeta4 = stringAppend(_OMC_LIT354,intString(listLength(_aliases)));
    tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT337);
    fputs(MMC_STRINGDATA(tmpMeta5),stdout);

    {
      modelica_metatype _tpl;
      for (tmpMeta6 = _aliases; !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
      {
        _tpl = MMC_CAR(tmpMeta6);
        /* Pattern-matching assignment */
        tmpMeta7 = _tpl;
        tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
        tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
        _cr1 = tmpMeta8;
        _cr2 = tmpMeta9;

        tmpMeta10 = stringAppend(omc_ComponentReference_crefStr(threadData, _cr1),_OMC_LIT224);
        tmpMeta11 = stringAppend(tmpMeta10,omc_ComponentReference_crefStr(threadData, _cr2));
        fputs(MMC_STRINGDATA(tmpMeta11),stdout);
      }
    }

    fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpJacobianMatrix(threadData_t *threadData, modelica_metatype _jacOpt)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _jacOpt;
    {
      modelica_integer _idx;
      modelica_metatype _jac = NULL;
      modelica_metatype _cols = NULL;
      modelica_metatype _colEqs = NULL;
      modelica_metatype _colVars = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _idx has no default value.
      // _jac has no default value.
      // _cols has no default value.
      // _colEqs has no default value.
      // _colVars has no default value.
      tmp3 = 0;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (optionNone(tmp3_1)) goto tmp2_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 1));
          _jac = tmpMeta5;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = _jac;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 12));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          _cols = tmpMeta7;
          _idx = tmp9  /* pattern as ty=Integer */;

          {
            modelica_metatype __omcQ_24tmpVar35;
            modelica_metatype* tmp11;
            modelica_metatype tmpMeta12;
            modelica_metatype __omcQ_24tmpVar34;
            modelica_integer tmp13;
            modelica_metatype _a_loopVar = 0;
            modelica_metatype _a;
            _a_loopVar = _cols;
            tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar35 = tmpMeta12; /* defaultValue */
            tmp11 = &__omcQ_24tmpVar35;
            while(1) {
              tmp13 = 1;
              if (!listEmpty(_a_loopVar)) {
                _a = MMC_CAR(_a_loopVar);
                _a_loopVar = MMC_CDR(_a_loopVar);
                tmp13--;
              }
              if (tmp13 == 0) {
                __omcQ_24tmpVar34 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_a), 2)));
                *tmp11 = mmc_mk_cons(__omcQ_24tmpVar34,0);
                tmp11 = &MMC_CDR(*tmp11);
              } else if (tmp13 == 1) {
                break;
              } else {
                goto goto_1;
              }
            }
            *tmp11 = mmc_mk_nil();
            tmpMeta10 = __omcQ_24tmpVar35;
          }
          _colEqs = omc_List_flatten(threadData, tmpMeta10);

          {
            modelica_metatype __omcQ_24tmpVar37;
            modelica_metatype* tmp15;
            modelica_metatype tmpMeta16;
            modelica_metatype __omcQ_24tmpVar36;
            modelica_integer tmp17;
            modelica_metatype _a_loopVar = 0;
            modelica_metatype _a;
            _a_loopVar = _cols;
            tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar37 = tmpMeta16; /* defaultValue */
            tmp15 = &__omcQ_24tmpVar37;
            while(1) {
              tmp17 = 1;
              if (!listEmpty(_a_loopVar)) {
                _a = MMC_CAR(_a_loopVar);
                _a_loopVar = MMC_CDR(_a_loopVar);
                tmp17--;
              }
              if (tmp17 == 0) {
                __omcQ_24tmpVar36 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_a), 3)));
                *tmp15 = mmc_mk_cons(__omcQ_24tmpVar36,0);
                tmp15 = &MMC_CDR(*tmp15);
              } else if (tmp17 == 1) {
                break;
              } else {
                goto goto_1;
              }
            }
            *tmp15 = mmc_mk_nil();
            tmpMeta14 = __omcQ_24tmpVar37;
          }
          _colVars = omc_List_flatten(threadData, tmpMeta14);

          tmpMeta18 = stringAppend(_OMC_LIT355,intString(_idx));
          tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT356);
          fputs(MMC_STRINGDATA(tmpMeta19),stdout);

          omc_SimCodeUtil_dumpSimEqSystemLst(threadData, _colEqs, _OMC_LIT356);

          fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

          tmpMeta20 = stringAppend(_OMC_LIT357,intString(listLength(_colVars)));
          tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT337);
          omc_SimCodeUtil_dumpVarLst(threadData, _colVars, tmpMeta21);
          goto tmp2_done;
        }
        case 1: {
          if (!optionNone(tmp3_1)) goto tmp2_end;
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpJacobianMatrixLst(threadData_t *threadData, modelica_metatype _simjacs)
{
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  {
    modelica_metatype _jac;
    for (tmpMeta1 = _simjacs; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _jac = MMC_CAR(tmpMeta1);
      fputs(MMC_STRINGDATA(_OMC_LIT358),stdout);

      omc_SimCodeUtil_dumpJacobianMatrix(threadData, mmc_mk_some(_jac));

      fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_dumpWhenOps(threadData_t *threadData, modelica_metatype _whenStmtLst)
{
  modelica_string _res = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype tmpMeta1;
  modelica_string tmp2 = 0;
  modelica_metatype tmpMeta32;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  // _e has no default value.
  _res = _OMC_LIT31;

  {
    modelica_metatype _whenOps;
    for (tmpMeta1 = _whenStmtLst; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _whenOps = MMC_CAR(tmpMeta1);
      { /* match expression */
        modelica_metatype tmp5_1;
        tmp5_1 = _whenOps;
        {
          volatile mmc_switch_type tmp5;
          int tmp6;
          tmp5 = 0;
          for (; tmp5 < 5; tmp5++) {
            switch (MMC_SWITCH_CAST(tmp5)) {
            case 0: {
              modelica_metatype tmpMeta7;
              modelica_metatype tmpMeta8;
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              modelica_metatype tmpMeta11;
              modelica_metatype tmpMeta12;
              if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,0,3) == 0) goto tmp4_end;
              
              _e = tmp5_1;
              /* Pattern matching succeeded */
              tmpMeta7 = stringAppend(_res,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)))));
              tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT224);
              tmpMeta9 = stringAppend(tmpMeta8,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 3)))));
              tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT359);
              tmpMeta11 = stringAppend(tmpMeta10,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 3))))));
              tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT360);
              tmp2 = tmpMeta12;
              goto tmp4_done;
            }
            case 1: {
              modelica_metatype tmpMeta13;
              modelica_metatype tmpMeta14;
              modelica_metatype tmpMeta15;
              modelica_metatype tmpMeta16;
              modelica_metatype tmpMeta17;
              modelica_metatype tmpMeta18;
              modelica_metatype tmpMeta19;
              if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,1,3) == 0) goto tmp4_end;
              
              _e = tmp5_1;
              /* Pattern matching succeeded */
              tmpMeta13 = stringAppend(_res,_OMC_LIT361);
              tmpMeta14 = stringAppend(tmpMeta13,omc_ComponentReference_debugPrintComponentRefTypeStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)))));
              tmpMeta15 = stringAppend(tmpMeta14,_OMC_LIT243);
              tmpMeta16 = stringAppend(tmpMeta15,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 3)))));
              tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT362);
              tmpMeta18 = stringAppend(tmpMeta17,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 3))))));
              tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT360);
              tmp2 = tmpMeta19;
              goto tmp4_done;
            }
            case 2: {
              modelica_metatype tmpMeta20;
              modelica_metatype tmpMeta21;
              modelica_metatype tmpMeta22;
              modelica_metatype tmpMeta23;
              modelica_metatype tmpMeta24;
              if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,2,4) == 0) goto tmp4_end;
              
              _e = tmp5_1;
              /* Pattern matching succeeded */
              tmpMeta20 = stringAppend(_res,_OMC_LIT363);
              tmpMeta21 = stringAppend(tmpMeta20,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)))));
              tmpMeta22 = stringAppend(tmpMeta21,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 3)))));
              tmpMeta23 = stringAppend(tmpMeta22,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 4)))));
              tmpMeta24 = stringAppend(tmpMeta23,_OMC_LIT337);
              tmp2 = tmpMeta24;
              goto tmp4_done;
            }
            case 3: {
              modelica_metatype tmpMeta25;
              modelica_metatype tmpMeta26;
              modelica_metatype tmpMeta27;
              if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,2) == 0) goto tmp4_end;
              
              _e = tmp5_1;
              /* Pattern matching succeeded */
              tmpMeta25 = stringAppend(_res,_OMC_LIT364);
              tmpMeta26 = stringAppend(tmpMeta25,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)))));
              tmpMeta27 = stringAppend(tmpMeta26,_OMC_LIT337);
              tmp2 = tmpMeta27;
              goto tmp4_done;
            }
            case 4: {
              modelica_metatype tmpMeta28;
              modelica_metatype tmpMeta29;
              modelica_metatype tmpMeta30;
              modelica_metatype tmpMeta31;
              if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,4,2) == 0) goto tmp4_end;
              
              _e = tmp5_1;
              /* Pattern matching succeeded */
              tmpMeta28 = stringAppend(_res,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2)))));
              tmpMeta29 = stringAppend(tmpMeta28,_OMC_LIT365);
              tmpMeta30 = stringAppend(tmpMeta29,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 2))))));
              tmpMeta31 = stringAppend(tmpMeta30,_OMC_LIT360);
              tmp2 = tmpMeta31;
              goto tmp4_done;
            }
            }
            goto tmp4_end;
            tmp4_end: ;
          }
          goto goto_3;
          goto_3:;
          MMC_THROW_INTERNAL();
          goto tmp4_done;
          tmp4_done:;
        }
      }
      _res = tmp2;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _res;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSimJac(threadData_t *threadData, modelica_metatype _simJac)
{
  modelica_integer _i1;
  modelica_integer _i2;
  modelica_string _res = NULL;
  modelica_metatype _simEqSys = NULL;
  modelica_metatype _tpl = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _i1 has no default value.
  // _i2 has no default value.
  // _res has no default value.
  // _simEqSys has no default value.
  // _tpl has no default value.
  if(listEmpty(_simJac))
  {
    _res = _OMC_LIT366;
  }
  else
  {
    _res = _OMC_LIT31;
  }

  {
    modelica_metatype _tpl;
    for (tmpMeta1 = _simJac; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _tpl = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _tpl;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmp4 = mmc_unbox_integer(tmpMeta3);
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      tmp6 = mmc_unbox_integer(tmpMeta5);
      tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
      _i1 = tmp4  /* pattern as ty=Integer */;
      _i2 = tmp6  /* pattern as ty=Integer */;
      _simEqSys = tmpMeta7;

      tmpMeta8 = stringAppend(_res,_OMC_LIT359);
      tmpMeta9 = stringAppend(tmpMeta8,intString(_i1));
      tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT243);
      tmpMeta11 = stringAppend(tmpMeta10,intString(_i2));
      tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT367);
      fputs(MMC_STRINGDATA(tmpMeta12),stdout);

      omc_SimCodeUtil_dumpSimEqSystem(threadData, _simEqSys);
    }
  }

  fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
void omc_SimCodeUtil_dumpSimEqSystem(threadData_t *threadData, modelica_metatype _eqSysIn)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* matchcontinue expression */
    volatile modelica_metatype tmp3_1;
    tmp3_1 = _eqSysIn;
    {
      modelica_integer _idx2;
      modelica_integer _idxLS2;
      modelica_integer _idxNLS2;
      modelica_metatype _crefs2 = NULL;
      modelica_metatype _eqs2 = NULL;
      modelica_metatype _residual2 = NULL;
      modelica_metatype _simJac = NULL;
      modelica_metatype _simJac2 = NULL;
      modelica_metatype _jac = NULL;
      modelica_metatype _jac2 = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _idx2 has no default value.
      // _idxLS2 has no default value.
      // _idxNLS2 has no default value.
      // _crefs2 has no default value.
      // _eqs2 has no default value.
      // _residual2 has no default value.
      // _simJac has no default value.
      // _simJac2 has no default value.
      // _jac has no default value.
      // _jac2 has no default value.
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 5; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp3_1,12,3) == 0) goto tmp2_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 2));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 7));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 9));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 3));
          if (!optionNone(tmpMeta8)) goto tmp2_end;
          
          _simJac = tmpMeta6;
          _jac = tmpMeta7;
          tmp3 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          fputs(MMC_STRINGDATA(omc_SimCodeUtil_simEqSystemString(threadData, _eqSysIn)),stdout);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac);

          fputs(MMC_STRINGDATA(_OMC_LIT368),stdout);

          omc_SimCodeUtil_dumpSimJac(threadData, _simJac);
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_integer tmp20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp3_1,12,3) == 0) goto tmp2_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 7));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 9));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 3));
          if (optionNone(tmpMeta12)) goto tmp2_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 7));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 8));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 9));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 11));
          tmp20 = mmc_unbox_integer(tmpMeta19);
          
          _simJac = tmpMeta10;
          _jac = tmpMeta11;
          _idx2 = tmp15  /* pattern as ty=Integer */;
          _simJac2 = tmpMeta16;
          _residual2 = tmpMeta17;
          _jac2 = tmpMeta18;
          _idxLS2 = tmp20  /* pattern as ty=Integer */;
          tmp3 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          fputs(MMC_STRINGDATA(omc_SimCodeUtil_simEqSystemString(threadData, _eqSysIn)),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT369),stdout);

          omc_SimCodeUtil_dumpSimJac(threadData, _simJac);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac);

          tmpMeta21 = stringAppend(_OMC_LIT370,intString(_idx2));
          tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT371);
          tmpMeta23 = stringAppend(tmpMeta22,_OMC_LIT372);
          tmpMeta24 = stringAppend(tmpMeta23,intString(_idxLS2));
          tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT373);
          tmpMeta26 = stringAppend(tmpMeta25,(isSome(_jac)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta27 = stringAppend(tmpMeta26,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta27),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT374),stdout);

          omc_SimCodeUtil_dumpSimEqSystemLst(threadData, _residual2, _OMC_LIT356);

          fputs(MMC_STRINGDATA(_OMC_LIT369),stdout);

          omc_SimCodeUtil_dumpSimJac(threadData, _simJac2);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac2);
          goto tmp2_done;
        }
        case 2: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          if (mmc__uniontype__metarecord__typedef__equal(tmp3_1,13,3) == 0) goto tmp2_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 7));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 3));
          if (!optionNone(tmpMeta30)) goto tmp2_end;
          
          _jac = tmpMeta29;
          tmp3 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          fputs(MMC_STRINGDATA(omc_SimCodeUtil_simEqSystemString(threadData, _eqSysIn)),stdout);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac);
          goto tmp2_done;
        }
        case 3: {
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_integer tmp36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_integer tmp40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          if (mmc__uniontype__metarecord__typedef__equal(tmp3_1,13,3) == 0) goto tmp2_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 2));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 7));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 3));
          if (optionNone(tmpMeta33)) goto tmp2_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 1));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 2));
          tmp36 = mmc_unbox_integer(tmpMeta35);
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 3));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 4));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 5));
          tmp40 = mmc_unbox_integer(tmpMeta39);
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 7));
          
          _jac = tmpMeta32;
          _idx2 = tmp36  /* pattern as ty=Integer */;
          _eqs2 = tmpMeta37;
          _crefs2 = tmpMeta38;
          _idxNLS2 = tmp40  /* pattern as ty=Integer */;
          _jac2 = tmpMeta41;
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(omc_SimCodeUtil_simEqSystemString(threadData, _eqSysIn)),stdout);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac);

          tmpMeta42 = stringAppend(_OMC_LIT370,intString(_idx2));
          tmpMeta43 = stringAppend(tmpMeta42,_OMC_LIT371);
          tmpMeta44 = stringAppend(tmpMeta43,_OMC_LIT375);
          tmpMeta45 = stringAppend(tmpMeta44,intString(_idxNLS2));
          tmpMeta46 = stringAppend(tmpMeta45,_OMC_LIT373);
          tmpMeta47 = stringAppend(tmpMeta46,(isSome(_jac2)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta48 = stringAppend(tmpMeta47,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta48),stdout);

          tmpMeta49 = stringAppend(_OMC_LIT376,stringDelimitList(omc_List_map(threadData, _crefs2, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT377));
          tmpMeta50 = stringAppend(tmpMeta49,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta50),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT374),stdout);

          omc_SimCodeUtil_dumpSimEqSystemLst(threadData, _eqs2, _OMC_LIT356);

          fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

          omc_SimCodeUtil_dumpJacobianMatrix(threadData, _jac2);
          goto tmp2_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(omc_SimCodeUtil_simEqSystemString(threadData, _eqSysIn)),stdout);
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 5) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_string omc_SimCodeUtil_simEqSystemString(threadData_t *threadData, modelica_metatype _eqSysIn)
{
  modelica_string _str = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _eqSysIn;
    {
      modelica_boolean _partMixed;
      modelica_boolean _lin;
      modelica_boolean _torn;
      modelica_integer _idx;
      modelica_integer _idxLS;
      modelica_integer _idxNLS;
      modelica_integer _idx2;
      modelica_integer _idxMS;
      modelica_string _s = NULL;
      modelica_metatype _sLst = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _lhs = NULL;
      modelica_metatype _iterator = NULL;
      modelica_metatype _startIt = NULL;
      modelica_metatype _endIt = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _cont = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _stmts = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _residual = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _beqs = NULL;
      modelica_metatype _jac = NULL;
      modelica_metatype _elseWhen = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _cons = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _partMixed has no default value.
      // _lin has no default value.
      // _torn has no default value.
      // _idx has no default value.
      // _idxLS has no default value.
      // _idxNLS has no default value.
      // _idx2 has no default value.
      // _idxMS has no default value.
      // _s has no default value.
      // _sLst has no default value.
      // _exp has no default value.
      // _lhs has no default value.
      // _iterator has no default value.
      // _startIt has no default value.
      // _endIt has no default value.
      // _cref has no default value.
      // _cont has no default value.
      // _crefs has no default value.
      // _stmts has no default value.
      // _eqs has no default value.
      // _residual has no default value.
      // _vars has no default value.
      // _beqs has no default value.
      // _jac has no default value.
      // _elseWhen has no default value.
      // _whenStmtLst has no default value.
      // _cons has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 23; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _idx = tmp7  /* pattern as ty=Integer */;
          _exp = tmpMeta8;
          tmp4 += 21; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta9 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta10 = stringAppend(tmpMeta9,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT378);
          tmp1 = tmpMeta11;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _idx = tmp13  /* pattern as ty=Integer */;
          _exp = tmpMeta14;
          tmp4 += 20; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta15 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta16 = stringAppend(tmpMeta15,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT379);
          tmp1 = tmpMeta17;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _idx = tmp19  /* pattern as ty=Integer */;
          _exp = tmpMeta20;
          tmp4 += 19; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta21 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta22 = stringAppend(tmpMeta21,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta23 = stringAppend(tmpMeta22,_OMC_LIT380);
          tmp1 = tmpMeta23;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _idx = tmp25  /* pattern as ty=Integer */;
          _cref = tmpMeta26;
          _exp = tmpMeta27;
          tmp4 += 18; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta28 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta29 = stringAppend(tmpMeta28,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref));
          tmpMeta30 = stringAppend(tmpMeta29,_OMC_LIT381);
          tmpMeta31 = stringAppend(tmpMeta30,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta32 = stringAppend(tmpMeta31,_OMC_LIT365);
          tmpMeta33 = stringAppend(tmpMeta32,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, _exp)));
          tmpMeta34 = stringAppend(tmpMeta33,_OMC_LIT360);
          tmp1 = tmpMeta34;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta35;
          modelica_integer tmp36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp36 = mmc_unbox_integer(tmpMeta35);
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _idx = tmp36  /* pattern as ty=Integer */;
          _cref = tmpMeta37;
          _exp = tmpMeta38;
          _cons = tmpMeta39;
          tmp4 += 17; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta40 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta41 = stringAppend(tmpMeta40,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref));
          tmpMeta42 = stringAppend(tmpMeta41,_OMC_LIT381);
          tmpMeta43 = stringAppend(tmpMeta42,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta44 = stringAppend(tmpMeta43,_OMC_LIT382);
          tmpMeta45 = stringAppend(tmpMeta44,omc_ExpressionDump_constraintDTlistToString(threadData, _cons, _OMC_LIT31));
          tmpMeta46 = stringAppend(tmpMeta45,_OMC_LIT360);
          tmpMeta47 = stringAppend(tmpMeta46,_OMC_LIT365);
          tmpMeta48 = stringAppend(tmpMeta47,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, _exp)));
          tmpMeta49 = stringAppend(tmpMeta48,_OMC_LIT360);
          tmp1 = tmpMeta49;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta50;
          modelica_integer tmp51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp51 = mmc_unbox_integer(tmpMeta50);
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _idx = tmp51  /* pattern as ty=Integer */;
          _lhs = tmpMeta52;
          _exp = tmpMeta53;
          tmp4 += 16; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta54 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta55 = stringAppend(tmpMeta54,omc_ExpressionBasics_printExpStr(threadData, _lhs));
          tmpMeta56 = stringAppend(tmpMeta55,_OMC_LIT381);
          tmpMeta57 = stringAppend(tmpMeta56,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta58 = stringAppend(tmpMeta57,_OMC_LIT365);
          tmpMeta59 = stringAppend(tmpMeta58,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, _exp)));
          tmpMeta60 = stringAppend(tmpMeta59,_OMC_LIT360);
          tmp1 = tmpMeta60;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta61;
          modelica_integer tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,5) == 0) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp62 = mmc_unbox_integer(tmpMeta61);
          
          _idx = tmp62  /* pattern as ty=Integer */;
          tmp4 += 15; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta63 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta64 = stringAppend(tmpMeta63,_OMC_LIT383);
          tmp1 = tmpMeta64;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta65;
          modelica_integer tmp66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp66 = mmc_unbox_integer(tmpMeta65);
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _idx = tmp66  /* pattern as ty=Integer */;
          _stmts = tmpMeta67;
          tmp4 += 14; /* Pattern matching succeeded; we may skip some cases if we fail */
          _sLst = omc_List_map(threadData, _stmts, boxvar_DAEDump_ppStatementStr);
          tmpMeta68 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta69 = stringAppend(tmpMeta68,omc_List_foldr(threadData, _sLst, boxvar_stringAppend, _OMC_LIT31));
          tmp1 = tmpMeta69;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta70;
          modelica_integer tmp71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp71 = mmc_unbox_integer(tmpMeta70);
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _idx = tmp71  /* pattern as ty=Integer */;
          _stmts = tmpMeta72;
          tmp4 += 13; /* Pattern matching succeeded; we may skip some cases if we fail */
          _sLst = omc_List_map(threadData, _stmts, boxvar_DAEDump_ppStatementStr);
          tmpMeta73 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta74 = stringAppend(tmpMeta73,omc_List_foldr(threadData, _sLst, boxvar_stringAppend, _OMC_LIT31));
          tmp1 = tmpMeta74;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_integer tmp77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_integer tmp83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 2));
          tmp77 = mmc_unbox_integer(tmpMeta76);
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 5));
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 6));
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 8));
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 9));
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 11));
          tmp83 = mmc_unbox_integer(tmpMeta82);
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (!optionNone(tmpMeta84)) goto tmp3_end;
          
          _idx = tmp77  /* pattern as ty=Integer */;
          _vars = tmpMeta78;
          _beqs = tmpMeta79;
          _residual = tmpMeta80;
          _jac = tmpMeta81;
          _idxLS = tmp83  /* pattern as ty=Integer */;
          tmp4 += 12; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta85 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta86 = stringAppend(tmpMeta85,_OMC_LIT372);
          tmpMeta87 = stringAppend(tmpMeta86,intString(_idxLS));
          tmpMeta88 = stringAppend(tmpMeta87,_OMC_LIT373);
          tmpMeta89 = stringAppend(tmpMeta88,(isSome(_jac)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta90 = stringAppend(tmpMeta89,_OMC_LIT48);
          _s = tmpMeta90;

          tmpMeta91 = stringAppend(_s,_OMC_LIT384);
          tmpMeta92 = stringAppend(tmpMeta91,stringDelimitList(omc_List_map(threadData, _vars, boxvar_SimCodeUtil_simVarString), _OMC_LIT48));
          _s = tmpMeta92;

          tmpMeta93 = stringAppend(_s,_OMC_LIT385);
          tmpMeta94 = stringAppend(tmpMeta93,stringDelimitList(omc_List_map(threadData, _beqs, boxvar_ExpressionBasics_printExpStr), _OMC_LIT48));
          _s = tmpMeta94;

          tmpMeta95 = stringAppend(_s,_OMC_LIT374);
          _s = tmpMeta95;

          tmpMeta96 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _residual, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          _s = tmpMeta96;
          tmpMeta97 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta97;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_integer tmp100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_integer tmp106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_metatype tmpMeta117;
          modelica_metatype tmpMeta118;
          modelica_metatype tmpMeta119;
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 2));
          tmp100 = mmc_unbox_integer(tmpMeta99);
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 5));
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 6));
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 8));
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 9));
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 11));
          tmp106 = mmc_unbox_integer(tmpMeta105);
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (optionNone(tmpMeta107)) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta107), 1));
          
          _idx = tmp100  /* pattern as ty=Integer */;
          _vars = tmpMeta101;
          _beqs = tmpMeta102;
          _residual = tmpMeta103;
          _jac = tmpMeta104;
          _idxLS = tmp106  /* pattern as ty=Integer */;
          tmp4 += 11; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta109 = stringAppend(_OMC_LIT386,intString(_idx));
          tmpMeta110 = stringAppend(tmpMeta109,_OMC_LIT371);
          tmpMeta111 = stringAppend(tmpMeta110,_OMC_LIT372);
          tmpMeta112 = stringAppend(tmpMeta111,intString(_idxLS));
          tmpMeta113 = stringAppend(tmpMeta112,_OMC_LIT373);
          tmpMeta114 = stringAppend(tmpMeta113,(isSome(_jac)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta115 = stringAppend(tmpMeta114,_OMC_LIT48);
          _s = tmpMeta115;

          tmpMeta116 = stringAppend(_s,_OMC_LIT387);
          tmpMeta117 = stringAppend(tmpMeta116,stringDelimitList(omc_List_map(threadData, _vars, boxvar_SimCodeUtil_simVarString), _OMC_LIT388));
          _s = tmpMeta117;

          tmpMeta118 = stringAppend(_s,_OMC_LIT385);
          tmpMeta119 = stringAppend(tmpMeta118,stringDelimitList(omc_List_map(threadData, _beqs, boxvar_ExpressionBasics_printExpStr), _OMC_LIT388));
          _s = tmpMeta119;

          tmpMeta120 = stringAppend(_s,_OMC_LIT374);
          _s = tmpMeta120;

          tmpMeta121 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _residual, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          _s = tmpMeta121;
          tmpMeta122 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta122;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          modelica_integer tmp125;
          modelica_metatype tmpMeta126;
          modelica_metatype tmpMeta127;
          modelica_metatype tmpMeta128;
          modelica_integer tmp129;
          modelica_metatype tmpMeta130;
          modelica_metatype tmpMeta131;
          modelica_metatype tmpMeta132;
          modelica_metatype tmpMeta133;
          modelica_metatype tmpMeta134;
          modelica_metatype tmpMeta135;
          modelica_metatype tmpMeta136;
          modelica_metatype tmpMeta137;
          modelica_metatype tmpMeta138;
          modelica_metatype tmpMeta139;
          modelica_metatype tmpMeta140;
          modelica_metatype tmpMeta141;
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta123 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta124 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 2));
          tmp125 = mmc_unbox_integer(tmpMeta124);
          tmpMeta126 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 3));
          tmpMeta127 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 4));
          tmpMeta128 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 5));
          tmp129 = mmc_unbox_integer(tmpMeta128);
          tmpMeta130 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 7));
          tmpMeta131 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (!optionNone(tmpMeta131)) goto tmp3_end;
          
          _idx = tmp125  /* pattern as ty=Integer */;
          _eqs = tmpMeta126;
          _crefs = tmpMeta127;
          _idxNLS = tmp129  /* pattern as ty=Integer */;
          _jac = tmpMeta130;
          tmp4 += 10; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta132 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta133 = stringAppend(tmpMeta132,_OMC_LIT375);
          tmpMeta134 = stringAppend(tmpMeta133,intString(_idxNLS));
          tmpMeta135 = stringAppend(tmpMeta134,_OMC_LIT373);
          tmpMeta136 = stringAppend(tmpMeta135,(isSome(_jac)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta137 = stringAppend(tmpMeta136,_OMC_LIT48);
          _s = tmpMeta137;

          tmpMeta138 = stringAppend(_s,_OMC_LIT389);
          tmpMeta139 = stringAppend(tmpMeta138,stringDelimitList(omc_List_map(threadData, _crefs, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT377));
          tmpMeta140 = stringAppend(tmpMeta139,_OMC_LIT48);
          _s = tmpMeta140;

          tmpMeta141 = stringAppend(_s,_OMC_LIT374);
          _s = tmpMeta141;

          tmpMeta142 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _eqs, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          _s = tmpMeta142;
          tmpMeta143 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta143;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta144;
          modelica_metatype tmpMeta145;
          modelica_integer tmp146;
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          modelica_metatype tmpMeta149;
          modelica_integer tmp150;
          modelica_metatype tmpMeta151;
          modelica_metatype tmpMeta152;
          modelica_metatype tmpMeta153;
          modelica_metatype tmpMeta154;
          modelica_metatype tmpMeta155;
          modelica_metatype tmpMeta156;
          modelica_metatype tmpMeta157;
          modelica_metatype tmpMeta158;
          modelica_metatype tmpMeta159;
          modelica_metatype tmpMeta160;
          modelica_metatype tmpMeta161;
          modelica_metatype tmpMeta162;
          modelica_metatype tmpMeta163;
          modelica_metatype tmpMeta164;
          modelica_metatype tmpMeta165;
          modelica_metatype tmpMeta166;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta144 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta145 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 2));
          tmp146 = mmc_unbox_integer(tmpMeta145);
          tmpMeta147 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 3));
          tmpMeta148 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 4));
          tmpMeta149 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 5));
          tmp150 = mmc_unbox_integer(tmpMeta149);
          tmpMeta151 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 7));
          tmpMeta152 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (optionNone(tmpMeta152)) goto tmp3_end;
          tmpMeta153 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta152), 1));
          
          _idx = tmp146  /* pattern as ty=Integer */;
          _eqs = tmpMeta147;
          _crefs = tmpMeta148;
          _idxNLS = tmp150  /* pattern as ty=Integer */;
          _jac = tmpMeta151;
          tmp4 += 9; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta154 = stringAppend(_OMC_LIT386,intString(_idx));
          tmpMeta155 = stringAppend(tmpMeta154,_OMC_LIT371);
          tmpMeta156 = stringAppend(tmpMeta155,_OMC_LIT375);
          tmpMeta157 = stringAppend(tmpMeta156,intString(_idxNLS));
          tmpMeta158 = stringAppend(tmpMeta157,_OMC_LIT373);
          tmpMeta159 = stringAppend(tmpMeta158,(isSome(_jac)?_OMC_LIT347:_OMC_LIT348));
          tmpMeta160 = stringAppend(tmpMeta159,_OMC_LIT48);
          _s = tmpMeta160;

          tmpMeta161 = stringAppend(_s,_OMC_LIT389);
          tmpMeta162 = stringAppend(tmpMeta161,stringDelimitList(omc_List_map(threadData, _crefs, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT377));
          tmpMeta163 = stringAppend(tmpMeta162,_OMC_LIT48);
          _s = tmpMeta163;

          tmpMeta164 = stringAppend(_s,_OMC_LIT374);
          _s = tmpMeta164;

          tmpMeta165 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _eqs, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          _s = tmpMeta165;
          tmpMeta166 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta166;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta167;
          modelica_integer tmp168;
          modelica_metatype tmpMeta169;
          modelica_metatype tmpMeta170;
          modelica_metatype tmpMeta171;
          modelica_integer tmp172;
          modelica_metatype tmpMeta173;
          modelica_metatype tmpMeta174;
          modelica_metatype tmpMeta175;
          modelica_metatype tmpMeta176;
          modelica_metatype tmpMeta177;
          modelica_metatype tmpMeta178;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta167 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp168 = mmc_unbox_integer(tmpMeta167);
          tmpMeta169 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta170 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta171 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp172 = mmc_unbox_integer(tmpMeta171);
          
          _idx = tmp168  /* pattern as ty=Integer */;
          _cont = tmpMeta169;
          _eqs = tmpMeta170;
          _idxMS = tmp172  /* pattern as ty=Integer */;
          tmp4 += 8; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta173 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta174 = stringAppend(tmpMeta173,_OMC_LIT390);
          tmpMeta175 = stringAppend(tmpMeta174,intString(_idxMS));
          tmpMeta176 = stringAppend(tmpMeta175,_OMC_LIT48);
          _s = tmpMeta176;

          tmpMeta177 = stringAppend(_s,omc_SimCodeUtil_simEqSystemString(threadData, _cont));
          _s = tmpMeta177;
          tmpMeta178 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _eqs, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          tmp1 = tmpMeta178;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta179;
          modelica_integer tmp180;
          modelica_metatype tmpMeta181;
          modelica_metatype tmpMeta182;
          modelica_metatype tmpMeta183;
          modelica_metatype tmpMeta184;
          modelica_metatype tmpMeta185;
          modelica_metatype tmpMeta186;
          modelica_metatype tmpMeta187;
          modelica_metatype tmpMeta188;
          modelica_metatype tmpMeta189;
          modelica_metatype tmpMeta190;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,15,7) == 0) goto tmp3_end;
          tmpMeta179 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp180 = mmc_unbox_integer(tmpMeta179);
          tmpMeta181 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta182 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta183 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _idx = tmp180  /* pattern as ty=Integer */;
          _crefs = tmpMeta181;
          _whenStmtLst = tmpMeta182;
          _elseWhen = tmpMeta183;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta184 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta185 = stringAppend(tmpMeta184,_OMC_LIT391);
          _s = tmpMeta185;

          tmpMeta186 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _crefs, boxvar_ComponentReference_crefStr), _OMC_LIT243));
          tmpMeta187 = stringAppend(tmpMeta186,_OMC_LIT392);
          _s = tmpMeta187;

          tmpMeta188 = stringAppend(_s,omc_SimCodeUtil_dumpWhenOps(threadData, _whenStmtLst));
          _s = tmpMeta188;

          if(isSome(_elseWhen))
          {
            tmpMeta189 = stringAppend(_s,_OMC_LIT393);
            _s = tmpMeta189;

            tmpMeta190 = stringAppend(_s,omc_SimCodeUtil_simEqSystemString(threadData, omc_Util_getOption(threadData, _elseWhen)));
            _s = tmpMeta190;
          }
          tmp1 = _s;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta191;
          modelica_integer tmp192;
          modelica_metatype tmpMeta193;
          modelica_metatype tmpMeta194;
          modelica_metatype tmpMeta195;
          modelica_metatype tmpMeta196;
          modelica_metatype tmpMeta197;
          modelica_metatype tmpMeta198;
          modelica_metatype tmpMeta199;
          modelica_metatype tmpMeta200;
          modelica_metatype tmpMeta201;
          modelica_metatype tmpMeta202;
          modelica_metatype tmpMeta203;
          modelica_metatype tmpMeta204;
          modelica_metatype tmpMeta205;
          modelica_metatype tmpMeta206;
          modelica_metatype tmpMeta207;
          modelica_metatype tmpMeta208;
          modelica_metatype tmpMeta209;
          modelica_metatype tmpMeta210;
          modelica_metatype tmpMeta211;
          modelica_metatype tmpMeta212;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,8) == 0) goto tmp3_end;
          tmpMeta191 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp192 = mmc_unbox_integer(tmpMeta191);
          tmpMeta193 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta194 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta195 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta196 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta197 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          
          _idx = tmp192  /* pattern as ty=Integer */;
          _iterator = tmpMeta193;
          _startIt = tmpMeta194;
          _endIt = tmpMeta195;
          _cref = tmpMeta196;
          _exp = tmpMeta197;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta198 = stringAppend(intString(_idx),_OMC_LIT394);
          tmpMeta199 = stringAppend(tmpMeta198,_OMC_LIT395);
          tmpMeta200 = stringAppend(tmpMeta199,omc_ExpressionBasics_printExpStr(threadData, _iterator));
          tmpMeta201 = stringAppend(tmpMeta200,_OMC_LIT396);
          tmpMeta202 = stringAppend(tmpMeta201,omc_ExpressionBasics_printExpStr(threadData, _startIt));
          tmpMeta203 = stringAppend(tmpMeta202,_OMC_LIT154);
          tmpMeta204 = stringAppend(tmpMeta203,omc_ExpressionBasics_printExpStr(threadData, _endIt));
          tmpMeta205 = stringAppend(tmpMeta204,_OMC_LIT397);
          _s = tmpMeta205;

          tmpMeta206 = stringAppend(_s,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref));
          tmpMeta207 = stringAppend(tmpMeta206,_OMC_LIT381);
          tmpMeta208 = stringAppend(tmpMeta207,omc_ExpressionBasics_printExpStr(threadData, _exp));
          tmpMeta209 = stringAppend(tmpMeta208,_OMC_LIT359);
          tmpMeta210 = stringAppend(tmpMeta209,omc_DAEDump_daeTypeStr(threadData, omc_Expression_typeof(threadData, _exp)));
          tmpMeta211 = stringAppend(tmpMeta210,_OMC_LIT398);
          _s = tmpMeta211;
          tmpMeta212 = stringAppend(_s,_OMC_LIT399);
          tmp1 = tmpMeta212;
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta213;
          modelica_integer tmp214;
          modelica_metatype tmpMeta215;
          modelica_metatype tmpMeta216;
          modelica_metatype tmpMeta217;
          modelica_metatype tmpMeta218;
          modelica_metatype tmpMeta219;
          modelica_metatype tmpMeta220;
          modelica_metatype tmpMeta221;
          modelica_metatype tmpMeta222;
          modelica_metatype tmpMeta223;
          modelica_metatype tmpMeta224;
          modelica_metatype tmpMeta225;
          modelica_metatype tmpMeta226;
          modelica_metatype tmpMeta227;
          modelica_metatype tmpMeta228;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,7) == 0) goto tmp3_end;
          tmpMeta213 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp214 = mmc_unbox_integer(tmpMeta213);
          tmpMeta215 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta216 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta217 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta218 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _idx = tmp214  /* pattern as ty=Integer */;
          _iterator = tmpMeta215;
          _startIt = tmpMeta216;
          _endIt = tmpMeta217;
          _eqs = tmpMeta218;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta219 = stringAppend(intString(_idx),_OMC_LIT400);
          tmpMeta220 = stringAppend(tmpMeta219,_OMC_LIT395);
          tmpMeta221 = stringAppend(tmpMeta220,omc_ExpressionBasics_printExpStr(threadData, _iterator));
          tmpMeta222 = stringAppend(tmpMeta221,_OMC_LIT396);
          tmpMeta223 = stringAppend(tmpMeta222,omc_ExpressionBasics_printExpStr(threadData, _startIt));
          tmpMeta224 = stringAppend(tmpMeta223,_OMC_LIT154);
          tmpMeta225 = stringAppend(tmpMeta224,omc_ExpressionBasics_printExpStr(threadData, _endIt));
          tmpMeta226 = stringAppend(tmpMeta225,_OMC_LIT397);
          _s = tmpMeta226;

          tmpMeta227 = stringAppend(_s,stringDelimitList(omc_List_map(threadData, _eqs, boxvar_SimCodeUtil_simEqSystemString), _OMC_LIT356));
          _s = tmpMeta227;
          tmpMeta228 = stringAppend(_s,_OMC_LIT399);
          tmp1 = tmpMeta228;
          goto tmp3_done;
        }
        case 17: {
          modelica_string tmp229;
          modelica_metatype tmpMeta230;
          modelica_string tmp231;
          modelica_metatype tmpMeta232;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,2) == 0) goto tmp3_end;
          
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp229 = modelica_integer_to_modelica_string(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 2)))), ((modelica_integer) 0), 1 /* true */);
          tmpMeta230 = stringAppend(tmp229,_OMC_LIT401);
          tmp231 = modelica_integer_to_modelica_string(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 3)))), ((modelica_integer) 0), 1 /* true */);
          tmpMeta232 = stringAppend(tmpMeta230,tmp231);
          tmp1 = tmpMeta232;
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta233;
          modelica_integer tmp234;
          modelica_metatype tmpMeta235;
          modelica_integer tmp236;
          modelica_metatype tmpMeta237;
          modelica_integer tmp238;
          modelica_metatype tmpMeta239;
          modelica_integer tmp240;
          modelica_metatype tmpMeta241;
          modelica_integer tmp242;
          modelica_metatype tmpMeta243;
          modelica_metatype tmpMeta244;
          modelica_metatype tmpMeta245;
          modelica_metatype tmpMeta246;
          modelica_metatype tmpMeta247;
          modelica_metatype tmpMeta248;
          modelica_metatype tmpMeta249;
          modelica_metatype tmpMeta250;
          modelica_metatype tmpMeta251;
          modelica_metatype tmpMeta252;
          modelica_metatype tmpMeta253;
          modelica_metatype tmpMeta254;
          modelica_metatype tmpMeta261;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,11) == 0) goto tmp3_end;
          tmpMeta233 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp234 = mmc_unbox_integer(tmpMeta233);
          tmpMeta235 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp236 = mmc_unbox_integer(tmpMeta235);
          tmpMeta237 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp238 = mmc_unbox_integer(tmpMeta237);
          tmpMeta239 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp240 = mmc_unbox_integer(tmpMeta239);
          tmpMeta241 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp242 = mmc_unbox_integer(tmpMeta241);
          
          _idx = tmp234  /* pattern as ty=Integer */;
          _idx2 = tmp236  /* pattern as ty=Integer */;
          _partMixed = tmp238  /* pattern as ty=Boolean */;
          _torn = tmp240  /* pattern as ty=Boolean */;
          _lin = tmp242  /* pattern as ty=Boolean */;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta243 = stringAppend(intString(_idx),_OMC_LIT371);
          tmpMeta244 = stringAppend(tmpMeta243,_OMC_LIT402);
          tmpMeta245 = stringAppend(tmpMeta244,intString(_idx2));
          tmpMeta246 = stringAppend(tmpMeta245,_OMC_LIT48);
          _s = tmpMeta246;

          tmpMeta247 = stringAppend(_s,_OMC_LIT403);
          tmpMeta248 = stringAppend(tmpMeta247,(_partMixed?_OMC_LIT347:_OMC_LIT348));
          tmpMeta249 = stringAppend(tmpMeta248,_OMC_LIT404);
          tmpMeta250 = stringAppend(tmpMeta249,(_torn?_OMC_LIT347:_OMC_LIT348));
          tmpMeta251 = stringAppend(tmpMeta250,_OMC_LIT405);
          tmpMeta252 = stringAppend(tmpMeta251,(_lin?_OMC_LIT347:_OMC_LIT348));
          tmpMeta253 = stringAppend(tmpMeta252,_OMC_LIT48);
          _s = tmpMeta253;

          tmpMeta254 = stringAppend(_s,omc_SimCodeUtil_omsiFuncEqnString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 8)))));
          _s = tmpMeta254;

          { /* match expression */
            modelica_metatype tmp257_1;
            tmp257_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 9)));
            {
              modelica_metatype _matrix = NULL;
              volatile mmc_switch_type tmp257;
              int tmp258;
              // _matrix has no default value.
              tmp257 = 0;
              for (; tmp257 < 1; tmp257++) {
                switch (MMC_SWITCH_CAST(tmp257)) {
                case 0: {
                  modelica_metatype tmpMeta259;
                  modelica_metatype tmpMeta260;
                  if (optionNone(tmp257_1)) goto tmp256_end;
                  tmpMeta259 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp257_1), 1));
                  
                  _matrix = tmpMeta259;
                  /* Pattern matching succeeded */
                  tmpMeta260 = stringAppend(_s,omc_SimCodeUtil_derivativeMatrixString(threadData, _matrix));
                  _s = tmpMeta260;
                  goto tmp256_done;
                }
                }
                goto tmp256_end;
                tmp256_end: ;
              }
              goto goto_255;
              goto_255:;
              goto goto_2;
              goto tmp256_done;
              tmp256_done:;
            }
          }
          ;
          tmpMeta261 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta261;
          goto tmp3_done;
        }
        case 19: {
          modelica_metatype tmpMeta262;
          modelica_metatype tmpMeta263;
          modelica_metatype tmpMeta264;
          modelica_metatype tmpMeta265;
          modelica_metatype tmpMeta266;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta262 = stringAppend(intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 2))))),_OMC_LIT371);
          tmpMeta263 = stringAppend(tmpMeta262,_OMC_LIT406);
          tmpMeta264 = stringAppend(tmpMeta263,_OMC_LIT407);
          tmpMeta265 = stringAppend(tmpMeta264,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 3))))));
          tmpMeta266 = stringAppend(tmpMeta265,_OMC_LIT48);
          tmp1 = tmpMeta266;
          goto tmp3_done;
        }
        case 20: {
          modelica_metatype tmpMeta267;
          modelica_metatype tmpMeta268;
          modelica_metatype tmpMeta269;
          modelica_metatype tmpMeta270;
          modelica_metatype tmpMeta271;
          modelica_metatype tmpMeta272;
          modelica_metatype tmpMeta273;
          modelica_metatype tmpMeta274;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta267 = stringAppend(intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 2))))),_OMC_LIT371);
          tmpMeta268 = stringAppend(tmpMeta267,_OMC_LIT408);
          tmpMeta269 = stringAppend(tmpMeta268,_OMC_LIT407);
          tmpMeta270 = stringAppend(tmpMeta269,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 3))))));
          tmpMeta271 = stringAppend(tmpMeta270,_OMC_LIT48);
          _s = tmpMeta271;
          tmpMeta272 = stringAppend(_s,_OMC_LIT409);
          tmpMeta273 = stringAppend(tmpMeta272,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 4))), boxvar_intString, _OMC_LIT31, _OMC_LIT410, _OMC_LIT243, _OMC_LIT411, 1 /* true */, ((modelica_integer) 10)));
          tmpMeta274 = stringAppend(tmpMeta273,_OMC_LIT48);
          tmp1 = tmpMeta274;
          goto tmp3_done;
        }
        case 21: {
          modelica_metatype tmpMeta275;
          modelica_metatype tmpMeta276;
          modelica_metatype tmpMeta277;
          modelica_metatype tmpMeta278;
          modelica_metatype tmpMeta279;
          modelica_metatype tmpMeta280;
          modelica_metatype tmpMeta281;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta275 = stringAppend(intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 2))))),_OMC_LIT371);
          tmpMeta276 = stringAppend(tmpMeta275,_OMC_LIT412);
          _s = tmpMeta276;

          tmpMeta277 = stringAppend(_s,_OMC_LIT413);
          tmpMeta278 = stringAppend(tmpMeta277,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 3))), boxvar_intString, _OMC_LIT31, _OMC_LIT410, _OMC_LIT243, _OMC_LIT411, 1 /* true */, ((modelica_integer) 10)));
          tmpMeta279 = stringAppend(tmpMeta278,_OMC_LIT48);
          _s = tmpMeta279;

          tmpMeta280 = stringAppend(_s,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSysIn), 4))), boxvar_SimCodeUtil_simEqSystemString, _OMC_LIT31, _OMC_LIT374, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0)));
          _s = tmpMeta280;
          tmpMeta281 = stringAppend(_s,_OMC_LIT48);
          tmp1 = tmpMeta281;
          goto tmp3_done;
        }
        case 22: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT414;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 23) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _str = tmp1;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
void omc_SimCodeUtil_dumpSimEqSystemLst(threadData_t *threadData, modelica_metatype _eqSysLstIn, modelica_string _delimiter)
{
  modelica_metatype _sys = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _sys has no default value.
  {
    modelica_metatype _sys;
    for (tmpMeta1 = _eqSysLstIn; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _sys = MMC_CAR(tmpMeta1);
      omc_SimCodeUtil_dumpSimEqSystem(threadData, _sys);

      fputs(MMC_STRINGDATA(_delimiter),stdout);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpFunctions(threadData_t *threadData, modelica_metatype _functions)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _functions;
    {
      modelica_metatype _path = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _outVars = NULL;
      modelica_metatype _functionArguments = NULL;
      modelica_metatype _variableDeclarations = NULL;
      modelica_metatype _funArgs = NULL;
      modelica_metatype _locals = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _path has no default value.
      // _rest has no default value.
      // _outVars has no default value.
      // _functionArguments has no default value.
      // _variableDeclarations has no default value.
      // _funArgs has no default value.
      // _locals has no default value.
      tmp3 = 0;
      for (; tmp3 < 6; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          if (!listEmpty(tmp3_1)) goto tmp2_end;
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta5 = MMC_CAR(tmp3_1);
          tmpMeta6 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta5,0,7) == 0) goto tmp2_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 5));
          
          _path = tmpMeta7;
          _outVars = tmpMeta8;
          _functionArguments = tmpMeta9;
          _variableDeclarations = tmpMeta10;
          _rest = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta11 = stringAppend(_OMC_LIT415,omc_AbsynUtil_pathStringNoQual(threadData, _path, _OMC_LIT169, 0 /* false */, 0 /* false */));
          tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta12),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT416),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _outVars, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT417),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _functionArguments, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT418),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _variableDeclarations, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

          /* Tail recursive call */
          _functions = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta13 = MMC_CAR(tmp3_1);
          tmpMeta14 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,1,6) == 0) goto tmp2_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          
          _path = tmpMeta15;
          _rest = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta16 = stringAppend(_OMC_LIT419,omc_AbsynUtil_pathStringNoQual(threadData, _path, _OMC_LIT169, 0 /* false */, 0 /* false */));
          tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta17),stdout);

          /* Tail recursive call */
          _functions = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta18 = MMC_CAR(tmp3_1);
          tmpMeta19 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,2,6) == 0) goto tmp2_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          
          _path = tmpMeta20;
          _rest = tmpMeta19;
          /* Pattern matching succeeded */
          tmpMeta21 = stringAppend(_OMC_LIT420,omc_AbsynUtil_pathStringNoQual(threadData, _path, _OMC_LIT169, 0 /* false */, 0 /* false */));
          tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta22),stdout);

          /* Tail recursive call */
          _functions = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 4: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta23 = MMC_CAR(tmp3_1);
          tmpMeta24 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,3,14) == 0) goto tmp2_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 8));
          
          _path = tmpMeta25;
          _outVars = tmpMeta26;
          _rest = tmpMeta24;
          /* Pattern matching succeeded */
          tmpMeta27 = stringAppend(_OMC_LIT421,omc_AbsynUtil_pathStringNoQual(threadData, _path, _OMC_LIT169, 0 /* false */, 0 /* false */));
          tmpMeta28 = stringAppend(tmpMeta27,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta28),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT416),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _outVars, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

          /* Tail recursive call */
          _functions = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 5: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta29 = MMC_CAR(tmp3_1);
          tmpMeta30 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,4,5) == 0) goto tmp2_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 3));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 4));
          
          _path = tmpMeta31;
          _funArgs = tmpMeta32;
          _locals = tmpMeta33;
          _rest = tmpMeta30;
          /* Pattern matching succeeded */
          tmpMeta34 = stringAppend(_OMC_LIT422,omc_AbsynUtil_pathStringNoQual(threadData, _path, _OMC_LIT169, 0 /* false */, 0 /* false */));
          tmpMeta35 = stringAppend(tmpMeta34,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta35),stdout);

          fputs(MMC_STRINGDATA(_OMC_LIT423),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _funArgs, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT424),stdout);

          omc_SimCodeUtil_dumpVariablesString(threadData, _locals, _OMC_LIT377);

          fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

          /* Tail recursive call */
          _functions = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
void omc_SimCodeUtil_dumpModelInfo(threadData_t *threadData, modelica_metatype _modelInfo)
{
  modelica_integer _nsv;
  modelica_integer _nalgv;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _simVars = NULL;
  modelica_metatype _stateVars = NULL;
  modelica_metatype _derivativeVars = NULL;
  modelica_metatype _algVars = NULL;
  modelica_metatype _discreteAlgVars = NULL;
  modelica_metatype _intAlgVars = NULL;
  modelica_metatype _boolAlgVars = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype _intAliasVars = NULL;
  modelica_metatype _paramVars = NULL;
  modelica_metatype _boolParamVars = NULL;
  modelica_metatype _intParamVars = NULL;
  modelica_metatype _extObjVars = NULL;
  modelica_metatype _constVars = NULL;
  modelica_metatype _intConstVars = NULL;
  modelica_metatype _stringConstVars = NULL;
  modelica_metatype _functions = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_integer tmp23;
  modelica_metatype tmpMeta24;
  modelica_integer tmp25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_metatype tmpMeta29;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nsv has no default value.
  // _nalgv has no default value.
  // _varInfo has no default value.
  // _simVars has no default value.
  // _stateVars has no default value.
  // _derivativeVars has no default value.
  // _algVars has no default value.
  // _discreteAlgVars has no default value.
  // _intAlgVars has no default value.
  // _boolAlgVars has no default value.
  // _aliasVars has no default value.
  // _intAliasVars has no default value.
  // _paramVars has no default value.
  // _boolParamVars has no default value.
  // _intParamVars has no default value.
  // _extObjVars has no default value.
  // _constVars has no default value.
  // _intConstVars has no default value.
  // _stringConstVars has no default value.
  // _functions has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _modelInfo;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 10));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 11));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 12));
  _varInfo = tmpMeta2;
  _simVars = tmpMeta3;
  _functions = tmpMeta4;

  /* Pattern-matching assignment */
  tmpMeta5 = _simVars;
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 4));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 5));
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 6));
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 7));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 10));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 11));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 13));
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 14));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 15));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 19));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 20));
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 21));
  tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 23));
  _stateVars = tmpMeta6;
  _derivativeVars = tmpMeta7;
  _algVars = tmpMeta8;
  _discreteAlgVars = tmpMeta9;
  _intAlgVars = tmpMeta10;
  _boolAlgVars = tmpMeta11;
  _aliasVars = tmpMeta12;
  _intAliasVars = tmpMeta13;
  _paramVars = tmpMeta14;
  _intParamVars = tmpMeta15;
  _boolParamVars = tmpMeta16;
  _extObjVars = tmpMeta17;
  _constVars = tmpMeta18;
  _intConstVars = tmpMeta19;
  _stringConstVars = tmpMeta20;

  /* Pattern-matching assignment */
  tmpMeta21 = _varInfo;
  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 6));
  tmp23 = mmc_unbox_integer(tmpMeta22);
  tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 7));
  tmp25 = mmc_unbox_integer(tmpMeta24);
  _nsv = tmp23  /* pattern as ty=Integer */;
  _nalgv = tmp25  /* pattern as ty=Integer */;

  tmpMeta26 = stringAppend(_OMC_LIT425,intString(_nsv));
  tmpMeta27 = stringAppend(tmpMeta26,_OMC_LIT337);
  omc_SimCodeUtil_dumpVarLst(threadData, _stateVars, tmpMeta27);

  omc_SimCodeUtil_dumpVarLst(threadData, _derivativeVars, _OMC_LIT426);

  tmpMeta28 = stringAppend(_OMC_LIT427,intString(_nalgv));
  tmpMeta29 = stringAppend(tmpMeta28,_OMC_LIT337);
  omc_SimCodeUtil_dumpVarLst(threadData, _algVars, tmpMeta29);

  omc_SimCodeUtil_dumpVarLst(threadData, _discreteAlgVars, _OMC_LIT428);

  omc_SimCodeUtil_dumpVarLst(threadData, _intAlgVars, _OMC_LIT429);

  omc_SimCodeUtil_dumpVarLst(threadData, _boolAlgVars, _OMC_LIT430);

  omc_SimCodeUtil_dumpVarLst(threadData, _aliasVars, _OMC_LIT431);

  omc_SimCodeUtil_dumpVarLst(threadData, _intAliasVars, _OMC_LIT432);

  omc_SimCodeUtil_dumpVarLst(threadData, _paramVars, _OMC_LIT433);

  omc_SimCodeUtil_dumpVarLst(threadData, _intParamVars, _OMC_LIT434);

  omc_SimCodeUtil_dumpVarLst(threadData, _boolParamVars, _OMC_LIT435);

  omc_SimCodeUtil_dumpVarLst(threadData, _extObjVars, _OMC_LIT436);

  omc_SimCodeUtil_dumpVarLst(threadData, _constVars, _OMC_LIT437);

  omc_SimCodeUtil_dumpVarLst(threadData, _intConstVars, _OMC_LIT438);

  omc_SimCodeUtil_dumpVarLst(threadData, _stringConstVars, _OMC_LIT439);

  fputs(MMC_STRINGDATA(_OMC_LIT440),stdout);

  omc_SimCodeUtil_dumpFunctions(threadData, _functions);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpVariablesString(threadData_t *threadData, modelica_metatype _vars, modelica_string _delimiter)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _vars;
    {
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _kind = NULL;
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _s1 has no default value.
      // _s2 has no default value.
      // _cref has no default value.
      // _ty has no default value.
      // _kind has no default value.
      // _rest has no default value.
      tmp3 = 0;
      for (; tmp3 < 4; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          if (!listEmpty(tmp3_1)) goto tmp2_end;
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta5 = MMC_CAR(tmp3_1);
          tmpMeta6 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta5,0,7) == 0) goto tmp2_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 7));
          
          _cref = tmpMeta7;
          _ty = tmpMeta8;
          _kind = tmpMeta9;
          _rest = tmpMeta6;
          /* Pattern matching succeeded */
          _s1 = omc_DAEDump_printTypeStr(threadData, _ty, NULL);

          _s1 = omc_TypesDump_printTypeStr(threadData, _ty);

          _s2 = omc_DAEDump_dumpKindStr(threadData, _kind);

          tmpMeta10 = stringAppend(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref),_OMC_LIT441);
          tmpMeta11 = stringAppend(tmpMeta10,_s1);
          tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT243);
          tmpMeta13 = stringAppend(tmpMeta12,_s2);
          tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT442);
          tmpMeta15 = stringAppend(tmpMeta14,_delimiter);
          fputs(MMC_STRINGDATA(tmpMeta15),stdout);

          /* Tail recursive call */
          _vars = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 2: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (listEmpty(tmp3_1)) goto tmp2_end;
          tmpMeta16 = MMC_CAR(tmp3_1);
          tmpMeta17 = MMC_CDR(tmp3_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,1,4) == 0) goto tmp2_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          
          _s1 = tmpMeta18;
          _rest = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta19 = stringAppend(_OMC_LIT443,_s1);
          tmpMeta20 = stringAppend(tmpMeta19,_delimiter);
          fputs(MMC_STRINGDATA(tmpMeta20),stdout);

          /* Tail recursive call */
          _vars = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          ;
          goto tmp2_done;
        }
        case 3: {
          modelica_metatype tmpMeta21;
          
          /* Pattern matching succeeded */
          tmpMeta21 = stringAppend(_OMC_LIT444,_delimiter);
          fputs(MMC_STRINGDATA(tmpMeta21),stdout);
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_string omc_SimCodeUtil_printVarLstCrefs(threadData_t *threadData, modelica_metatype _inVars)
{
  modelica_string _str = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _cref has no default value.
  // _var has no default value.
  _str = _OMC_LIT376;

  {
    modelica_metatype _var;
    for (tmpMeta1 = _inVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _var;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _cref = tmpMeta3;

      tmpMeta4 = stringAppend(_str,omc_ComponentReference_debugPrintComponentRefTypeStr(threadData, _cref));
      tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT377);
      _str = tmpMeta5;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
void omc_SimCodeUtil_dumpVarLst(threadData_t *threadData, modelica_metatype _varLst, modelica_string _header)
{
  modelica_metatype _var = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _var has no default value.
  if((!listEmpty(_varLst)))
  {
    tmpMeta1 = stringAppend(_header,_OMC_LIT445);
    fputs(MMC_STRINGDATA(tmpMeta1),stdout);

    {
      modelica_metatype _var;
      for (tmpMeta2 = _varLst; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
      {
        _var = MMC_CAR(tmpMeta2);
        tmpMeta3 = stringAppend(omc_SimCodeUtil_simVarString(threadData, _var),_OMC_LIT48);
        fputs(MMC_STRINGDATA(tmpMeta3),stdout);
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_string omc_SimCodeUtil_simVarString(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_string _s = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_string tmp4 = 0;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_boolean tmp20;
  modelica_string tmp21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _s has no default value.
  tmpMeta1 = stringAppend(_OMC_LIT446,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 7))))));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT371);
  tmpMeta3 = stringAppend(tmpMeta2,omc_ComponentReferenceBasics_printComponentRefStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 2)))));
  _s = tmpMeta3;

  { /* match expression */
    modelica_metatype tmp7_1;
    tmp7_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 16)));
    {
      modelica_metatype _cr = NULL;
      int tmp7;
      // _cr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp7_1))) {
        case 3: {
          
          /* Pattern matching succeeded */
          tmp4 = _OMC_LIT447;
          goto tmp6_done;
        }
        case 4: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,1,1) == 0) goto tmp6_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 2));
          _cr = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = stringAppend(_OMC_LIT448,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
          tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT442);
          tmp4 = tmpMeta10;
          goto tmp6_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,2,1) == 0) goto tmp6_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 2));
          _cr = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta12 = stringAppend(_OMC_LIT449,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
          tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT442);
          tmp4 = tmpMeta13;
          goto tmp6_done;
        }
        }
        goto tmp6_end;
        tmp6_end: ;
      }
      goto goto_5;
      goto_5:;
      MMC_THROW_INTERNAL();
      goto tmp6_done;
      tmp6_done:;
    }
  }tmpMeta14 = stringAppend(_s,tmp4);
  _s = tmpMeta14;

  tmpMeta15 = stringAppend(_s,(mmc_unbox_boolean((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 23))))?_OMC_LIT450:_OMC_LIT31));
  _s = tmpMeta15;

  tmpMeta16 = stringAppend(_s,(mmc_unbox_boolean(omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 24))), mmc_mk_boolean(0 /* false */)))?_OMC_LIT451:_OMC_LIT31));
  _s = tmpMeta16;

  tmpMeta17 = stringAppend(_s,_OMC_LIT452);
  tmpMeta18 = stringAppend(tmpMeta17,(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 10))))?omc_ExpressionDump_printOptExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 10)))):_OMC_LIT31));
  _s = tmpMeta18;

  tmp20 = (modelica_boolean)isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 15))));
  if(tmp20)
  {
    tmpMeta19 = stringAppend(_OMC_LIT453,omc_ComponentReferenceBasics_printComponentRefStr(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 15))))));
    tmp21 = tmpMeta19;
  }
  else
  {
    tmp21 = _OMC_LIT454;
  }
  tmpMeta22 = stringAppend(_s,tmp21);
  _s = tmpMeta22;

  tmpMeta23 = stringAppend(_s,_OMC_LIT455);
  tmpMeta24 = stringAppend(tmpMeta23,(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 19))))?intString(mmc_unbox_integer(omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 19)))))):_OMC_LIT31));
  tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT337);
  _s = tmpMeta25;

  tmpMeta26 = stringAppend(_s,_OMC_LIT365);
  tmpMeta27 = stringAppend(tmpMeta26,stringDelimitList((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 21))), _OMC_LIT186));
  tmpMeta28 = stringAppend(tmpMeta27,_OMC_LIT360);
  _s = tmpMeta28;
  _return: OMC_LABEL_UNUSED
  return _s;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_derVarFromStateVar(threadData_t *threadData, modelica_metatype _state, modelica_metatype _timeInterval, modelica_metatype _iterationVars)
{
  modelica_metatype __omcQ_24mrfa_5F10 = NULL;
  modelica_metatype __omcQ_24mrfa_5F11 = NULL;
  modelica_metatype __omcQ_24mrfa_5F12 = NULL;
  modelica_metatype __omcQ_24mrfa_5F13 = NULL;
  modelica_metatype __omcQ_24mrfa_5F14 = NULL;
  modelica_metatype __omcQ_24mrfa_5F15 = NULL;
  modelica_metatype __omcQ_24mrfa_5F16 = NULL;
  modelica_string __omcQ_24mrfa_5F17 = NULL;
  modelica_metatype __omcQ_24mrfa_5F18 = NULL;
  modelica_metatype __omcQ_24mrfa_5F19 = NULL;
  modelica_metatype __omcQ_24mrfa_5F20 = NULL;
  modelica_metatype __omcQ_24mrfa_5F21 = NULL;
  modelica_metatype __omcQ_24mrfa_5F22 = NULL;
  modelica_metatype __omcQ_24mrfa_5F23 = NULL;
  modelica_metatype __omcQ_24mrfa_5F24 = NULL;
  modelica_metatype __omcQ_24mrfa_5F25 = NULL;
  modelica_metatype _deriv = NULL;
  modelica_metatype _unit = NULL;
  modelica_metatype _nominal = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F10 has no default value.
  // __omcQ_24mrfa_5F11 has no default value.
  // __omcQ_24mrfa_5F12 has no default value.
  // __omcQ_24mrfa_5F13 has no default value.
  // __omcQ_24mrfa_5F14 has no default value.
  // __omcQ_24mrfa_5F15 has no default value.
  // __omcQ_24mrfa_5F16 has no default value.
  // __omcQ_24mrfa_5F17 has no default value.
  // __omcQ_24mrfa_5F18 has no default value.
  // __omcQ_24mrfa_5F19 has no default value.
  // __omcQ_24mrfa_5F20 has no default value.
  // __omcQ_24mrfa_5F21 has no default value.
  // __omcQ_24mrfa_5F22 has no default value.
  // __omcQ_24mrfa_5F23 has no default value.
  // __omcQ_24mrfa_5F24 has no default value.
  // __omcQ_24mrfa_5F25 has no default value.
  _deriv = _state;
  // _unit has no default value.
  // _nominal has no default value.
  __omcQ_24mrfa_5F14 = omc_Util_applyOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 15))), boxvar_ComponentReference_crefPrefixDer);

  __omcQ_24mrfa_5F15 = omc_ComponentReference_crefPrefixDer(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))));

  __omcQ_24mrfa_5F16 = _OMC_LIT456;

  tmpMeta1 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, __omcQ_24mrfa_5F15, __omcQ_24mrfa_5F16, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 14))), __omcQ_24mrfa_5F14, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 32))));
  _deriv = tmpMeta1;

  if((!stringEqual((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), _OMC_LIT31)))
  {
    tmpMeta3 = stringAppend(_OMC_LIT457,(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))));
    tmpMeta4 = stringAppend(tmpMeta3,_OMC_LIT337);
    tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[4] = tmpMeta4;
    _deriv = tmpMeta2;
  }

  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp7;
      int tmp8;
      tmp7 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp6_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp7 < 2; tmp7++) {
        switch (MMC_SWITCH_CAST(tmp7)) {
        case 0: {
          modelica_metatype tmpMeta9;
          /* Pattern matching succeeded */
          _unit = omc_NFUnit_parseUnitString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), omc_NFUnit_getKnownUnits(threadData), _OMC_LIT90);

          _unit = omc_NFUnit_unitDiv(threadData, _unit, _OMC_LIT458);

          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(33));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[5] = omc_NFUnit_unitString(threadData, _unit, omc_NFUnit_getKnownUnitsInverse(threadData));
          _deriv = tmpMeta9;
          goto tmp6_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(33));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[5] = _OMC_LIT31;
          _deriv = tmpMeta10;
          goto tmp6_done;
        }
        }
        goto tmp6_end;
        tmp6_end: ;
      }
      goto goto_5;
      tmp6_done:
      (void)tmp7;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp6_done2;
      goto_5:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp7 < 2) {
        goto tmp6_top;
      }
      MMC_THROW_INTERNAL();
      tmp6_done2:;
    }
  }
  ;

  __omcQ_24mrfa_5F17 = _OMC_LIT31;

  __omcQ_24mrfa_5F18 = mmc_mk_none();

  __omcQ_24mrfa_5F19 = mmc_mk_none();

  tmpMeta11 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), __omcQ_24mrfa_5F17, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 7))), __omcQ_24mrfa_5F18, __omcQ_24mrfa_5F19, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 29))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 32))));
  _deriv = tmpMeta11;

  if((isSome(_iterationVars) && omc_UnorderedSet_contains(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), omc_Util_getOption(threadData, _iterationVars))))
  {
    if(isSome(_timeInterval))
    {
      _nominal = omc_Expression_makeDiv(threadData, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), _OMC_LIT2), omc_Util_getOption(threadData, _timeInterval));

      tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(33));
      memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[11] = mmc_mk_some(omc_ExpressionSimplify_simplify(threadData, _nominal, NULL));
      _deriv = tmpMeta12;
    }
  }
  else
  {
    tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[11] = mmc_mk_none();
    _deriv = tmpMeta13;
  }

  __omcQ_24mrfa_5F20 = mmc_mk_boolean(0 /* false */);

  __omcQ_24mrfa_5F21 = _OMC_LIT88;

  __omcQ_24mrfa_5F22 = _OMC_LIT94;

  __omcQ_24mrfa_5F23 = mmc_mk_none();

  __omcQ_24mrfa_5F24 = mmc_mk_boolean(0 /* false */);

  __omcQ_24mrfa_5F25 = _OMC_LIT459;

  tmpMeta14 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), __omcQ_24mrfa_5F20, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 15))), __omcQ_24mrfa_5F21, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 17))), __omcQ_24mrfa_5F22, __omcQ_24mrfa_5F23, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 21))), __omcQ_24mrfa_5F24, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 28))), __omcQ_24mrfa_5F25, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 30))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 32))));
  _deriv = tmpMeta14;

  if((isSome(_iterationVars) && omc_UnorderedSet_contains(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), omc_Util_getOption(threadData, _iterationVars))))
  {
    __omcQ_24mrfa_5F10 = _OMC_LIT461;

    __omcQ_24mrfa_5F11 = _OMC_LIT264;

    tmpMeta15 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 9))), __omcQ_24mrfa_5F11, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 29))), __omcQ_24mrfa_5F10, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 32))));
    _deriv = tmpMeta15;
  }
  else
  {
    __omcQ_24mrfa_5F12 = _OMC_LIT460;

    __omcQ_24mrfa_5F13 = mmc_mk_none();

    tmpMeta16 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 9))), __omcQ_24mrfa_5F13, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 19))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 20))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 21))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 22))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 23))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 24))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 25))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 26))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 27))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 28))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 29))), __omcQ_24mrfa_5F12, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 31))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 32))));
    _deriv = tmpMeta16;
  }

  if((omc_Flags_getConfigEnum(threadData, _OMC_LIT490) == ((modelica_integer) 4)))
  {
    tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[31] = mmc_mk_some(omc_ComponentReference_getConcealedCref(threadData));
    _deriv = tmpMeta17;
  }
  else
  {
    tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_deriv), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[31] = mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_deriv), 2))));
    _deriv = tmpMeta18;
  }
  _return: OMC_LABEL_UNUSED
  return _deriv;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_addSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_integer _index, modelica_metatype _simVars)
{
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = mmc_mk_cons(_simVar, arrayGetNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_index))));
  arrayUpdateNoBoundsChecking(_simVars, ((modelica_integer)((modelica_integer)_index)), tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return;
}
PROTECTED_FUNCTION_STATIC void boxptr_SimCodeUtil_addSimVar(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _index, modelica_metatype _simVars)
{
  modelica_integer tmp1;
  tmp1 = mmc_unbox_integer(_index);
  omc_SimCodeUtil_addSimVar(threadData, _simVar, tmp1, _simVars);
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extractVarFromVar2(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _simVars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars)
{
  modelica_metatype _simVar = NULL;
  modelica_metatype _derivSimvar = NULL;
  modelica_boolean _isalias;
  modelica_boolean _isAlg;
  modelica_boolean _isParam;
  modelica_boolean _isConst;
  modelica_metatype _name = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simVar has no default value.
  // _derivSimvar has no default value.
  // _isalias has no default value.
  // _isAlg has no default value.
  // _isParam has no default value.
  // _isConst has no default value.
  // _name has no default value.
  _simVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _dlowVar, mmc_mk_some(_inAliasVars), _inVars, _iterationVars);

  _isalias = omc_SimCodeUtil_isAliasVar(threadData, _simVar);

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[31] = omc_SimCodeUtil_getExportVar(threadData, _dlowVar);
  _simVar = tmpMeta1;

  if(((omc_BackendVariable_isStringParam(threadData, _dlowVar) && isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 10))))) && (!omc_Expression_isEvaluatedConst(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 10))))))))
  {
    tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(33));
    memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[31] = mmc_mk_none();
    _simVar = tmpMeta2;
  }

  omc_Mutable_update(threadData, _hs, omc_BaseHashSet_add(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 2))), omc_Mutable_access(threadData, _hs)));

  if(((!_isalias) && (omc_BackendVariable_isStateVar(threadData, _dlowVar) || omc_BackendVariable_isAlgState(threadData, _dlowVar))))
  {
    _derivSimvar = omc_SimCodeUtil_derVarFromStateVar(threadData, _simVar, _timeInterval, _iterationVars);

    omc_Mutable_update(threadData, _hs, omc_BaseHashSet_add(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_derivSimvar), 2))), omc_Mutable_access(threadData, _hs)));
  }
  else
  {
    _derivSimvar = _simVar;
  }

  if(((!_isalias) && omc_BackendVariable_isVarOnTopLevelAndInputNoDerInput(threadData, _dlowVar)))
  {
    { /* match expression */
      modelica_metatype tmp6_1;
      tmp6_1 = _simVar;
      {
        volatile mmc_switch_type tmp6;
        int tmp7;
        tmp6 = 0;
        for (; tmp6 < 2; tmp6++) {
          switch (MMC_SWITCH_CAST(tmp6)) {
          case 0: {
            modelica_metatype tmpMeta8;
            
            /* Pattern matching succeeded */
            tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(33));
            memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[26] = mmc_mk_some(arrayCreate(((modelica_integer) 1), mmc_mk_integer(((modelica_integer) -2))));
            _simVar = tmpMeta8;
            tmpMeta3 = _simVar;
            goto tmp5_done;
          }
          case 1: {
            
            /* Pattern matching succeeded */
            omc_Error_addInternalError(threadData, _OMC_LIT491, _OMC_LIT492);
            goto goto_4;
            goto tmp5_done;
          }
          }
          goto tmp5_end;
          tmp5_end: ;
        }
        goto goto_4;
        goto_4:;
        MMC_THROW_INTERNAL();
        goto tmp5_done;
        tmp5_done:;
      }
    }
    _simVar = tmpMeta3;
  }

  _isAlg = omc_BackendVariable_isVarAlg(threadData, _dlowVar);

  _isParam = omc_BackendVariable_isParam(threadData, _dlowVar);

  _isConst = omc_BackendVariable_isConst(threadData, _dlowVar);

  if(omc_BackendVariable_isVarOnTopLevelAndInputNoDerInput(threadData, _dlowVar))
  {
    omc_SimCodeUtil_addSimVar(threadData, _simVar, 19, _simVars);
  }

  if(omc_BackendVariable_isVarOnTopLevelAndOutput(threadData, _dlowVar))
  {
    omc_SimCodeUtil_addSimVar(threadData, _simVar, 20, _simVars);
  }

  if(_isalias)
  {
    if(omc_Types_isReal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
    {
      omc_SimCodeUtil_addSimVar(threadData, _simVar, 8, _simVars);
    }
    else
    {
      if((omc_Types_isInteger(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))) || omc_Types_isEnumeration(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6))))))
      {
        omc_SimCodeUtil_addSimVar(threadData, _simVar, 11, _simVars);
      }
      else
      {
        if(omc_Types_isBoolean(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
        {
          omc_SimCodeUtil_addSimVar(threadData, _simVar, 14, _simVars);
        }
        else
        {
          if(omc_Types_isString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
          {
            omc_SimCodeUtil_addSimVar(threadData, _simVar, 17, _simVars);
          }
        }
      }
    }
  }
  else
  {
    if((omc_BackendVariable_isStateVar(threadData, _dlowVar) || omc_BackendVariable_isAlgState(threadData, _dlowVar)))
    {
      omc_SimCodeUtil_addSimVar(threadData, _simVar, 1, _simVars);

      omc_SimCodeUtil_addSimVar(threadData, _derivSimvar, 2, _simVars);
    }
    else
    {
      if(((_isAlg || _isParam) || _isConst))
      {
        if(omc_Types_isReal(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
        {
          if(_isAlg)
          {
            if(omc_BackendVariable_isVarDiscrete(threadData, _dlowVar))
            {
              omc_SimCodeUtil_addSimVar(threadData, _simVar, 4, _simVars);
            }
            else
            {
              omc_SimCodeUtil_addSimVar(threadData, _simVar, 3, _simVars);
            }
          }
          else
          {
            if(_isParam)
            {
              omc_SimCodeUtil_addSimVar(threadData, _simVar, 7, _simVars);
            }
            else
            {
              if(_isConst)
              {
                omc_SimCodeUtil_addSimVar(threadData, _simVar, 21, _simVars);
              }
            }
          }
        }
        else
        {
          if((omc_Types_isInteger(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))) || omc_Types_isEnumeration(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6))))))
          {
            if(_isAlg)
            {
              omc_SimCodeUtil_addSimVar(threadData, _simVar, 9, _simVars);
            }
            else
            {
              if(_isParam)
              {
                omc_SimCodeUtil_addSimVar(threadData, _simVar, 10, _simVars);
              }
              else
              {
                if(_isConst)
                {
                  omc_SimCodeUtil_addSimVar(threadData, _simVar, 22, _simVars);
                }
              }
            }
          }
          else
          {
            if(omc_Types_isBoolean(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
            {
              if(_isAlg)
              {
                omc_SimCodeUtil_addSimVar(threadData, _simVar, 12, _simVars);
              }
              else
              {
                if(_isParam)
                {
                  omc_SimCodeUtil_addSimVar(threadData, _simVar, 13, _simVars);
                }
                else
                {
                  if(_isConst)
                  {
                    omc_SimCodeUtil_addSimVar(threadData, _simVar, 23, _simVars);
                  }
                }
              }
            }
            else
            {
              if(omc_Types_isString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
              {
                if(_isAlg)
                {
                  omc_SimCodeUtil_addSimVar(threadData, _simVar, 15, _simVars);
                }
                else
                {
                  if(_isParam)
                  {
                    omc_SimCodeUtil_addSimVar(threadData, _simVar, 16, _simVars);
                  }
                  else
                  {
                    if(_isConst)
                    {
                      omc_SimCodeUtil_addSimVar(threadData, _simVar, 24, _simVars);
                    }
                  }
                }
              }
              else
              {
                tmpMeta9 = stringAppend(_OMC_LIT495,omc_BackendDump_varString(threadData, _dlowVar));
                omc_Error_addInternalError(threadData, tmpMeta9, _OMC_LIT496);
              }
            }
          }
        }
      }
      else
      {
        if(omc_BackendVariable_isExtObj(threadData, _dlowVar))
        {
          omc_SimCodeUtil_addSimVar(threadData, _simVar, 18, _simVars);
        }
        else
        {
          if(omc_BackendVariable_isRealOptimizeConstraintsVars(threadData, _dlowVar))
          {
            omc_SimCodeUtil_addSimVar(threadData, _simVar, 5, _simVars);
          }
          else
          {
            if(omc_BackendVariable_isRealOptimizeFinalConstraintsVars(threadData, _dlowVar))
            {
              omc_SimCodeUtil_addSimVar(threadData, _simVar, 6, _simVars);
            }
            else
            {
              if(omc_BackendVariable_isOptInputVar(threadData, _dlowVar))
              {
                omc_SimCodeUtil_addSimVar(threadData, _simVar, 3, _simVars);
              }
              else
              {
                if(omc_BackendVariable_isDAEmodeVar(threadData, _dlowVar))
                {
                }
                else
                {
                  tmpMeta10 = stringAppend(_OMC_LIT493,omc_BackendDump_varString(threadData, _dlowVar));
                  omc_Error_addInternalError(threadData, tmpMeta10, _OMC_LIT494);
                }
              }
            }
          }
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getExportVar(threadData_t *threadData, modelica_metatype _var)
{
  modelica_metatype _exportVar = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exportVar = mmc_mk_none();
  if((omc_Flags_getConfigEnum(threadData, _OMC_LIT490) == ((modelica_integer) 1)))
  {
    _exportVar = mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
  }
  else
  {
    if((omc_Flags_getConfigEnum(threadData, _OMC_LIT490) == ((modelica_integer) 2)))
    {
      if((!(omc_ComponentReference_isInternalCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)))) && ((!omc_BackendVariable_isStateVar(threadData, _var)) && (!omc_BackendVariable_isClockedStateVar(threadData, _var))))))
      {
        _exportVar = mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
      }
    }
    else
    {
      if((omc_Flags_getConfigEnum(threadData, _OMC_LIT490) == ((modelica_integer) 3)))
      {
        if((!(omc_ComponentReference_isInternalCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)))) && ((!omc_BackendVariable_isStateVar(threadData, _var)) && (!omc_BackendVariable_isClockedStateVar(threadData, _var))))))
        {
          if((!(omc_BackendVariable_isProtected(threadData, _var) && (((!omc_BackendVariable_isStateVar(threadData, _var)) && (!omc_BackendVariable_isClockedStateVar(threadData, _var))) && (!omc_ComponentReference_isPreviousCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)))))))))
          {
            _exportVar = mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
          }
        }
      }
      else
      {
        if((omc_Flags_getConfigEnum(threadData, _OMC_LIT490) == ((modelica_integer) 4)))
        {
          if((omc_BackendVariable_isInput(threadData, _var) || omc_BackendVariable_isOutputVar(threadData, _var)))
          {
            _exportVar = mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
          }
          else
          {
            if((omc_BackendVariable_isStateVar(threadData, _var) || omc_BackendVariable_isClockedStateVar(threadData, _var)))
            {
              _exportVar = mmc_mk_some(omc_ComponentReference_getConcealedCref(threadData));
            }
          }
        }
        else
        {
          omc_Error_addInternalError(threadData, _OMC_LIT497, _OMC_LIT498);

          MMC_THROW_INTERNAL();
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _exportVar;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_extractVarFromVar(threadData_t *threadData, modelica_metatype _dlowVar, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _simVars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars)
{
  modelica_metatype __omcQ_24mrfa_5F26 = NULL;
  modelica_metatype __omcQ_24mrfa_5F27 = NULL;
  modelica_metatype _scalar_crefs = NULL;
  modelica_metatype _scalarVar = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype _scalar_bindings = NULL;
  modelica_metatype _binding_opt = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F26 has no default value.
  // __omcQ_24mrfa_5F27 has no default value.
  // _scalar_crefs has no default value.
  // _scalarVar has no default value.
  // _binding has no default value.
  // _scalar_bindings has no default value.
  // _binding_opt has no default value.
  // _cref has no default value.
  if(omc_Types_isArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 6)))))
  {
    _scalar_crefs = omc_ComponentReference_expandCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 2))), 0 /* false */);

    { /* matchcontinue expression */
      {
        volatile mmc_switch_type tmp3;
        int tmp4;
        tmp3 = 0;
        MMC_TRY_INTERNAL(mmc_jumper)
        tmp2_top:
        threadData->mmc_jumper = &new_mmc_jumper;
        for (; tmp3 < 2; tmp3++) {
          switch (MMC_SWITCH_CAST(tmp3)) {
          case 0: {
            modelica_metatype tmpMeta5;
            /* Pattern matching succeeded */
            { /* match expression */
              modelica_metatype tmp8_1;
              tmp8_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 7)));
              {
                volatile mmc_switch_type tmp8;
                int tmp9;
                tmp8 = 0;
                for (; tmp8 < 3; tmp8++) {
                  switch (MMC_SWITCH_CAST(tmp8)) {
                  case 0: {
                    modelica_metatype tmpMeta10;
                    modelica_metatype tmpMeta11;
                    if (optionNone(tmp8_1)) goto tmp7_end;
                    tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 1));
                    if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,16,3) == 0) goto tmp7_end;
                    
                    _binding = tmpMeta10;
                    /* Pattern matching succeeded */
                    {
                      modelica_metatype __omcQ_24tmpVar39;
                      modelica_metatype* tmp12;
                      modelica_metatype tmpMeta13;
                      modelica_metatype __omcQ_24tmpVar38;
                      modelica_integer tmp14;
                      modelica_metatype _b_loopVar = 0;
                      modelica_metatype _b;
                      _b_loopVar = omc_Expression_expandArray(threadData, _binding);
                      tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
                      __omcQ_24tmpVar39 = tmpMeta13; /* defaultValue */
                      tmp12 = &__omcQ_24tmpVar39;
                      while(1) {
                        tmp14 = 1;
                        if (!listEmpty(_b_loopVar)) {
                          _b = MMC_CAR(_b_loopVar);
                          _b_loopVar = MMC_CDR(_b_loopVar);
                          tmp14--;
                        }
                        if (tmp14 == 0) {
                          __omcQ_24tmpVar38 = mmc_mk_some(_b);
                          *tmp12 = mmc_mk_cons(__omcQ_24tmpVar38,0);
                          tmp12 = &MMC_CDR(*tmp12);
                        } else if (tmp14 == 1) {
                          break;
                        } else {
                          goto goto_6;
                        }
                      }
                      *tmp12 = mmc_mk_nil();
                      tmpMeta11 = __omcQ_24tmpVar39;
                    }
                    tmpMeta5 = tmpMeta11;
                    goto tmp7_done;
                  }
                  case 1: {
                    modelica_metatype tmpMeta15;
                    modelica_metatype tmpMeta16;
                    if (optionNone(tmp8_1)) goto tmp7_end;
                    tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 1));
                    if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,17,3) == 0) goto tmp7_end;
                    
                    _binding = tmpMeta15;
                    /* Pattern matching succeeded */
                    {
                      modelica_metatype __omcQ_24tmpVar41;
                      modelica_metatype* tmp17;
                      modelica_metatype tmpMeta18;
                      modelica_metatype __omcQ_24tmpVar40;
                      modelica_integer tmp19;
                      modelica_metatype _b_loopVar = 0;
                      modelica_metatype _b;
                      _b_loopVar = omc_Expression_expandArray(threadData, _binding);
                      tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
                      __omcQ_24tmpVar41 = tmpMeta18; /* defaultValue */
                      tmp17 = &__omcQ_24tmpVar41;
                      while(1) {
                        tmp19 = 1;
                        if (!listEmpty(_b_loopVar)) {
                          _b = MMC_CAR(_b_loopVar);
                          _b_loopVar = MMC_CDR(_b_loopVar);
                          tmp19--;
                        }
                        if (tmp19 == 0) {
                          __omcQ_24tmpVar40 = mmc_mk_some(_b);
                          *tmp17 = mmc_mk_cons(__omcQ_24tmpVar40,0);
                          tmp17 = &MMC_CDR(*tmp17);
                        } else if (tmp19 == 1) {
                          break;
                        } else {
                          goto goto_6;
                        }
                      }
                      *tmp17 = mmc_mk_nil();
                      tmpMeta16 = __omcQ_24tmpVar41;
                    }
                    tmpMeta5 = tmpMeta16;
                    goto tmp7_done;
                  }
                  case 2: {
                    
                    /* Pattern matching succeeded */
                    tmpMeta5 = omc_List_fill(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 7))), listLength(_scalar_crefs));
                    goto tmp7_done;
                  }
                  }
                  goto tmp7_end;
                  tmp7_end: ;
                }
                goto goto_6;
                goto_6:;
                goto goto_1;
                goto tmp7_done;
                tmp7_done:;
              }
            }
            _scalar_bindings = tmpMeta5;

            if((listLength(_scalar_bindings) != listLength(_scalar_crefs)))
            {
              goto goto_1;
            }
            goto tmp2_done;
          }
          case 1: {
            /* Pattern matching succeeded */
            _scalar_bindings = omc_List_fill(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 7))), listLength(_scalar_crefs));
            goto tmp2_done;
          }
          }
          goto tmp2_end;
          tmp2_end: ;
        }
        goto goto_1;
        tmp2_done:
        (void)tmp3;
        MMC_RESTORE_INTERNAL(mmc_jumper);
        goto tmp2_done2;
        goto_1:;
        MMC_CATCH_INTERNAL(mmc_jumper);
        if (++tmp3 < 2) {
          goto tmp2_top;
        }
        MMC_THROW_INTERNAL();
        tmp2_done2:;
      }
    }
    ;

    if((!stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))
    {
      omc_Mutable_update(threadData, _hs, omc_BaseHashSet_add(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlowVar), 2))), omc_Mutable_access(threadData, _hs)));

      {
        modelica_metatype _tpl;
        for (tmpMeta20 = omc_List_zip(threadData, _scalar_crefs, _scalar_bindings); !listEmpty(tmpMeta20); tmpMeta20=MMC_CDR(tmpMeta20))
        {
          _tpl = MMC_CAR(tmpMeta20);
          /* Pattern-matching assignment */
          tmpMeta21 = _tpl;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          _cref = tmpMeta22;
          _binding_opt = tmpMeta23;

          _scalarVar = omc_BackendVariable_copyVarNewName(threadData, _cref, _dlowVar);

          __omcQ_24mrfa_5F26 = _binding_opt;

          __omcQ_24mrfa_5F27 = omc_ComponentReference_crefTypeFull(threadData, _cref);

          tmpMeta24 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 5))), __omcQ_24mrfa_5F27, __omcQ_24mrfa_5F26, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 16))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 17))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 18))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_scalarVar), 19))));
          _scalarVar = tmpMeta24;

          omc_SimCodeUtil_extractVarFromVar2(threadData, _scalarVar, _inAliasVars, _inVars, _simVars, _hs, _timeInterval, _iterationVars);
        }
      }
    }
    else
    {
      omc_SimCodeUtil_extractVarFromVar2(threadData, _dlowVar, _inAliasVars, _inVars, _simVars, _hs, _timeInterval, _iterationVars);

      {
        modelica_metatype _cref;
        for (tmpMeta26 = _scalar_crefs; !listEmpty(tmpMeta26); tmpMeta26=MMC_CDR(tmpMeta26))
        {
          _cref = MMC_CAR(tmpMeta26);
          omc_Mutable_update(threadData, _hs, omc_BaseHashSet_add(threadData, _cref, omc_Mutable_access(threadData, _hs)));
        }
      }
    }
  }
  else
  {
    omc_SimCodeUtil_extractVarFromVar2(threadData, _dlowVar, _inAliasVars, _inVars, _simVars, _hs, _timeInterval, _iterationVars);
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_SimCodeUtil_simBranchString_simBranchBodyString(threadData_t *threadData, modelica_metatype _tpl)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(omc_ExpressionBasics_printExpStr(threadData, omc_Util_tuple21(threadData, _tpl)),_OMC_LIT224);
  tmpMeta2 = stringAppend(tmpMeta1,omc_ExpressionBasics_printExpStr(threadData, omc_Util_tuple22(threadData, _tpl)));
  tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT61);
  _str = tmpMeta3;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_string omc_SimCodeUtil_simBranchString(threadData_t *threadData, modelica_metatype _branch)
{
  modelica_string _str = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _branch;
    {
      modelica_boolean _b;
      int tmp4;
      // _b has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_boolean tmp7;
          modelica_string tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_boolean tmp11;
          modelica_string tmp12;
          
          /* Pattern matching succeeded */
          _b = isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 2))));

          tmp7 = (modelica_boolean)_b;
          if(tmp7)
          {
            tmpMeta5 = stringAppend(_OMC_LIT499,omc_ExpressionBasics_printExpStr(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 2))))));
            tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT500);
            tmp8 = tmpMeta6;
          }
          else
          {
            tmp8 = _OMC_LIT501;
          }
          _str = tmp8;

          tmpMeta9 = stringAppend(_str,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 3))), boxvar_SimCodeUtil_simBranchString_simBranchBodyString, _OMC_LIT502, _OMC_LIT502, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0)));
          _str = tmpMeta9;
          tmp11 = (modelica_boolean)_b;
          if(tmp11)
          {
            tmpMeta10 = stringAppend(_str,_OMC_LIT503);
            tmp12 = tmpMeta10;
          }
          else
          {
            tmp12 = _str;
          }
          tmp1 = tmp12;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_boolean tmp15;
          modelica_string tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_boolean tmp19;
          modelica_string tmp20;
          
          /* Pattern matching succeeded */
          _b = isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 2))));

          tmp15 = (modelica_boolean)_b;
          if(tmp15)
          {
            tmpMeta13 = stringAppend(_OMC_LIT499,omc_ExpressionBasics_printExpStr(threadData, omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 2))))));
            tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT500);
            tmp16 = tmpMeta14;
          }
          else
          {
            tmp16 = _OMC_LIT501;
          }
          _str = tmp16;

          tmpMeta17 = stringAppend(_str,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_branch), 3))), boxvar_DAEDump_ppStatementStr, _OMC_LIT502, _OMC_LIT502, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0)));
          _str = tmpMeta17;
          tmp19 = (modelica_boolean)_b;
          if(tmp19)
          {
            tmpMeta18 = stringAppend(_str,_OMC_LIT504);
            tmp20 = tmpMeta18;
          }
          else
          {
            tmp20 = _str;
          }
          tmp1 = tmp20;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT31;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _str = tmp1;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_string omc_SimCodeUtil_simGenericCallString(threadData_t *threadData, modelica_metatype _call)
{
  modelica_string _str = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _call;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          
          /* Pattern matching succeeded */
          tmpMeta5 = stringAppend(_OMC_LIT505,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 2))))));
          tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT349);
          tmpMeta7 = stringAppend(tmpMeta6,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 3))), boxvar_BackendDump_simIteratorString, _OMC_LIT31, _OMC_LIT410, _OMC_LIT243, _OMC_LIT411, 1 /* true */, ((modelica_integer) 0)));
          _str = tmpMeta7;
          tmpMeta8 = stringAppend(_str,_OMC_LIT506);
          tmpMeta9 = stringAppend(tmpMeta8,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 4)))));
          tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT224);
          tmpMeta11 = stringAppend(tmpMeta10,omc_ExpressionBasics_printExpStr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 5)))));
          tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT61);
          tmp1 = tmpMeta12;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          
          /* Pattern matching succeeded */
          tmpMeta13 = stringAppend(_OMC_LIT507,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 2))))));
          tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT349);
          tmpMeta15 = stringAppend(tmpMeta14,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 3))), boxvar_BackendDump_simIteratorString, _OMC_LIT31, _OMC_LIT410, _OMC_LIT243, _OMC_LIT411, 1 /* true */, ((modelica_integer) 0)));
          _str = tmpMeta15;
          tmpMeta16 = stringAppend(_str,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 4))), boxvar_SimCodeUtil_simBranchString, _OMC_LIT31, _OMC_LIT31, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0)));
          tmp1 = tmpMeta16;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          
          /* Pattern matching succeeded */
          tmpMeta17 = stringAppend(_OMC_LIT508,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 2))))));
          tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT349);
          tmpMeta19 = stringAppend(tmpMeta18,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 3))), boxvar_BackendDump_simIteratorString, _OMC_LIT31, _OMC_LIT410, _OMC_LIT243, _OMC_LIT411, 1 /* true */, ((modelica_integer) 0)));
          _str = tmpMeta19;
          tmpMeta20 = stringAppend(_str,omc_List_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 4))), boxvar_SimCodeUtil_simBranchString, _OMC_LIT31, _OMC_LIT31, _OMC_LIT48, _OMC_LIT31, 1 /* true */, ((modelica_integer) 0)));
          tmp1 = tmpMeta20;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT31;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _str = tmp1;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_string omc_SimCodeUtil_getFmiInitialAttributeStr(threadData_t *threadData, modelica_metatype _simVar)
{
  modelica_string _out_string = NULL;
  modelica_metatype _var_initial = NULL;
  modelica_metatype _default_initial = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_string tmp3 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _out_string = _OMC_LIT31;
  // _var_initial has no default value.
  // _default_initial has no default value.
  if(isNone((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 30)))))
  {
    goto _return;
  }

  /* Pattern-matching assignment */
  tmpMeta1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 30)));
  if (optionNone(tmpMeta1)) MMC_THROW_INTERNAL();
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  _var_initial = tmpMeta2;

  _default_initial = omc_SimCodeUtil_getDefaultFmiInitialAttribute(threadData, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 29))), _OMC_LIT124), omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 18))), _OMC_LIT93));

  if((valueEq(_var_initial, _default_initial) && (!omc_Flags_isSet(threadData, _OMC_LIT511))))
  {
    _var_initial = _OMC_LIT275;
  }

  { /* match expression */
    modelica_metatype tmp6_1;
    tmp6_1 = _var_initial;
    {
      int tmp6;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp6_1))) {
        case 4: {
          
          /* Pattern matching succeeded */
          tmp3 = _OMC_LIT512;
          goto tmp5_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmp3 = _OMC_LIT513;
          goto tmp5_done;
        }
        case 6: {
          
          /* Pattern matching succeeded */
          tmp3 = _OMC_LIT514;
          goto tmp5_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp3 = _OMC_LIT31;
          goto tmp5_done;
        }
        }
        goto tmp5_end;
        tmp5_end: ;
      }
      goto goto_4;
      goto_4:;
      MMC_THROW_INTERNAL();
      goto tmp5_done;
      tmp5_done:;
    }
  }
  _out_string = tmp3;
  _return: OMC_LABEL_UNUSED
  return _out_string;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getDefaultFmiInitialAttribute(threadData_t *threadData, modelica_metatype _variability, modelica_metatype _causality)
{
  modelica_metatype _initial_ = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _initial_ has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _variability;
    tmp4_2 = _causality;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 13; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,4,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,4,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT274;
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 7: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 8: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 9: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 10: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 11: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT272;
          goto tmp3_done;
        }
        case 12: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _OMC_LIT275;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _initial_ = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _initial_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_extractVarsFromList(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fvar, modelica_metatype __omcQ_24in_5FsimVars, modelica_metatype _aliasVars, modelica_metatype _vars, modelica_metatype _hs, modelica_metatype _timeInterval, modelica_metatype _iterationVars, modelica_metatype *out_simVars)
{
  modelica_metatype _var = NULL;
  modelica_metatype _simVars = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _var = __omcQ_24in_5Fvar;
  _simVars = __omcQ_24in_5FsimVars;
  if(((omc_ComponentReference_isPreCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)))) || omc_ComponentReference_isStartCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)))))?0 /* false */:(!omc_BaseHashSet_has(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), omc_Mutable_access(threadData, _hs)))))
  {
    if((!omc_BackendVariable_isAlgebraicOldState(threadData, _var)))
    {
      omc_SimCodeUtil_extractVarFromVar(threadData, _var, _aliasVars, _vars, _simVars, _hs, _timeInterval, _iterationVars);
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_simVars) { *out_simVars = _simVars; }
  return _var;
}

static modelica_metatype closure7_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp21)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp21);
}static modelica_metatype closure8_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp23)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp23);
}static modelica_metatype closure9_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp25)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp25);
}static modelica_metatype closure10_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp27)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp27);
}static modelica_metatype closure11_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp29)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp29);
}static modelica_metatype closure12_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp35)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp35);
}static modelica_metatype closure13_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp37)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp37);
}static modelica_metatype closure14_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp39)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp39);
}static modelica_metatype closure15_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp41)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp41);
}static modelica_metatype closure16_SimCodeUtil_extractVarsFromList(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_var, modelica_metatype $in_simVars, modelica_metatype tmp43)
{
  modelica_metatype aliasVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype hs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype timeInterval = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype iterationVars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_SimCodeUtil_extractVarsFromList(thData, $in_var, $in_simVars, aliasVars, vars, hs, timeInterval, iterationVars, tmp43);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVars(threadData_t *threadData, modelica_metatype _inSimDAE, modelica_metatype _inInitDAE, modelica_metatype _tempvars, modelica_metatype *out_unitDefinitions)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _unitDefinitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _globalKnownVars1 = NULL;
  modelica_metatype _globalKnownVars2 = NULL;
  modelica_metatype _localKnownVars1 = NULL;
  modelica_metatype _localKnownVars2 = NULL;
  modelica_metatype _extvars1 = NULL;
  modelica_metatype _extvars2 = NULL;
  modelica_metatype _aliasVars1 = NULL;
  modelica_metatype _aliasVars2 = NULL;
  modelica_metatype _systs1 = NULL;
  modelica_metatype _systs2 = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _hs = NULL;
  modelica_metatype _simVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _primeSize;
  modelica_metatype _iterationVarsLst = NULL;
  modelica_metatype _iterationVars = NULL;
  modelica_metatype _timeInterval = NULL;
  modelica_boolean _debug;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta28;
  modelica_metatype tmpMeta30;
  modelica_metatype tmpMeta31;
  modelica_metatype tmpMeta36;
  modelica_metatype tmpMeta38;
  modelica_metatype tmpMeta40;
  modelica_metatype tmpMeta42;
  modelica_metatype tmpMeta44;
  modelica_metatype tmpMeta45;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _unitDefinitions = tmpMeta1;
  // _globalKnownVars1 has no default value.
  // _globalKnownVars2 has no default value.
  // _localKnownVars1 has no default value.
  // _localKnownVars2 has no default value.
  // _extvars1 has no default value.
  // _extvars2 has no default value.
  // _aliasVars1 has no default value.
  // _aliasVars2 has no default value.
  // _systs1 has no default value.
  // _systs2 has no default value.
  // _shared has no default value.
  // _hs has no default value.
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _simVars = arrayCreate(((modelica_integer) 30), tmpMeta2);
  // _primeSize has no default value.
  // _iterationVarsLst has no default value.
  // _iterationVars has no default value.
  _timeInterval = mmc_mk_none();
  _debug = 0 /* false */;
  /* Pattern-matching assignment */
  tmpMeta3 = _inSimDAE;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 3));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 4));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 5));
  _systs1 = tmpMeta4;
  _shared = tmpMeta5;
  _globalKnownVars1 = tmpMeta6;
  _localKnownVars1 = tmpMeta7;
  _extvars1 = tmpMeta8;
  _aliasVars1 = tmpMeta9;

  /* Pattern-matching assignment */
  tmpMeta10 = _inInitDAE;
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 4));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 5));
  _systs2 = tmpMeta11;
  _globalKnownVars2 = tmpMeta13;
  _localKnownVars2 = tmpMeta14;
  _extvars2 = tmpMeta15;
  _aliasVars2 = tmpMeta16;

  omc_BackendDAEOptimize_listAllIterationVariables0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inInitDAE), 2))) ,&_iterationVarsLst);

  _iterationVars = (listEmpty(_iterationVarsLst)?mmc_mk_none():mmc_mk_some(omc_UnorderedSet_fromList(threadData, _iterationVarsLst, boxvar_ComponentReferenceBasics_hashComponentRef, boxvar_ComponentReferenceBasics_crefEqual)));

  _primeSize = omc_Util_nextPrime(threadData, ((modelica_integer)floor((1.4) * (((modelica_real)omc_BackendVariable_varsSize(threadData, _globalKnownVars1) + omc_BackendVariable_varsSize(threadData, _globalKnownVars2) + omc_BackendVariable_varsSize(threadData, _localKnownVars1) + omc_BackendVariable_varsSize(threadData, _localKnownVars2) + omc_BackendVariable_varsSize(threadData, _aliasVars1) + omc_BackendVariable_varsSize(threadData, _aliasVars2) + omc_BackendVariable_varsSize(threadData, _extvars1) + omc_BackendVariable_varsSize(threadData, _extvars2) + omc_BackendDAEUtil_daeSize(threadData, _inSimDAE) + omc_BackendDAEUtil_daeSize(threadData, _inInitDAE))))));

  _hs = omc_Mutable_create(threadData, omc_HashSet_emptyHashSetSized(threadData, _primeSize));

  if((!omc_Flags_isSet(threadData, _OMC_LIT517)))
  {
    _systs1 = omc_List_map2(threadData, _systs1, boxvar_SimCodeUtil_preCalculateStartValues, _globalKnownVars1, _shared);

    _globalKnownVars1 = omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _globalKnownVars1, boxvar_SimCodeUtil_evaluateStartValues, _shared, NULL);
  }

  {
    modelica_metatype __omcQ_24tmpVar43;
    modelica_metatype* tmp18;
    modelica_metatype tmpMeta19;
    modelica_metatype __omcQ_24tmpVar42;
    modelica_integer tmp20;
    modelica_metatype _syst_loopVar = 0;
    modelica_metatype _syst;
    _syst_loopVar = _systs1;
    tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar43 = tmpMeta19; /* defaultValue */
    tmp18 = &__omcQ_24tmpVar43;
    while(1) {
      tmp20 = 1;
      if (!listEmpty(_syst_loopVar)) {
        _syst = MMC_CAR(_syst_loopVar);
        _syst_loopVar = MMC_CDR(_syst_loopVar);
        tmp20--;
      }
      if (tmp20 == 0) {
        __omcQ_24tmpVar42 = omc_BackendVariable_daeVars(threadData, _syst);
        *tmp18 = mmc_mk_cons(__omcQ_24tmpVar42,0);
        tmp18 = &MMC_CDR(*tmp18);
      } else if (tmp20 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp18 = mmc_mk_nil();
    tmpMeta17 = __omcQ_24tmpVar43;
  }
  tmpMeta22 = mmc_mk_box5(0, _aliasVars1, _globalKnownVars1, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_List_fold1(threadData, tmpMeta17, boxvar_BackendVariable_traverseBackendDAEVars, (modelica_fnptr) mmc_mk_box2(0,closure7_SimCodeUtil_extractVarsFromList,tmpMeta22), _simVars);

  tmpMeta24 = mmc_mk_box5(0, _aliasVars1, _globalKnownVars1, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _globalKnownVars1, (modelica_fnptr) mmc_mk_box2(0,closure8_SimCodeUtil_extractVarsFromList,tmpMeta24), _simVars);

  tmpMeta26 = mmc_mk_box5(0, _aliasVars1, _globalKnownVars1, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _localKnownVars1, (modelica_fnptr) mmc_mk_box2(0,closure9_SimCodeUtil_extractVarsFromList,tmpMeta26), _simVars);

  tmpMeta28 = mmc_mk_box5(0, _aliasVars1, _globalKnownVars1, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _aliasVars1, (modelica_fnptr) mmc_mk_box2(0,closure10_SimCodeUtil_extractVarsFromList,tmpMeta28), _simVars);

  tmpMeta30 = mmc_mk_box5(0, _aliasVars1, _globalKnownVars1, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _extvars1, (modelica_fnptr) mmc_mk_box2(0,closure11_SimCodeUtil_extractVarsFromList,tmpMeta30), _simVars);

  {
    modelica_metatype __omcQ_24tmpVar45;
    modelica_metatype* tmp32;
    modelica_metatype tmpMeta33;
    modelica_metatype __omcQ_24tmpVar44;
    modelica_integer tmp34;
    modelica_metatype _syst_loopVar = 0;
    modelica_metatype _syst;
    _syst_loopVar = _systs2;
    tmpMeta33 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar45 = tmpMeta33; /* defaultValue */
    tmp32 = &__omcQ_24tmpVar45;
    while(1) {
      tmp34 = 1;
      if (!listEmpty(_syst_loopVar)) {
        _syst = MMC_CAR(_syst_loopVar);
        _syst_loopVar = MMC_CDR(_syst_loopVar);
        tmp34--;
      }
      if (tmp34 == 0) {
        __omcQ_24tmpVar44 = omc_BackendVariable_daeVars(threadData, _syst);
        *tmp32 = mmc_mk_cons(__omcQ_24tmpVar44,0);
        tmp32 = &MMC_CDR(*tmp32);
      } else if (tmp34 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp32 = mmc_mk_nil();
    tmpMeta31 = __omcQ_24tmpVar45;
  }
  tmpMeta36 = mmc_mk_box5(0, _aliasVars2, _globalKnownVars2, _hs, mmc_mk_none(), _iterationVars);
  _simVars = omc_List_fold1(threadData, tmpMeta31, boxvar_BackendVariable_traverseBackendDAEVars, (modelica_fnptr) mmc_mk_box2(0,closure12_SimCodeUtil_extractVarsFromList,tmpMeta36), _simVars);

  tmpMeta38 = mmc_mk_box5(0, _aliasVars2, _globalKnownVars2, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _globalKnownVars2, (modelica_fnptr) mmc_mk_box2(0,closure13_SimCodeUtil_extractVarsFromList,tmpMeta38), _simVars);

  tmpMeta40 = mmc_mk_box5(0, _aliasVars2, _globalKnownVars2, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _localKnownVars2, (modelica_fnptr) mmc_mk_box2(0,closure14_SimCodeUtil_extractVarsFromList,tmpMeta40), _simVars);

  tmpMeta42 = mmc_mk_box5(0, _aliasVars2, _globalKnownVars2, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _aliasVars2, (modelica_fnptr) mmc_mk_box2(0,closure15_SimCodeUtil_extractVarsFromList,tmpMeta42), _simVars);

  tmpMeta44 = mmc_mk_box5(0, _aliasVars2, _globalKnownVars2, _hs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _iterationVars);
  _simVars = omc_BackendVariable_traverseBackendDAEVars(threadData, _extvars2, (modelica_fnptr) mmc_mk_box2(0,closure16_SimCodeUtil_extractVarsFromList,tmpMeta44), _simVars);

  omc_SimCodeUtil_addTempVars(threadData, _simVars, _tempvars);

  omc_SimCodeUtil_sortSimvars(threadData, _simVars);

  if((stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))
  {
    omc_SimCodeUtil_extendIncompleteArray(threadData, _simVars);
  }

  omc_SimCodeUtil_fixIndex(threadData, _simVars);

  omc_SimCodeUtil_setVariableIndex(threadData, _simVars);

  _unitDefinitions = omc_SimCodeUtil_getFmiUnitDefinitions(threadData, _simVars);

  tmpMeta45 = mmc_mk_box(31, 3, &SimCodeVar_SimVars_SIMVARS__desc, arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 1)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 2)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 3)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 4)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 9)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 12)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 19)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 20)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 8)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 11)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 14)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 7)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 10)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 13)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 15)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 16)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 17)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 18)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 21)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 22)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 23)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 24)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 29)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 30)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 5)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 6)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 25)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 26)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 27)), arrayGetNoBoundsChecking(_simVars, ((modelica_integer) 28)));
  _outVars = tmpMeta45;

  omc_GCExt_free(threadData, _simVars);
  _return: OMC_LABEL_UNUSED
  if (out_unitDefinitions) { *out_unitDefinitions = _unitDefinitions; }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getStateInfo(threadData_t *threadData, modelica_integer _idx, modelica_metatype _vars, modelica_metatype _stateInfoIn)
{
  modelica_metatype _stateInfoOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _stateInfoOut has no default value.
  { /* matchcontinue expression */
    {
      modelica_metatype _var = NULL;
      modelica_metatype _kind = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _kind has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_boolean tmp6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          /* Pattern matching succeeded */
          _var = omc_BackendVariable_getVarAt(threadData, _vars, _idx);

          /* Pattern-matching assignment */
          tmp6 = omc_BackendVariable_isStateVar(threadData, _var);
          if (1 /* true */ != tmp6) goto goto_2;

          _kind = omc_BackendVariable_varKind(threadData, _var);
          tmpMeta8 = mmc_mk_box2(0, mmc_mk_integer(_idx), _kind);
          tmpMeta7 = mmc_mk_cons(tmpMeta8, _stateInfoIn);
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          tmpMeta1 = _stateInfoIn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _stateInfoOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _stateInfoOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getStateInfo(threadData_t *threadData, modelica_metatype _idx, modelica_metatype _vars, modelica_metatype _stateInfoIn)
{
  modelica_integer tmp1;
  modelica_metatype _stateInfoOut = NULL;
  tmp1 = mmc_unbox_integer(_idx);
  _stateInfoOut = omc_SimCodeUtil_getStateInfo(threadData, tmp1, _vars, _stateInfoIn);
  /* skip box _stateInfoOut; list<tuple<#Integer, BackendDAE.VarKind>> */
  return _stateInfoOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setVarKindForStates(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _kindIn, modelica_metatype *out_kindOut)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _kindOut = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _kindOut has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      modelica_metatype _var = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          if (1 != tmp8) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _var = omc_BackendVariable_setVarKind(threadData, _inVar, _kindIn);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = _kindIn;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _kindIn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVar = tmpMeta[0+0];
  _kindOut = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_kindOut) { *out_kindOut = _kindOut; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceCrefWithStartValue(threadData_t *threadData, modelica_metatype _expIn, modelica_metatype _varsIn, modelica_metatype *out_varsOut)
{
  modelica_metatype _expOut = NULL;
  modelica_metatype _varsOut = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _expOut has no default value.
  // _varsOut has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _expIn;
    {
      modelica_integer _idx;
      modelica_real _r;
      modelica_metatype _optionExpisASUB = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _exp3 = NULL;
      modelica_metatype _startTime = NULL;
      modelica_metatype _exp1_ = NULL;
      modelica_metatype _exp2_ = NULL;
      modelica_metatype _exp3_ = NULL;
      modelica_metatype _op = NULL;
      modelica_metatype _expLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _idx has no default value.
      // _r has no default value.
      // _optionExpisASUB has no default value.
      // _var has no default value.
      // _cref has no default value.
      // _exp has no default value.
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _exp3 has no default value.
      // _startTime has no default value.
      // _exp1_ has no default value.
      // _exp2_ has no default value.
      // _exp3_ has no default value.
      // _op has no default value.
      // _expLst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 12; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (4 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT519), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _OMC_LIT263;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_boolean tmp9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cref = tmpMeta8;
          tmp4 += 9; /* Pattern matching succeeded; we may skip some cases if we fail */
          _var = omc_BackendVariable_getVarSingle(threadData, _cref, _varsIn, NULL);

          /* Pattern-matching assignment */
          tmp9 = (!omc_SimCodeUtil_artificialVarKind(threadData, omc_BackendVariable_varKind(threadData, _var)));
          if (1 /* true */ != tmp9) goto goto_2;

          if(omc_BackendVariable_varHasBindExp(threadData, _var))
          {
            _exp = omc_BackendVariable_varBindExp(threadData, _var);

            if((((modelica_integer) 0) != omc_ExpressionBasics_compare(threadData, _exp, _expIn)))
            {
              _exp = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp, _varsIn, NULL);
            }
          }
          else
          {
            if(omc_BackendVariable_varHasStartValue(threadData, _var))
            {
              _exp = omc_BackendVariable_varStartValue(threadData, _var);
            }
            else
            {
              _exp = _expIn;
            }
          }

          _exp = (omc_Expression_isConst(threadData, _exp)?_exp:_expIn);
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,1,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          if (6 != MMC_STRLEN(tmpMeta11) || strcmp(MMC_STRINGDATA(_OMC_LIT520), MMC_STRINGDATA(tmpMeta11)) != 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _expLst = tmpMeta12;
          tmp4 += 8; /* Pattern matching succeeded; we may skip some cases if we fail */
          _startTime = listGet(_expLst, ((modelica_integer) 2));

          _startTime = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _startTime, _varsIn, NULL);

          if(omc_Expression_isZero(threadData, _startTime))
          {
            _exp = _OMC_LIT518;
          }
          else
          {
            _exp = _expIn;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _exp1 = tmpMeta13;
          _op = tmpMeta14;
          _exp2 = tmpMeta15;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp1_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp1, _varsIn, NULL);

          _exp2_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp2, _varsIn, NULL);

          if((referenceEq(_exp1, _exp1_) && referenceEq(_exp2, _exp2_)))
          {
            _exp = _expIn;
          }
          else
          {
            tmpMeta16 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, _exp1_, _op, _exp2_);
            _exp = tmpMeta16;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,3) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _exp1 = tmpMeta17;
          _op = tmpMeta18;
          _exp2 = tmpMeta19;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp1_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp1, _varsIn, NULL);

          _exp2_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp2, _varsIn, NULL);

          if((referenceEq(_exp1, _exp1_) && referenceEq(_exp2, _exp2_)))
          {
            _exp = _expIn;
          }
          else
          {
            tmpMeta20 = mmc_mk_box4(12, &DAE_Exp_LBINARY__desc, _exp1_, _op, _exp2_);
            _exp = tmpMeta20;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_real tmp27;
          modelica_boolean tmp28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta21,6,2) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,1,3) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          if (4 != MMC_STRLEN(tmpMeta23) || strcmp(MMC_STRINGDATA(_OMC_LIT519), MMC_STRINGDATA(tmpMeta23)) != 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,27,1) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,1,1) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          tmp27 = mmc_unbox_real(tmpMeta26);
          
          _r = tmp27  /* pattern as ty=Real */;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp28 = (_r <= 0.0);
          if (1 /* true */ != tmp28) goto goto_2;
          tmpMeta[0+0] = _expIn;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_real tmp35;
          modelica_boolean tmp36;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,6,2) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,1,3) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          if (4 != MMC_STRLEN(tmpMeta31) || strcmp(MMC_STRINGDATA(_OMC_LIT519), MMC_STRINGDATA(tmpMeta31)) != 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,28,1) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta33,1,1) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmp35 = mmc_unbox_real(tmpMeta34);
          
          _r = tmp35  /* pattern as ty=Real */;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp36 = (_r <= 0.0);
          if (1 /* true */ != tmp36) goto goto_2;
          tmpMeta[0+0] = _expIn;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_real tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_boolean tmp44;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,1,1) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          tmp39 = mmc_unbox_real(tmpMeta38);
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,25,1) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta41,6,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta42,1,3) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          if (4 != MMC_STRLEN(tmpMeta43) || strcmp(MMC_STRINGDATA(_OMC_LIT519), MMC_STRINGDATA(tmpMeta43)) != 0) goto tmp3_end;
          
          _r = tmp39  /* pattern as ty=Real */;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp44 = (_r <= 0.0);
          if (1 /* true */ != tmp44) goto goto_2;
          tmpMeta[0+0] = _expIn;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_real tmp47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_boolean tmp52;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta45,1,1) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 2));
          tmp47 = mmc_unbox_real(tmpMeta46);
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta48,26,1) == 0) goto tmp3_end;
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta49,6,2) == 0) goto tmp3_end;
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta50,1,3) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta50), 2));
          if (4 != MMC_STRLEN(tmpMeta51) || strcmp(MMC_STRINGDATA(_OMC_LIT519), MMC_STRINGDATA(tmpMeta51)) != 0) goto tmp3_end;
          
          _r = tmp47  /* pattern as ty=Real */;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp52 = (_r <= 0.0);
          if (1 /* true */ != tmp52) goto goto_2;
          tmpMeta[0+0] = _expIn;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_integer tmp57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp57 = mmc_unbox_integer(tmpMeta56);
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _exp1 = tmpMeta53;
          _op = tmpMeta54;
          _exp2 = tmpMeta55;
          _idx = tmp57  /* pattern as ty=Integer */;
          _optionExpisASUB = tmpMeta58;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp1_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp1, _varsIn, NULL);

          _exp2_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp2, _varsIn, NULL);

          if((referenceEq(_exp1, _exp1_) && referenceEq(_exp2, _exp2_)))
          {
            _exp = _expIn;
          }
          else
          {
            tmpMeta59 = mmc_mk_box6(14, &DAE_Exp_RELATION__desc, _exp1_, _op, _exp2_, mmc_mk_integer(_idx), _optionExpisASUB);
            _exp = tmpMeta59;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _exp1 = tmpMeta60;
          _exp2 = tmpMeta61;
          _exp3 = tmpMeta62;
          /* Pattern matching succeeded */
          _exp1_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp1, _varsIn, NULL);

          _exp2_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp2, _varsIn, NULL);

          _exp3_ = omc_SimCodeUtil_replaceCrefWithStartValue(threadData, _exp3, _varsIn, NULL);

          if(((referenceEq(_exp1, _exp1_) && referenceEq(_exp2, _exp2_)) && referenceEq(_exp3, _exp3_)))
          {
            _exp = _expIn;
          }
          else
          {
            tmpMeta63 = mmc_mk_box4(15, &DAE_Exp_IFEXP__desc, _exp1_, _exp2_, _exp3_);
            _exp = tmpMeta63;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        case 11: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _expIn;
          tmpMeta[0+1] = _varsIn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 12) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _expOut = tmpMeta[0+0];
  _varsOut = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_varsOut) { *out_varsOut = _varsOut; }
  return _expOut;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_artificialVarKind(threadData_t *threadData, modelica_metatype _inVarKind)
{
  modelica_boolean _isVar;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isVar has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVarKind;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 10: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 11: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 9: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 22: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 7: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _isVar = tmp1;
  _return: OMC_LABEL_UNUSED
  return _isVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_artificialVarKind(threadData_t *threadData, modelica_metatype _inVarKind)
{
  modelica_boolean _isVar;
  modelica_metatype out_isVar;
  _isVar = omc_SimCodeUtil_artificialVarKind(threadData, _inVarKind);
  out_isVar = mmc_mk_icon(_isVar);
  return out_isVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_preCalculateStartValues1(threadData_t *threadData, modelica_metatype _eqIndexes, modelica_metatype _m, modelica_metatype _mT, modelica_metatype _varMap, modelica_metatype _eqs, modelica_metatype _varsIn)
{
  modelica_metatype _varArr = NULL;
  modelica_integer _eqIdx;
  modelica_integer _varIdx;
  modelica_integer _varIdx0;
  modelica_metatype _rest = NULL;
  modelica_metatype _newEqIdcs = NULL;
  modelica_metatype _workList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _mEntries = NULL;
  modelica_metatype _eq = NULL;
  modelica_metatype _eqArr = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype _eqLst = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _lhs = NULL;
  modelica_metatype _rhs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _varArr = _varsIn;
  // _eqIdx has no default value.
  // _varIdx has no default value.
  // _varIdx0 has no default value.
  // _rest has no default value.
  // _newEqIdcs has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _workList = tmpMeta1;
  // _mEntries has no default value.
  // _eq has no default value.
  // _eqArr has no default value.
  // _var has no default value.
  // _eqLst has no default value.
  // _cref has no default value.
  // _lhs has no default value.
  // _rhs has no default value.
  _rest = _eqIndexes;

  while(1)
  {
    if(!((!listEmpty(_rest)) || (!listEmpty(_workList)))) break;
    if(listEmpty(_rest))
    {
      _rest = listReverseInPlace(_workList);

      tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
      _workList = tmpMeta2;
    }

    /* Pattern-matching assignment */
    tmpMeta3 = _rest;
    if (listEmpty(tmpMeta3)) MMC_THROW_INTERNAL();
    tmpMeta4 = MMC_CAR(tmpMeta3);
    tmpMeta5 = MMC_CDR(tmpMeta3);
    tmp6 = mmc_unbox_integer(tmpMeta4);
    _eqIdx = tmp6  /* pattern as ty=Integer */;
    _rest = tmpMeta5;

    { /* matchcontinue expression */
      {
        volatile mmc_switch_type tmp9;
        int tmp10;
        tmp9 = 0;
        MMC_TRY_INTERNAL(mmc_jumper)
        tmp8_top:
        threadData->mmc_jumper = &new_mmc_jumper;
        for (; tmp9 < 2; tmp9++) {
          switch (MMC_SWITCH_CAST(tmp9)) {
          case 0: {
            modelica_metatype tmpMeta11;
            modelica_metatype tmpMeta12;
            modelica_metatype tmpMeta13;
            modelica_integer tmp14;
            modelica_metatype tmpMeta15;
            modelica_metatype tmpMeta16;
            modelica_boolean tmp17;
            modelica_metatype tmpMeta18;
            /* Pattern matching succeeded */
            /* Pattern-matching assignment */
            tmpMeta11 = arrayGet(_m, _eqIdx);
            if (listEmpty(tmpMeta11)) goto goto_7;
            tmpMeta12 = MMC_CAR(tmpMeta11);
            tmpMeta13 = MMC_CDR(tmpMeta11);
            tmp14 = mmc_unbox_integer(tmpMeta12);
            if (!listEmpty(tmpMeta13)) goto goto_7;
            _varIdx0 = tmp14  /* pattern as ty=Integer */;

            _varIdx = mmc_unbox_integer(arrayGet(_varMap, labs(_varIdx0)));

            _var = omc_BackendVariable_getVarAt(threadData, _varArr, _varIdx);

            _cref = omc_BackendVariable_varCref(threadData, _var);

            _eq = omc_BackendEquation_get(threadData, _eqs, _eqIdx);

            _rhs = omc_BackendEquation_getEquationRHS(threadData, _eq);

            _lhs = omc_BackendEquation_getEquationLHS(threadData, _eq);

            /* Pattern-matching tuple assignment */
            tmpMeta16 = omc_ExpressionSolve_solve(threadData, _lhs, _rhs, omc_Expression_crefExp(threadData, _cref), mmc_mk_none(), &tmpMeta15);
            _rhs = tmpMeta16;
            if (!listEmpty(tmpMeta15)) goto goto_7;

            /* Pattern-matching assignment */
            tmp17 = omc_Expression_isScalarConst(threadData, _rhs);
            if (1 /* true */ != tmp17) goto goto_7;

            _var = omc_BackendVariable_setVarStartValue(threadData, _var, _rhs);

            _varArr = omc_BackendVariable_setVarAt(threadData, _varArr, _varIdx, _var);

            _newEqIdcs = arrayGet(_mT, _varIdx0);

            _newEqIdcs = omc_List_deleteMemberOnTrue(threadData, mmc_mk_integer(_eqIdx), _newEqIdcs, boxvar_intEq, NULL);

            _workList = omc_List_append__reverse(threadData, _newEqIdcs, _workList);

            _eqLst = omc_List_map1r(threadData, _newEqIdcs, boxvar_BackendEquation_get, _eqs);

            _eqLst = omc_BackendEquation_traverseExpsOfEquationList(threadData, _eqLst, boxvar_SimCodeUtil_replaceCrefWithStartValue, _varArr, NULL);

            _eqArr = omc_List_threadFold(threadData, _newEqIdcs, _eqLst, boxvar_BackendEquation_setAtIndexFirst, _eqs);

            _mEntries = omc_List_map1(threadData, _newEqIdcs, boxvar_Array_getIndexFirst, _m);

            {
              modelica_metatype __omcQ_24tmpVar47;
              modelica_metatype* tmp19;
              modelica_metatype tmpMeta20;
              modelica_metatype __omcQ_24tmpVar46;
              modelica_integer tmp21;
              modelica_metatype _e_loopVar = 0;
              modelica_metatype _e;
              _e_loopVar = _mEntries;
              tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
              __omcQ_24tmpVar47 = tmpMeta20; /* defaultValue */
              tmp19 = &__omcQ_24tmpVar47;
              while(1) {
                tmp21 = 1;
                if (!listEmpty(_e_loopVar)) {
                  _e = MMC_CAR(_e_loopVar);
                  _e_loopVar = MMC_CDR(_e_loopVar);
                  tmp21--;
                }
                if (tmp21 == 0) {
                  __omcQ_24tmpVar46 = omc_List_deleteMemberOnTrue(threadData, mmc_mk_integer(_varIdx0), _e, boxvar_intEq, NULL);
                  *tmp19 = mmc_mk_cons(__omcQ_24tmpVar46,0);
                  tmp19 = &MMC_CDR(*tmp19);
                } else if (tmp21 == 1) {
                  break;
                } else {
                  goto goto_7;
                }
              }
              *tmp19 = mmc_mk_nil();
              tmpMeta18 = __omcQ_24tmpVar47;
            }
            _mEntries = tmpMeta18;

            omc_List_threadMap1__0(threadData, _newEqIdcs, _mEntries, boxvar_Array_updateIndexFirst, _m);
            goto tmp8_done;
          }
          case 1: {
            /* Pattern matching succeeded */
            goto tmp8_done;
          }
          }
          goto tmp8_end;
          tmp8_end: ;
        }
        goto goto_7;
        tmp8_done:
        (void)tmp9;
        MMC_RESTORE_INTERNAL(mmc_jumper);
        goto tmp8_done2;
        goto_7:;
        MMC_CATCH_INTERNAL(mmc_jumper);
        if (++tmp9 < 2) {
          goto tmp8_top;
        }
        MMC_THROW_INTERNAL();
        tmp8_done2:;
      }
    }
    ;
  }
  _return: OMC_LABEL_UNUSED
  return _varArr;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_preCalculateStartValues(threadData_t *threadData, modelica_metatype _systIn, modelica_metatype _globalKnownVars, modelica_metatype _shared)
{
  modelica_metatype _systOut = NULL;
  modelica_metatype _varMap = NULL;
  modelica_metatype _varMapArr = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _vars1 = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _mStart = NULL;
  modelica_metatype _mTStart = NULL;
  modelica_metatype _syst = NULL;
  modelica_metatype _varLst = NULL;
  modelica_metatype _noStartVarLst = NULL;
  modelica_metatype _stateInfo = NULL;
  modelica_metatype _stateIdcs = NULL;
  modelica_metatype _stateKinds = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _systOut has no default value.
  // _varMap has no default value.
  // _varMapArr has no default value.
  // _vars has no default value.
  // _vars1 has no default value.
  // _eqs has no default value.
  // _mStart has no default value.
  // _mTStart has no default value.
  // _syst has no default value.
  // _varLst has no default value.
  // _noStartVarLst has no default value.
  // _stateInfo has no default value.
  // _stateIdcs has no default value.
  // _stateKinds has no default value.
  _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_systIn), 2)));

  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _stateInfo = omc_List_fold1(threadData, omc_List_intRange(threadData, omc_BackendVariable_varsSize(threadData, _vars)), boxvar_SimCodeUtil_getStateInfo, _vars, tmpMeta1);

  _vars = omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _vars, boxvar_SimCodeUtil_setVarKindForStates, _OMC_LIT87, NULL);

  _varLst = omc_BackendVariable_varList(threadData, _vars);

  _varMap = omc_List_intRange(threadData, omc_BackendVariable_varsSize(threadData, _vars));

  _noStartVarLst = omc_List_filterOnTrueSync(threadData, _varLst, boxvar_BackendVariable_varHasNoStartValue, _varMap ,&_varMap);

  _eqs = omc_BackendEquation_copyEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_systIn), 3))));

  omc_BackendDAEUtil_traverseBackendDAEExpsEqns(threadData, _eqs, boxvar_SimCodeUtil_replaceCrefWithStartValue, _globalKnownVars);

  omc_BackendDAEUtil_traverseBackendDAEExpsEqns(threadData, _eqs, boxvar_SimCodeUtil_replaceCrefWithStartValue, _vars);

  _vars1 = omc_BackendVariable_listVar1(threadData, _noStartVarLst);

  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _syst = omc_BackendDAEUtil_createEqSystem(threadData, _vars1, _eqs, tmpMeta2, _OMC_LIT521, omc_BackendEquation_emptyEqns(threadData));

  _syst = omc_BackendDAEUtil_getAdjacencyMatrix(threadData, _syst, _OMC_LIT133, mmc_mk_none(), omc_BackendDAEUtil_isInitializationDAE(threadData, _shared) ,&_mStart ,&_mTStart);

  _varMapArr = listArray(_varMap);

  _vars = omc_SimCodeUtil_preCalculateStartValues1(threadData, omc_List_intRange(threadData, arrayLength(_mStart)), _mStart, _mTStart, _varMapArr, _eqs, _vars);

  _stateIdcs = omc_List_map(threadData, _stateInfo, boxvar_Util_tuple21);

  _stateKinds = omc_List_map(threadData, _stateInfo, boxvar_Util_tuple22);

  _vars = omc_List_threadFold(threadData, _stateIdcs, _stateKinds, boxvar_BackendVariable_setVarKindForVar, _vars);

  _vars = omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _vars, boxvar_SimCodeUtil_evaluateStartValues, _shared, NULL);

  _systOut = omc_BackendDAEUtil_setEqSystVars(threadData, _systIn, _vars);
  _return: OMC_LABEL_UNUSED
  return _systOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_evaluateVariableAttributes(threadData_t *threadData, modelica_metatype _attrIn, modelica_metatype _shared)
{
  modelica_metatype _attrOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _attrOut has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _attrIn;
    tmp4_2 = _shared;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _exp_ = NULL;
      modelica_metatype _exps = NULL;
      modelica_metatype _value = NULL;
      modelica_metatype _cache = NULL;
      modelica_metatype _graph = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _exp_ has no default value.
      // _exps has no default value.
      // _value has no default value.
      // _cache has no default value.
      // _graph has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,15) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 10));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 11));
          
          _exp = tmpMeta7;
          _cache = tmpMeta8;
          _graph = tmpMeta9;
          /* Pattern matching succeeded */
          { /* match expression */
            modelica_metatype tmp13_1;
            tmp13_1 = _exp;
            {
              volatile mmc_switch_type tmp13;
              int tmp14;
              tmp13 = 0;
              for (; tmp13 < 3; tmp13++) {
                switch (MMC_SWITCH_CAST(tmp13)) {
                case 0: {
                  modelica_metatype tmpMeta15;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp13_1,13,3) == 0) goto tmp12_end;
                  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 3));
                  
                  _exps = tmpMeta15;
                  /* Pattern matching succeeded */
                  /* Check guard condition after assignments */
                  if (!omc_Expression_isConstWorkList(threadData, _exps)) goto tmp12_end;
                  omc_Ceval_ceval(threadData, _cache, _graph, _exp, 0 /* false */, _OMC_LIT522, ((modelica_integer) 0) ,&_value);
                  tmpMeta10 = omc_ValuesUtil_valueExp(threadData, _value, mmc_mk_none());
                  goto tmp12_done;
                }
                case 1: {
                  modelica_metatype tmpMeta16;
                  modelica_metatype tmpMeta17;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp13_1,21,2) == 0) goto tmp12_end;
                  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 2));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,13,3) == 0) goto tmp12_end;
                  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
                  
                  _exps = tmpMeta17;
                  /* Pattern matching succeeded */
                  /* Check guard condition after assignments */
                  if (!omc_Expression_isConstWorkList(threadData, _exps)) goto tmp12_end;
                  omc_Ceval_ceval(threadData, _cache, _graph, _exp, 0 /* false */, _OMC_LIT522, ((modelica_integer) 0) ,&_value);
                  tmpMeta10 = omc_ValuesUtil_valueExp(threadData, _value, mmc_mk_none());
                  goto tmp12_done;
                }
                case 2: {
                  
                  /* Pattern matching succeeded */
                  tmpMeta10 = _exp;
                  goto tmp12_done;
                }
                }
                goto tmp12_end;
                tmp12_end: ;
              }
              goto goto_11;
              goto_11:;
              goto goto_2;
              goto tmp12_done;
              tmp12_done:;
            }
          }
          _exp_ = tmpMeta10;

          if((!referenceEq(_exp, _exp_)))
          {
            tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(17));
            memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_attrIn), 17*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[7] = mmc_mk_some(_exp);
            _attrIn = tmpMeta18;
          }
          tmpMeta1 = _attrIn;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _attrIn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _attrOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _attrOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_evaluateStartValues(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inShared, modelica_metatype *out_outShared)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outShared has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inShared;
    {
      modelica_metatype _o1 = NULL;
      modelica_metatype _o2 = NULL;
      modelica_metatype _startValue = NULL;
      modelica_metatype _startValue_ = NULL;
      modelica_metatype _exps = NULL;
      modelica_metatype _attr = NULL;
      modelica_metatype _attr_ = NULL;
      modelica_metatype _value = NULL;
      modelica_metatype _cache = NULL;
      modelica_metatype _graph = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _o1 has no default value.
      // _o2 has no default value.
      // _startValue has no default value.
      // _startValue_ has no default value.
      // _exps has no default value.
      // _attr has no default value.
      // _attr_ has no default value.
      // _value has no default value.
      // _cache has no default value.
      // _graph has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 10));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 11));
          
          _o1 = tmpMeta6;
          _o2 = tmpMeta7;
          _cache = tmpMeta8;
          _graph = tmpMeta9;
          /* Pattern matching succeeded */
          if(isSome(_o1))
          {
            _startValue = omc_Util_getOption(threadData, _o1);

            { /* match expression */
              modelica_metatype tmp13_1;
              tmp13_1 = _startValue;
              {
                volatile mmc_switch_type tmp13;
                int tmp14;
                tmp13 = 0;
                for (; tmp13 < 3; tmp13++) {
                  switch (MMC_SWITCH_CAST(tmp13)) {
                  case 0: {
                    modelica_metatype tmpMeta15;
                    if (mmc__uniontype__metarecord__typedef__equal(tmp13_1,13,3) == 0) goto tmp12_end;
                    tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 3));
                    
                    _exps = tmpMeta15;
                    /* Pattern matching succeeded */
                    /* Check guard condition after assignments */
                    if (!omc_Expression_isConstWorkList(threadData, _exps)) goto tmp12_end;
                    omc_Ceval_ceval(threadData, _cache, _graph, _startValue, 0 /* false */, _OMC_LIT522, ((modelica_integer) 0) ,&_value);
                    tmpMeta10 = omc_ValuesUtil_valueExp(threadData, _value, mmc_mk_none());
                    goto tmp12_done;
                  }
                  case 1: {
                    modelica_metatype tmpMeta16;
                    modelica_metatype tmpMeta17;
                    if (mmc__uniontype__metarecord__typedef__equal(tmp13_1,21,2) == 0) goto tmp12_end;
                    tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 2));
                    if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,13,3) == 0) goto tmp12_end;
                    tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
                    
                    _exps = tmpMeta17;
                    /* Pattern matching succeeded */
                    /* Check guard condition after assignments */
                    if (!omc_Expression_isConstWorkList(threadData, _exps)) goto tmp12_end;
                    omc_Ceval_ceval(threadData, _cache, _graph, _startValue, 0 /* false */, _OMC_LIT522, ((modelica_integer) 0) ,&_value);
                    tmpMeta10 = omc_ValuesUtil_valueExp(threadData, _value, mmc_mk_none());
                    goto tmp12_done;
                  }
                  case 2: {
                    
                    /* Pattern matching succeeded */
                    tmpMeta10 = _startValue;
                    goto tmp12_done;
                  }
                  }
                  goto tmp12_end;
                  tmp12_end: ;
                }
                goto goto_11;
                goto_11:;
                goto goto_2;
                goto tmp12_done;
                tmp12_done:;
              }
            }
            _startValue_ = tmpMeta10;

            if((!referenceEq(_startValue, _startValue_)))
            {
              tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(20));
              memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_inVar), 20*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[7] = mmc_mk_some(_startValue_);
              _inVar = tmpMeta18;
            }
          }

          if(isSome(_o2))
          {
            _attr = omc_Util_getOption(threadData, _o2);

            _attr_ = omc_SimCodeUtil_evaluateVariableAttributes(threadData, _attr, _inShared);

            if((!referenceEq(_attr, _attr_)))
            {
              tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(20));
              memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_inVar), 20*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[11] = mmc_mk_some(_attr_);
              _inVar = tmpMeta19;
            }
          }
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inShared;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inShared;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outShared = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isRealInput(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _isReal;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isReal has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 13));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _isReal = tmp1;
  _return: OMC_LABEL_UNUSED
  return _isReal;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isRealInput(threadData_t *threadData, modelica_metatype _var)
{
  modelica_boolean _isReal;
  modelica_metatype out_isReal;
  _isReal = omc_SimCodeUtil_isRealInput(threadData, _var);
  out_isReal = mmc_mk_icon(_isReal);
  return out_isReal;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_getNumberOfRealInputs(threadData_t *threadData, modelica_metatype _inputVars)
{
  modelica_integer _numRealInputs;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _numRealInputs = ((modelica_integer) 0);
  {
    modelica_metatype _var;
    for (tmpMeta1 = _inputVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      if(omc_SimCodeUtil_isRealInput(threadData, _var))
      {
        _numRealInputs = ((modelica_integer) 1) + _numRealInputs;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _numRealInputs;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getNumberOfRealInputs(threadData_t *threadData, modelica_metatype _inputVars)
{
  modelica_integer _numRealInputs;
  modelica_metatype out_numRealInputs;
  _numRealInputs = omc_SimCodeUtil_getNumberOfRealInputs(threadData, _inputVars);
  out_numRealInputs = mmc_mk_icon(_numRealInputs);
  return out_numRealInputs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVarInfo(threadData_t *threadData, modelica_metatype _dlow, modelica_integer _nx, modelica_integer _ny, modelica_integer _ndy, modelica_integer _np, modelica_integer _na, modelica_integer _next, modelica_integer _numOutVars, modelica_integer _numInVars, modelica_integer _ny_int, modelica_integer _np_int, modelica_integer _na_int, modelica_integer _ny_bool, modelica_integer _np_bool, modelica_integer _na_bool, modelica_integer _ny_string, modelica_integer _np_string, modelica_integer _na_string, modelica_integer _numStateSets, modelica_integer _numOptimizeConstraints, modelica_integer _numOptimizeFinalConstraints, modelica_integer _numRealInputVars)
{
  modelica_metatype _varInfo = NULL;
  modelica_integer _numZeroCrossings;
  modelica_integer _numTimeEvents;
  modelica_integer _numRelations;
  modelica_integer _numMathEventFunctions;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _varInfo has no default value.
  // _numZeroCrossings has no default value.
  // _numTimeEvents has no default value.
  // _numRelations has no default value.
  // _numMathEventFunctions has no default value.
  _numZeroCrossings = omc_BackendDAEUtil_numberOfZeroCrossings(threadData, _dlow ,&_numTimeEvents ,&_numRelations ,&_numMathEventFunctions);

  tmpMeta1 = mmc_mk_box(36, 3, &SimCode_VarInfo_VARINFO__desc, mmc_mk_integer(_numZeroCrossings), mmc_mk_integer(_numTimeEvents), mmc_mk_integer(_numRelations), mmc_mk_integer(_numMathEventFunctions), mmc_mk_integer(_nx), mmc_mk_integer(_ny), mmc_mk_integer(_ndy), mmc_mk_integer(_ny_int), mmc_mk_integer(_ny_bool), mmc_mk_integer(_na), mmc_mk_integer(_na_int), mmc_mk_integer(_na_bool), mmc_mk_integer(_np), mmc_mk_integer(_np_int), mmc_mk_integer(_np_bool), mmc_mk_integer(_numOutVars), mmc_mk_integer(_numInVars), mmc_mk_integer(_next), mmc_mk_integer(_ny_string), mmc_mk_integer(_np_string), mmc_mk_integer(_na_string), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(_numStateSets), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(_numOptimizeConstraints), mmc_mk_integer(_numOptimizeFinalConstraints), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(_numRealInputVars), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)));
  _varInfo = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _varInfo;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createVarInfo(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype _nx, modelica_metatype _ny, modelica_metatype _ndy, modelica_metatype _np, modelica_metatype _na, modelica_metatype _next, modelica_metatype _numOutVars, modelica_metatype _numInVars, modelica_metatype _ny_int, modelica_metatype _np_int, modelica_metatype _na_int, modelica_metatype _ny_bool, modelica_metatype _np_bool, modelica_metatype _na_bool, modelica_metatype _ny_string, modelica_metatype _np_string, modelica_metatype _na_string, modelica_metatype _numStateSets, modelica_metatype _numOptimizeConstraints, modelica_metatype _numOptimizeFinalConstraints, modelica_metatype _numRealInputVars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  modelica_integer tmp7;
  modelica_integer tmp8;
  modelica_integer tmp9;
  modelica_integer tmp10;
  modelica_integer tmp11;
  modelica_integer tmp12;
  modelica_integer tmp13;
  modelica_integer tmp14;
  modelica_integer tmp15;
  modelica_integer tmp16;
  modelica_integer tmp17;
  modelica_integer tmp18;
  modelica_integer tmp19;
  modelica_integer tmp20;
  modelica_integer tmp21;
  modelica_metatype _varInfo = NULL;
  tmp1 = mmc_unbox_integer(_nx);
  tmp2 = mmc_unbox_integer(_ny);
  tmp3 = mmc_unbox_integer(_ndy);
  tmp4 = mmc_unbox_integer(_np);
  tmp5 = mmc_unbox_integer(_na);
  tmp6 = mmc_unbox_integer(_next);
  tmp7 = mmc_unbox_integer(_numOutVars);
  tmp8 = mmc_unbox_integer(_numInVars);
  tmp9 = mmc_unbox_integer(_ny_int);
  tmp10 = mmc_unbox_integer(_np_int);
  tmp11 = mmc_unbox_integer(_na_int);
  tmp12 = mmc_unbox_integer(_ny_bool);
  tmp13 = mmc_unbox_integer(_np_bool);
  tmp14 = mmc_unbox_integer(_na_bool);
  tmp15 = mmc_unbox_integer(_ny_string);
  tmp16 = mmc_unbox_integer(_np_string);
  tmp17 = mmc_unbox_integer(_na_string);
  tmp18 = mmc_unbox_integer(_numStateSets);
  tmp19 = mmc_unbox_integer(_numOptimizeConstraints);
  tmp20 = mmc_unbox_integer(_numOptimizeFinalConstraints);
  tmp21 = mmc_unbox_integer(_numRealInputVars);
  _varInfo = omc_SimCodeUtil_createVarInfo(threadData, _dlow, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp18, tmp19, tmp20, tmp21);
  /* skip box _varInfo; SimCode.VarInfo */
  return _varInfo;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createModelInfo(threadData_t *threadData, modelica_metatype _class_, modelica_metatype _program, modelica_metatype _dlow, modelica_metatype _inInitDAE, modelica_metatype _functions, modelica_metatype _labels, modelica_integer _numStateSets, modelica_integer _numSpatialDistributions, modelica_string _fileDir, modelica_integer _nSubClock, modelica_metatype _tempVars)
{
  modelica_metatype _modelInfo = NULL;
  modelica_string _description = NULL;
  modelica_string _directory = NULL;
  modelica_string _version = NULL;
  modelica_string _author = NULL;
  modelica_string _license = NULL;
  modelica_string _copyright = NULL;
  modelica_string _fileName = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _vars = NULL;
  modelica_integer _nx;
  modelica_integer _ny;
  modelica_integer _ndy;
  modelica_integer _np;
  modelica_integer _na;
  modelica_integer _next;
  modelica_integer _numOutVars;
  modelica_integer _numInVars;
  modelica_integer _ny_int;
  modelica_integer _np_int;
  modelica_integer _na_int;
  modelica_integer _ny_bool;
  modelica_integer _np_bool;
  modelica_integer _numOptimizeConstraints;
  modelica_integer _numOptimizeFinalConstraints;
  modelica_integer _numRealInputVars;
  modelica_integer _na_bool;
  modelica_integer _ny_string;
  modelica_integer _np_string;
  modelica_integer _na_string;
  modelica_boolean _hasLargeEqSystems;
  modelica_metatype _unitDefinitions = NULL;
  modelica_boolean _debug;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _modelInfo has no default value.
  // _description has no default value.
  // _directory has no default value.
  // _version has no default value.
  // _author has no default value.
  // _license has no default value.
  // _copyright has no default value.
  // _fileName has no default value.
  // _varInfo has no default value.
  // _vars has no default value.
  // _nx has no default value.
  // _ny has no default value.
  // _ndy has no default value.
  // _np has no default value.
  // _na has no default value.
  // _next has no default value.
  // _numOutVars has no default value.
  // _numInVars has no default value.
  // _ny_int has no default value.
  // _np_int has no default value.
  // _na_int has no default value.
  // _ny_bool has no default value.
  // _np_bool has no default value.
  // _numOptimizeConstraints has no default value.
  // _numOptimizeFinalConstraints has no default value.
  // _numRealInputVars has no default value.
  // _na_bool has no default value.
  // _ny_string has no default value.
  // _np_string has no default value.
  // _na_string has no default value.
  // _hasLargeEqSystems has no default value.
  // _unitDefinitions has no default value.
  _debug = 0 /* false */;
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          /* Pattern matching succeeded */
          _directory = omc_System_trim(threadData, _fileDir, _OMC_LIT33);

          _version = omc_System_trim(threadData, omc_ProgramUtil_getNamedAnnotationExp(threadData, _class_, _program, _OMC_LIT524, _OMC_LIT525, boxvar_ProgramUtil_getDefaultComponentPrefixesModStr), _OMC_LIT33);

          _author = omc_System_trim(threadData, omc_ProgramUtil_getNamedAnnotationExp(threadData, _class_, _program, _OMC_LIT527, _OMC_LIT525, boxvar_ProgramUtil_getDefaultComponentPrefixesModStr), _OMC_LIT33);

          _license = omc_System_trim(threadData, omc_ProgramUtil_getNamedAnnotationExp(threadData, _class_, _program, _OMC_LIT529, _OMC_LIT525, boxvar_ProgramUtil_getDefaultComponentPrefixesModStr), _OMC_LIT33);

          _copyright = omc_System_trim(threadData, omc_ProgramUtil_getNamedAnnotationExp(threadData, _class_, _program, _OMC_LIT531, _OMC_LIT525, boxvar_ProgramUtil_getDefaultComponentPrefixesModStr), _OMC_LIT33);

          _fileName = omc_System_basename(threadData, omc_AbsynUtil_classFilename(threadData, omc_ProgramUtil_getPathedClassInProgram(threadData, _class_, _program, 0 /* false */, 0 /* false */)));

          _vars = omc_SimCodeUtil_createVars(threadData, _dlow, _inInitDAE, _tempVars ,&_unitDefinitions);

          /* Pattern-matching assignment */
          tmpMeta5 = _dlow;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 17));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          _description = tmpMeta8;

          _nx = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 2))));

          _ny = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 4))));

          _ndy = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 5))));

          _ny_int = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 6))));

          _ny_bool = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 7))));

          _numOutVars = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 9))));

          _numInVars = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 8))));

          _na = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 10))));

          _na_int = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 11))));

          _na_bool = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 12))));

          _np = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 13))));

          _np_int = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 14))));

          _np_bool = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 15))));

          _ny_string = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 16))));

          _np_string = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 17))));

          _na_string = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 18))));

          _next = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 19))));

          _numOptimizeConstraints = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 26))));

          _numOptimizeFinalConstraints = omc_SimCodeUtil_getNumScalars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 27))));

          _numRealInputVars = omc_SimCodeUtil_getNumberOfRealInputs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_vars), 8))));

          _varInfo = omc_SimCodeUtil_createVarInfo(threadData, _dlow, _nx, _ny, _ndy, _np, _na, _next, _numOutVars, _numInVars, _ny_int, _np_int, _na_int, _ny_bool, _np_bool, _na_bool, _ny_string, _np_string, _na_string, _numStateSets, _numOptimizeConstraints, _numOptimizeFinalConstraints, _numRealInputVars);

          _hasLargeEqSystems = omc_SimCodeUtil_hasLargeEquationSystems(threadData, _dlow, _inInitDAE);

          tmp10 = (modelica_boolean)omc_Flags_getConfigBool(threadData, _OMC_LIT260);
          if(tmp10)
          {
            tmpMeta11 = omc_SimCodeUtil_getResources(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_program), 2))), _dlow, _inInitDAE);
          }
          else
          {
            tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta11 = tmpMeta9;
          }
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta14 = mmc_mk_box(22, 3, &SimCode_ModelInfo_MODELINFO__desc, _class_, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)))), 17)))), 2))), _version, _author, _license, _copyright, _directory, _fileName, _varInfo, _vars, _functions, _labels, tmpMeta11, omc_List_sort(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_program), 2))), boxvar_AbsynUtil_classNameGreater), mmc_mk_integer(arrayLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)))), 18)))), 2))))), mmc_mk_integer(arrayLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)))), 18)))), 3))))), mmc_mk_integer(((modelica_integer) 1) + _numSpatialDistributions), mmc_mk_boolean(_hasLargeEqSystems), tmpMeta12, tmpMeta13, _unitDefinitions);
          _modelInfo = tmpMeta14;
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT532, _OMC_LIT533);

          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _modelInfo;
}
modelica_metatype boxptr_SimCodeUtil_createModelInfo(threadData_t *threadData, modelica_metatype _class_, modelica_metatype _program, modelica_metatype _dlow, modelica_metatype _inInitDAE, modelica_metatype _functions, modelica_metatype _labels, modelica_metatype _numStateSets, modelica_metatype _numSpatialDistributions, modelica_metatype _fileDir, modelica_metatype _nSubClock, modelica_metatype _tempVars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_metatype _modelInfo = NULL;
  tmp1 = mmc_unbox_integer(_numStateSets);
  tmp2 = mmc_unbox_integer(_numSpatialDistributions);
  tmp3 = mmc_unbox_integer(_nSubClock);
  _modelInfo = omc_SimCodeUtil_createModelInfo(threadData, _class_, _program, _dlow, _inInitDAE, _functions, _labels, tmp1, tmp2, _fileDir, tmp3, _tempVars);
  /* skip box _modelInfo; SimCode.ModelInfo */
  return _modelInfo;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createVarAsserts(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_metatype _outAlgs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outAlgs has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  omc_BackendVariable_getMinMaxAsserts(threadData, _inVar, tmpMeta1 ,&_outAlgs);
  _return: OMC_LABEL_UNUSED
  return _outAlgs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createInitialAssignmentsFromMax(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _initialEquation = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _name = NULL;
      modelica_metatype _maxv = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _av = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _initialEquation has no default value.
      // _eqns has no default value.
      // _name has no default value.
      // _maxv has no default value.
      // _source has no default value.
      // _av has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _var = tmp4_1;
          _name = tmpMeta6;
          _source = tmpMeta7;
          _eqns = tmpMeta8;
          _av = tmpMeta9;
          /* Pattern matching succeeded */
          _maxv = omc_BackendVariable_varMaxValueFail(threadData, _var);

          /* Pattern-matching assignment */
          tmp10 = omc_Expression_isConst(threadData, _maxv);
          if (0 /* false */ != tmp10) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta11 = omc_SimCodeUtil_getAliasVar(threadData, _var, mmc_mk_some(_av));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,0,0) == 0) goto goto_2;

          tmpMeta12 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _name, _maxv, _source, _OMC_LIT535);
          _initialEquation = tmpMeta12;
          tmpMeta13 = mmc_mk_cons(_initialEquation, _eqns);
          tmpMeta14 = mmc_mk_box2(0, tmpMeta13, _av);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createInitialAssignmentsFromMin(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _initialEquation = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _name = NULL;
      modelica_metatype _minv = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _av = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _initialEquation has no default value.
      // _eqns has no default value.
      // _name has no default value.
      // _minv has no default value.
      // _source has no default value.
      // _av has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _var = tmp4_1;
          _name = tmpMeta6;
          _source = tmpMeta7;
          _eqns = tmpMeta8;
          _av = tmpMeta9;
          /* Pattern matching succeeded */
          _minv = omc_BackendVariable_varMinValueFail(threadData, _var);

          /* Pattern-matching assignment */
          tmp10 = omc_Expression_isConst(threadData, _minv);
          if (0 /* false */ != tmp10) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta11 = omc_SimCodeUtil_getAliasVar(threadData, _var, mmc_mk_some(_av));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,0,0) == 0) goto goto_2;

          tmpMeta12 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _name, _minv, _source, _OMC_LIT535);
          _initialEquation = tmpMeta12;
          tmpMeta13 = mmc_mk_cons(_initialEquation, _eqns);
          tmpMeta14 = mmc_mk_box2(0, tmpMeta13, _av);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createInitialAssignmentsFromNominal(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _initialEquation = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _name = NULL;
      modelica_metatype _nominalv = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _av = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _initialEquation has no default value.
      // _eqns has no default value.
      // _name has no default value.
      // _nominalv has no default value.
      // _source has no default value.
      // _av has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _var = tmp4_1;
          _name = tmpMeta6;
          _source = tmpMeta7;
          _eqns = tmpMeta8;
          _av = tmpMeta9;
          /* Pattern matching succeeded */
          _nominalv = omc_BackendVariable_varNominalValueFail(threadData, _var);

          /* Pattern-matching assignment */
          tmp10 = omc_Expression_isConst(threadData, _nominalv);
          if (0 /* false */ != tmp10) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta11 = omc_SimCodeUtil_getAliasVar(threadData, _var, mmc_mk_some(_av));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,0,0) == 0) goto goto_2;

          tmpMeta12 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _name, _nominalv, _source, _OMC_LIT535);
          _initialEquation = tmpMeta12;
          tmpMeta13 = mmc_mk_cons(_initialEquation, _eqns);
          tmpMeta14 = mmc_mk_box2(0, tmpMeta13, _av);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createInitialAssignmentsFromStart(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _initialEquation = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _startExp = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _av = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _parameters = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _initialEquation has no default value.
      // _eqns has no default value.
      // _cref has no default value.
      // _startExp has no default value.
      // _source has no default value.
      // _av has no default value.
      // _globalKnownVars has no default value.
      // _parameters has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_boolean tmp11;
          modelica_boolean tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _var = tmp4_1;
          _cref = tmpMeta6;
          _source = tmpMeta7;
          _eqns = tmpMeta8;
          _av = tmpMeta9;
          _globalKnownVars = tmpMeta10;
          /* Pattern matching succeeded */
          _startExp = omc_BackendVariable_varStartValueFail(threadData, _var);

          _parameters = omc_Expression_getAllCrefs(threadData, _startExp);

          /* Pattern-matching assignment */
          tmp11 = omc_BackendVariable_areAllCrefsPrimaryParameters(threadData, _parameters, _globalKnownVars);
          if (1 /* true */ != tmp11) goto goto_2;

          /* Pattern-matching assignment */
          tmp12 = omc_Expression_isConst(threadData, _startExp);
          if (0 /* false */ != tmp12) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta13 = omc_SimCodeUtil_getAliasVar(threadData, _var, mmc_mk_some(_av));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,0,0) == 0) goto goto_2;

          tmpMeta14 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, omc_ComponentReference_crefPrefixStart(threadData, _cref), _startExp, _source, _OMC_LIT537);
          _initialEquation = tmpMeta14;
          tmpMeta15 = mmc_mk_cons(_initialEquation, _eqns);
          tmpMeta16 = mmc_mk_box3(0, tmpMeta15, _av, _globalKnownVars);
          tmpMeta[0+0] = _var;
          tmpMeta[0+1] = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSimEqsForGlobalKnownVars(threadData_t *threadData, modelica_metatype __omcQ_24in_5FglobalKnownVar, modelica_metatype _inTuple, modelica_metatype *out_outTuple)
{
  modelica_metatype _globalKnownVar = NULL;
  modelica_metatype _outTuple = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_integer _nFixedParameters;
  modelica_metatype _simEq = NULL;
  modelica_metatype _parameterEquations = NULL;
  modelica_metatype _varasserts = NULL;
  modelica_metatype _varasserts2 = NULL;
  modelica_metatype _tplExpHT = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta30;
  modelica_metatype tmpMeta31;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _globalKnownVar = __omcQ_24in_5FglobalKnownVar;
  // _outTuple has no default value.
  // _uniqueEqIndex has no default value.
  // _nFixedParameters has no default value.
  // _simEq has no default value.
  // _parameterEquations has no default value.
  // _varasserts has no default value.
  // _varasserts2 has no default value.
  // _tplExpHT has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTuple;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  _uniqueEqIndex = tmp3  /* pattern as ty=Integer */;
  _parameterEquations = tmpMeta4;
  _varasserts = tmpMeta5;
  _nFixedParameters = tmp7  /* pattern as ty=Integer */;
  _tplExpHT = tmpMeta8;

  if((omc_BackendVariable_isParam(threadData, _globalKnownVar) && omc_BackendVariable_varFixed(threadData, _globalKnownVar)))
  {
    _varasserts2 = omc_SimCodeUtil_createVarAsserts(threadData, _globalKnownVar);

    _varasserts = omc_List_append__reverse(threadData, _varasserts2, _varasserts);

    _nFixedParameters = ((modelica_integer) 1) + _nFixedParameters;
  }

  if((((omc_BackendVariable_isParam(threadData, _globalKnownVar) && ((omc_BackendVariable_varFixed(threadData, _globalKnownVar) && (omc_BackendVariable_isFinalOrProtectedVar(threadData, _globalKnownVar) || omc_BackendVariable_varHasNonConstantBindExpOrStartValue(threadData, _globalKnownVar))) || (omc_BackendVariable_varHasStartValue(threadData, _globalKnownVar) && (!omc_BackendVariable_varHasConstantStartExp(threadData, _globalKnownVar))))) || ((omc_BackendVariable_isVarAlg(threadData, _globalKnownVar) && (!omc_BackendVariable_isInput(threadData, _globalKnownVar))) && omc_BackendVariable_varFixed(threadData, _globalKnownVar))) || ((omc_BackendVariable_isExtObj(threadData, _globalKnownVar) && omc_BackendVariable_varHasBindExp(threadData, _globalKnownVar)) && omc_BackendVariable_varFixed(threadData, _globalKnownVar))))
  {
    { /* match expression */
      modelica_metatype tmp11_1;
      tmp11_1 = _globalKnownVar;
      {
        modelica_metatype _call = NULL;
        modelica_metatype _tplExp = NULL;
        modelica_metatype _rec = NULL;
        modelica_metatype _source = NULL;
        modelica_metatype _expl = NULL;
        modelica_metatype _tp = NULL;
        volatile mmc_switch_type tmp11;
        int tmp12;
        // _call has no default value.
        // _tplExp has no default value.
        // _rec has no default value.
        // _source has no default value.
        // _expl has no default value.
        // _tp has no default value.
        tmp11 = 0;
        for (; tmp11 < 3; tmp11++) {
          switch (MMC_SWITCH_CAST(tmp11)) {
          case 0: {
            modelica_metatype tmpMeta13;
            modelica_metatype tmpMeta14;
            modelica_metatype tmpMeta15;
            modelica_metatype tmpMeta16;
            modelica_metatype tmpMeta17;
            modelica_metatype tmpMeta18;
            modelica_metatype tmpMeta19;
            modelica_metatype tmpMeta20;
            modelica_metatype tmpMeta21;
            tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 8));
            if (optionNone(tmpMeta13)) goto tmp10_end;
            tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,19,1) == 0) goto tmp10_end;
            tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
            
            _tplExp = tmpMeta14;
            _expl = tmpMeta15;
            /* Pattern matching succeeded */
            if(omc_BaseHashSet_has(threadData, _tplExp, _tplExpHT))
            {
              tmpMeta16 = mmc_mk_box5(0, mmc_mk_integer(_uniqueEqIndex), _parameterEquations, _varasserts, mmc_mk_integer(_nFixedParameters), _tplExpHT);
              _outTuple = tmpMeta16;

              goto _return;
            }
            else
            {
              _tp = omc_Expression_typeof(threadData, _tplExp);

              /* Pattern-matching assignment */
              tmpMeta17 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_globalKnownVar), 7)));
              if (optionNone(tmpMeta17)) goto goto_9;
              tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 1));
              _call = tmpMeta18;

              _source = omc_BackendVariable_getVarSource(threadData, _globalKnownVar);

              tmpMeta20 = mmc_mk_box5(4, &DAE_Statement_STMT__TUPLE__ASSIGN__desc, _tp, _expl, _call, _source);
              tmpMeta19 = mmc_mk_cons(tmpMeta20, MMC_REFSTRUCTLIT(mmc_nil));
              tmpMeta21 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_uniqueEqIndex), tmpMeta19, _OMC_LIT535);
              _simEq = tmpMeta21;

              _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;

              _tplExpHT = omc_BaseHashSet_add(threadData, _tplExp, _tplExpHT);
            }
            goto tmp10_done;
          }
          case 1: {
            modelica_metatype tmpMeta22;
            modelica_metatype tmpMeta23;
            modelica_metatype tmpMeta24;
            modelica_metatype tmpMeta25;
            modelica_metatype tmpMeta26;
            modelica_metatype tmpMeta27;
            modelica_metatype tmpMeta28;
            modelica_metatype tmpMeta29;
            tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 8));
            if (optionNone(tmpMeta22)) goto tmp10_end;
            tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
            
            _rec = tmpMeta23;
            /* Pattern matching succeeded */
            if(omc_BaseHashSet_has(threadData, _rec, _tplExpHT))
            {
              tmpMeta24 = mmc_mk_box5(0, mmc_mk_integer(_uniqueEqIndex), _parameterEquations, _varasserts, mmc_mk_integer(_nFixedParameters), _tplExpHT);
              _outTuple = tmpMeta24;

              goto _return;
            }
            else
            {
              _tp = omc_Expression_typeof(threadData, _rec);

              /* Pattern-matching assignment */
              tmpMeta25 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_globalKnownVar), 7)));
              if (optionNone(tmpMeta25)) goto goto_9;
              tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 1));
              _call = tmpMeta26;

              _source = omc_BackendVariable_getVarSource(threadData, _globalKnownVar);

              tmpMeta28 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _rec, _call, _source);
              tmpMeta27 = mmc_mk_cons(tmpMeta28, MMC_REFSTRUCTLIT(mmc_nil));
              tmpMeta29 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_uniqueEqIndex), tmpMeta27, _OMC_LIT535);
              _simEq = tmpMeta29;

              _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;

              _tplExpHT = omc_BaseHashSet_add(threadData, _rec, _tplExpHT);
            }
            goto tmp10_done;
          }
          case 2: {
            
            /* Pattern matching succeeded */
            _simEq = omc_SimCodeUtil_makeSolved__fromStartValue(threadData, _globalKnownVar, _uniqueEqIndex ,&_uniqueEqIndex);
            goto tmp10_done;
          }
          }
          goto tmp10_end;
          tmp10_end: ;
        }
        goto goto_9;
        goto_9:;
        MMC_THROW_INTERNAL();
        goto tmp10_done;
        tmp10_done:;
      }
    }
    ;

    tmpMeta30 = mmc_mk_cons(_simEq, _parameterEquations);
    _parameterEquations = tmpMeta30;
  }

  tmpMeta31 = mmc_mk_box5(0, mmc_mk_integer(_uniqueEqIndex), _parameterEquations, _varasserts, mmc_mk_integer(_nFixedParameters), _tplExpHT);
  _outTuple = tmpMeta31;
  _return: OMC_LABEL_UNUSED
  if (out_outTuple) { *out_outTuple = _outTuple; }
  return _globalKnownVar;
}

DLLDirection
modelica_integer omc_SimCodeUtil_createParameterEquations(threadData_t *threadData, modelica_integer _inUniqueEqIndex, modelica_metatype _acc, modelica_metatype _globalKnownVars, modelica_metatype *out_outParameterEquations, modelica_integer *out_nFixedParameters)
{
  modelica_integer _outUniqueEqIndex;
  modelica_metatype _outParameterEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _nFixedParameters;
  modelica_metatype _simvarasserts = NULL;
  modelica_metatype _varasserts = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_integer tmp16;
  modelica_metatype tmpMeta17;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outUniqueEqIndex = _inUniqueEqIndex;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outParameterEquations = tmpMeta1;
  // _nFixedParameters has no default value.
  // _simvarasserts has no default value.
  // _varasserts has no default value.
  /* Pattern-matching assignment */
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta3 = mmc_mk_box5(0, mmc_mk_integer(_outUniqueEqIndex), _outParameterEquations, tmpMeta2, mmc_mk_integer(((modelica_integer) 0)), omc_HashSetExp_emptyHashSetSized(threadData, omc_Util_nextPrime(threadData, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_globalKnownVars), 5)))))));
  tmpMeta4 = omc_BackendVariable_traverseBackendDAEVars(threadData, _globalKnownVars, boxvar_SimCodeUtil_createSimEqsForGlobalKnownVars, tmpMeta3);
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmp6 = mmc_unbox_integer(tmpMeta5);
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 3));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 4));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  _outUniqueEqIndex = tmp6  /* pattern as ty=Integer */;
  _outParameterEquations = tmpMeta7;
  _varasserts = tmpMeta8;
  _nFixedParameters = tmp10  /* pattern as ty=Integer */;

  if(omc_Flags_isSet(threadData, _OMC_LIT541))
  {
    tmpMeta11 = stringAppend(_OMC_LIT538,intString(listLength(_outParameterEquations)));
    tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT47);
    tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT122);
    tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT48);
    fputs(MMC_STRINGDATA(tmpMeta14),stdout);

    omc_SimCodeUtil_dumpSimEqSystemLst(threadData, listReverse(_outParameterEquations), _OMC_LIT48);

    fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);
  }

  _varasserts = listReverseInPlace(_varasserts);

  /* Pattern-matching tuple assignment */
  tmpMeta17 = omc_List_mapFold(threadData, _varasserts, boxvar_SimCodeUtil_dlowAlgToSimEqSystem, mmc_mk_integer(_outUniqueEqIndex), &tmpMeta15);
  _simvarasserts = tmpMeta17;
  tmp16 = mmc_unbox_integer(tmpMeta15);
  _outUniqueEqIndex = tmp16  /* pattern as ty=Integer */;

  _outParameterEquations = omc_List_append__reverse(threadData, _simvarasserts, _outParameterEquations);

  _outParameterEquations = omc_List_append__reverse(threadData, _acc, _outParameterEquations);

  _outParameterEquations = listReverse(_outParameterEquations);
  _return: OMC_LABEL_UNUSED
  if (out_outParameterEquations) { *out_outParameterEquations = _outParameterEquations; }
  if (out_nFixedParameters) { *out_nFixedParameters = _nFixedParameters; }
  return _outUniqueEqIndex;
}
modelica_metatype boxptr_SimCodeUtil_createParameterEquations(threadData_t *threadData, modelica_metatype _inUniqueEqIndex, modelica_metatype _acc, modelica_metatype _globalKnownVars, modelica_metatype *out_outParameterEquations, modelica_metatype *out_nFixedParameters)
{
  modelica_integer tmp1;
  modelica_integer _nFixedParameters;
  modelica_integer _outUniqueEqIndex;
  modelica_metatype out_outUniqueEqIndex;
  tmp1 = mmc_unbox_integer(_inUniqueEqIndex);
  _outUniqueEqIndex = omc_SimCodeUtil_createParameterEquations(threadData, tmp1, _acc, _globalKnownVars, out_outParameterEquations, &_nFixedParameters);
  out_outUniqueEqIndex = mmc_mk_icon(_outUniqueEqIndex);
  /* skip box _outParameterEquations; list<SimCode.SimEqSystem> */
  if (out_nFixedParameters) { *out_nFixedParameters = mmc_mk_icon(_nFixedParameters); }
  return out_outUniqueEqIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolved__fromStartValue(threadData_t *threadData, modelica_metatype _inVar, modelica_integer _inUniqueEqIndex, modelica_integer *out_outUniqueEqIndex)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_integer _outUniqueEqIndex;
  modelica_metatype _e = NULL;
  modelica_metatype _varExp = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype _source = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqn has no default value.
  // _outUniqueEqIndex has no default value.
  // _e has no default value.
  // _varExp has no default value.
  // _cr has no default value.
  // _source has no default value.
  _e = omc_BackendVariable_varBindExpStartValueNoFail(threadData, _inVar);

  _source = omc_BackendVariable_getVarSource(threadData, _inVar);

  if(omc_Types_isArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 6)))))
  {
    _varExp = omc_BackendVariable_varExp(threadData, _inVar);

    tmpMeta1 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_inUniqueEqIndex), _varExp, _e, _source, _OMC_LIT535);
    _outSimEqn = tmpMeta1;
  }
  else
  {
    _cr = omc_BackendVariable_varCref(threadData, _inVar);

    tmpMeta2 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_inUniqueEqIndex), _cr, _e, _source, _OMC_LIT535);
    _outSimEqn = tmpMeta2;
  }

  _outUniqueEqIndex = ((modelica_integer) 1) + _inUniqueEqIndex;
  _return: OMC_LABEL_UNUSED
  if (out_outUniqueEqIndex) { *out_outUniqueEqIndex = _outUniqueEqIndex; }
  return _outSimEqn;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolved__fromStartValue(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inUniqueEqIndex, modelica_metatype *out_outUniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _outUniqueEqIndex;
  modelica_metatype _outSimEqn = NULL;
  tmp1 = mmc_unbox_integer(_inUniqueEqIndex);
  _outSimEqn = omc_SimCodeUtil_makeSolved__fromStartValue(threadData, _inVar, tmp1, &_outUniqueEqIndex);
  /* skip box _outSimEqn; SimCode.SimEqSystem */
  if (out_outUniqueEqIndex) { *out_outUniqueEqIndex = mmc_mk_icon(_outUniqueEqIndex); }
  return _outSimEqn;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createMaxValueEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _maxValueEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _maxValueEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _syst;
    tmp4_2 = _shared;
    tmp4_3 = _acc;
    {
      modelica_metatype _maxValueEquationsTmp = NULL;
      modelica_metatype _simeqns = NULL;
      modelica_metatype _simeqns1 = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _maxValueEquationsTmp has no default value.
      // _simeqns has no default value.
      // _simeqns1 has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
          _simeqns = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box2(0, tmpMeta9, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 5))));
          tmpMeta11 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), boxvar_SimCodeUtil_createInitialAssignmentsFromMax, tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          _maxValueEquationsTmp = tmpMeta12;

          _maxValueEquationsTmp = listReverse(_maxValueEquationsTmp);

          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_List_mapFold(threadData, _maxValueEquationsTmp, boxvar_SimCodeUtil_dlowEqToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta13);
          _simeqns1 = tmpMeta15;
          tmp14 = mmc_unbox_integer(tmpMeta13);
          _uniqueEqIndex = tmp14  /* pattern as ty=Integer */;
          tmpMeta16 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_simeqns1, _simeqns));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT542, _OMC_LIT543);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _maxValueEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _maxValueEquations;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createMinValueEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _minValueEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _minValueEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _syst;
    tmp4_2 = _shared;
    tmp4_3 = _acc;
    {
      modelica_metatype _minValueEquationsTmp = NULL;
      modelica_metatype _simeqns = NULL;
      modelica_metatype _simeqns1 = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _minValueEquationsTmp has no default value.
      // _simeqns has no default value.
      // _simeqns1 has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
          _simeqns = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box2(0, tmpMeta9, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 5))));
          tmpMeta11 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), boxvar_SimCodeUtil_createInitialAssignmentsFromMin, tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          _minValueEquationsTmp = tmpMeta12;

          _minValueEquationsTmp = listReverse(_minValueEquationsTmp);

          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_List_mapFold(threadData, _minValueEquationsTmp, boxvar_SimCodeUtil_dlowEqToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta13);
          _simeqns1 = tmpMeta15;
          tmp14 = mmc_unbox_integer(tmpMeta13);
          _uniqueEqIndex = tmp14  /* pattern as ty=Integer */;
          tmpMeta16 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_simeqns1, _simeqns));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT544, _OMC_LIT545);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _minValueEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _minValueEquations;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createNominalValueEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _nominalValueEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nominalValueEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _syst;
    tmp4_2 = _shared;
    tmp4_3 = _acc;
    {
      modelica_metatype _nominalValueEquationsTmp = NULL;
      modelica_metatype _simeqns = NULL;
      modelica_metatype _simeqns1 = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _nominalValueEquationsTmp has no default value.
      // _simeqns has no default value.
      // _simeqns1 has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
          _simeqns = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box2(0, tmpMeta9, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 5))));
          tmpMeta11 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), boxvar_SimCodeUtil_createInitialAssignmentsFromNominal, tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          _nominalValueEquationsTmp = tmpMeta12;

          _nominalValueEquationsTmp = listReverse(_nominalValueEquationsTmp);

          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_List_mapFold(threadData, _nominalValueEquationsTmp, boxvar_SimCodeUtil_dlowEqToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta13);
          _simeqns1 = tmpMeta15;
          tmp14 = mmc_unbox_integer(tmpMeta13);
          _uniqueEqIndex = tmp14  /* pattern as ty=Integer */;
          tmpMeta16 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_simeqns1, _simeqns));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT546, _OMC_LIT547);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _nominalValueEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _nominalValueEquations;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createValueEquationsShared(threadData_t *threadData, modelica_metatype _shared, modelica_fnptr _valueFunction, modelica_metatype _acc)
{
  modelica_metatype _maxValueEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _maxValueEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _shared;
    tmp4_2 = _acc;
    {
      modelica_metatype _maxValueEquationsTmp = NULL;
      modelica_metatype _simeqns = NULL;
      modelica_metatype _simeqns1 = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _maxValueEquationsTmp has no default value.
      // _simeqns has no default value.
      // _simeqns1 has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
          _simeqns = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box2(0, tmpMeta9, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 5))));
          tmpMeta11 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 2))), ((modelica_fnptr) _valueFunction), tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          _maxValueEquationsTmp = tmpMeta12;

          _maxValueEquationsTmp = listReverse(_maxValueEquationsTmp);

          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_List_mapFold(threadData, _maxValueEquationsTmp, boxvar_SimCodeUtil_dlowEqToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta13);
          _simeqns1 = tmpMeta15;
          tmp14 = mmc_unbox_integer(tmpMeta13);
          _uniqueEqIndex = tmp14  /* pattern as ty=Integer */;
          tmpMeta16 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_simeqns1, _simeqns));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT548, _OMC_LIT549);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _maxValueEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _maxValueEquations;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createStartValueEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _startValueEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _startValueEquations has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _syst;
    tmp4_2 = _shared;
    tmp4_3 = _acc;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _av = NULL;
      modelica_metatype _startValueEquationsTmp2 = NULL;
      modelica_metatype _simeqns = NULL;
      modelica_metatype _simeqns1 = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _globalKnownVars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _av has no default value.
      // _startValueEquationsTmp2 has no default value.
      // _simeqns has no default value.
      // _simeqns1 has no default value.
      // _uniqueEqIndex has no default value.
      // _globalKnownVars has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 3));
          _vars = tmpMeta6;
          _av = tmpMeta7;
          _uniqueEqIndex = tmp9  /* pattern as ty=Integer */;
          _simeqns = tmpMeta10;
          _globalKnownVars = tmpMeta11;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta13 = mmc_mk_box3(0, tmpMeta12, _av, _globalKnownVars);
          tmpMeta14 = omc_BackendVariable_traverseBackendDAEVars(threadData, _vars, boxvar_SimCodeUtil_createInitialAssignmentsFromStart, tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 1));
          _startValueEquationsTmp2 = tmpMeta15;

          _startValueEquationsTmp2 = listReverse(_startValueEquationsTmp2);

          /* Pattern-matching tuple assignment */
          tmpMeta18 = omc_List_mapFold(threadData, _startValueEquationsTmp2, boxvar_SimCodeUtil_dlowEqToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta16);
          _simeqns1 = tmpMeta18;
          tmp17 = mmc_unbox_integer(tmpMeta16);
          _uniqueEqIndex = tmp17  /* pattern as ty=Integer */;
          tmpMeta19 = mmc_mk_box3(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_simeqns1, _simeqns), _globalKnownVars);
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT550, _OMC_LIT551);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _startValueEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _startValueEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowAlgToSimEqSystem(threadData_t *threadData, modelica_metatype _inAlg, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outEquation = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _algStatements = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquation has no default value.
  // _ouniqueEqIndex has no default value.
  // _algStatements has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = omc_BackendDAEUtil_collateAlgorithm(threadData, _inAlg, mmc_mk_none());
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _algStatements = tmpMeta2;

  tmpMeta3 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _OMC_LIT535);
  _outEquation = tmpMeta3;

  _ouniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outEquation;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dlowAlgToSimEqSystem(threadData_t *threadData, modelica_metatype _inAlg, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outEquation = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outEquation = omc_SimCodeUtil_dlowAlgToSimEqSystem(threadData, _inAlg, tmp1, &_ouniqueEqIndex);
  /* skip box _outEquation; SimCode.SimEqSystem */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outEquation;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dlowEqToSimEqSystem(threadData_t *threadData, modelica_metatype _inEquation, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outEquation = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquation has no default value.
  // _ouniqueEqIndex has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _exp_ = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _alg = NULL;
      modelica_metatype _algStatements = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _whenEquation = NULL;
      modelica_metatype _elseWhen = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _oelseWhen = NULL;
      modelica_metatype _conditions = NULL;
      modelica_boolean _initialCall;
      modelica_metatype _elseWhenEquation = NULL;
      modelica_metatype _oelseWhenSimEq = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _eqAttr = NULL;
      int tmp4;
      // _cr has no default value.
      // _exp_ has no default value.
      // _cond has no default value.
      // _alg has no default value.
      // _algStatements has no default value.
      // _source has no default value.
      // _whenEquation has no default value.
      // _elseWhen has no default value.
      // _whenStmtLst has no default value.
      // _oelseWhen has no default value.
      // _conditions has no default value.
      // _initialCall has no default value.
      // _elseWhenEquation has no default value.
      // _oelseWhenSimEq has no default value.
      // _uniqueEqIndex has no default value.
      // _eqAttr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 5: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _cr = tmpMeta5;
          _exp_ = tmpMeta6;
          _source = tmpMeta7;
          _eqAttr = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _cr, _exp_, _source, _eqAttr);
          tmpMeta[0+0] = tmpMeta9;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _exp_ = tmpMeta10;
          _source = tmpMeta11;
          _eqAttr = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)), _exp_, _source, _eqAttr);
          tmpMeta[0+0] = tmpMeta13;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _alg = tmpMeta14;
          _eqAttr = tmpMeta15;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta16 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          _algStatements = tmpMeta17;
          tmpMeta18 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _eqAttr);
          tmpMeta[0+0] = tmpMeta18;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _whenEquation = tmpMeta19;
          _source = tmpMeta20;
          _eqAttr = tmpMeta21;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta22 = _whenEquation;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 3));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 4));
          _cond = tmpMeta23;
          _whenStmtLst = tmpMeta24;
          _oelseWhen = tmpMeta25;

          if(isSome(_oelseWhen))
          {
            /* Pattern-matching assignment */
            tmpMeta26 = _oelseWhen;
            if (optionNone(tmpMeta26)) goto goto_2;
            tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 1));
            _elseWhen = tmpMeta27;

            tmpMeta28 = MMC_REFSTRUCTLIT(mmc_nil);
            _elseWhenEquation = omc_SimCodeUtil_createElseWhenEquation(threadData, _elseWhen, tmpMeta28, ((modelica_integer) 1) + _iuniqueEqIndex, _source, _eqAttr ,&_uniqueEqIndex);

            _oelseWhenSimEq = mmc_mk_some(_elseWhenEquation);
          }
          else
          {
            _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

            _oelseWhenSimEq = mmc_mk_none();
          }

          _conditions = omc_BackendDAEUtil_getConditionList(threadData, _cond ,&_initialCall);
          tmpMeta29 = mmc_mk_box8(18, &SimCode_SimEqSystem_SES__WHEN__desc, mmc_mk_integer(_iuniqueEqIndex), _conditions, mmc_mk_boolean(_initialCall), _whenStmtLst, _oelseWhenSimEq, _source, _eqAttr);
          tmpMeta[0+0] = tmpMeta29;
          tmp1_c1 = _uniqueEqIndex;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Error_addInternalError(threadData, _OMC_LIT552, _OMC_LIT553);
          }
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEquation = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outEquation;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dlowEqToSimEqSystem(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outEquation = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outEquation = omc_SimCodeUtil_dlowEqToSimEqSystem(threadData, _inEquation, tmp1, &_ouniqueEqIndex);
  /* skip box _outEquation; SimCode.SimEqSystem */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outEquation;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseAliasVarsToSimEqSystem(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _v = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _eqns = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _uniqueEqIndex has no default value.
      // _eqns has no default value.
      // _cr has no default value.
      // _exp has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _v = tmp4_1;
          _cr = tmpMeta6;
          _exp = tmpMeta8;
          _source = tmpMeta9;
          _uniqueEqIndex = tmp11  /* pattern as ty=Integer */;
          _eqns = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta14 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex), _cr, _exp, _source, _OMC_LIT535);
          tmpMeta13 = mmc_mk_cons(tmpMeta14, _eqns);
          tmpMeta15 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _uniqueEqIndex), tmpMeta13);
          tmpMeta[0+0] = _v;
          tmpMeta[0+1] = tmpMeta15;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traverseKnVarsToSimEqSystem(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _v = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _eqns = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _uniqueEqIndex has no default value.
      // _eqns has no default value.
      // _cr has no default value.
      // _exp has no default value.
      // _source has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_boolean tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 10));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _v = tmp4_1;
          _cr = tmpMeta6;
          _exp = tmpMeta8;
          _source = tmpMeta9;
          _uniqueEqIndex = tmp11  /* pattern as ty=Integer */;
          _eqns = tmpMeta12;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp13 = omc_BackendVariable_isVarOnTopLevelAndInput(threadData, _v);
          if (0 /* false */ != tmp13) goto goto_2;
          tmpMeta15 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex), _cr, _exp, _source, _OMC_LIT535);
          tmpMeta14 = mmc_mk_cons(tmpMeta15, _eqns);
          tmpMeta16 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _uniqueEqIndex), tmpMeta14);
          tmpMeta[0+0] = _v;
          tmpMeta[0+1] = tmpMeta16;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createInitialEquations__lambda0(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _outInitialEqns = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _tempvars = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _knownEquations = NULL;
  modelica_metatype _solvedEquations = NULL;
  modelica_metatype _aliasEquations = NULL;
  modelica_metatype _systs = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _globalKnownVars = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_integer tmp11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_integer tmp18;
  modelica_metatype tmpMeta19;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outInitialEqns = tmpMeta1;
  _ouniqueEqIndex = _iuniqueEqIndex;
  _otempvars = _itempvars;
  // _tempvars has no default value.
  // _uniqueEqIndex has no default value.
  // _allEquations has no default value.
  // _knownEquations has no default value.
  // _solvedEquations has no default value.
  // _aliasEquations has no default value.
  // _systs has no default value.
  // _shared has no default value.
  // _globalKnownVars has no default value.
  // _aliasVars has no default value.
  /* Pattern-matching assignment */
  tmpMeta2 = _inInitDAE;
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 5));
  _systs = tmpMeta3;
  _shared = tmpMeta4;
  _globalKnownVars = tmpMeta5;
  _aliasVars = tmpMeta6;

  /* Pattern-matching assignment */
  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta8 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), tmpMeta7);
  tmpMeta9 = omc_BackendVariable_traverseBackendDAEVars(threadData, _globalKnownVars, boxvar_SimCodeUtil_traverseKnVarsToSimEqSystem, tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
  tmp11 = mmc_unbox_integer(tmpMeta10);
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
  _uniqueEqIndex = tmp11  /* pattern as ty=Integer */;
  _knownEquations = tmpMeta12;

  tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
  _uniqueEqIndex = omc_SimCodeUtil_createEquationsForSystems(threadData, _systs, _shared, _uniqueEqIndex, tmpMeta13, _itempvars, ((modelica_integer) 0), _OMC_LIT205, 1 /* true */ ,NULL ,NULL ,NULL ,&_solvedEquations ,NULL ,&_tempvars ,NULL ,NULL ,NULL ,NULL);

  /* Pattern-matching assignment */
  tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta15 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta14);
  tmpMeta16 = omc_BackendVariable_traverseBackendDAEVars(threadData, _aliasVars, boxvar_SimCodeUtil_traverseAliasVarsToSimEqSystem, tmpMeta15);
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 1));
  tmp18 = mmc_unbox_integer(tmpMeta17);
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
  _uniqueEqIndex = tmp18  /* pattern as ty=Integer */;
  _aliasEquations = tmpMeta19;

  _allEquations = omc_List_append__reverse(threadData, _solvedEquations, _aliasEquations);

  _allEquations = listAppend(_knownEquations, _allEquations);

  _outInitialEqns = _allEquations;

  _ouniqueEqIndex = _uniqueEqIndex;

  _otempvars = _tempvars;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _outInitialEqns;
}
modelica_metatype boxptr_SimCodeUtil_createInitialEquations__lambda0(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outInitialEqns = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outInitialEqns = omc_SimCodeUtil_createInitialEquations__lambda0(threadData, _inInitDAE, tmp1, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _outInitialEqns; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _outInitialEqns;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createInitialEquations(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _outInitialEqns = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _removedEqs = NULL;
  modelica_metatype _tempvars = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _knownVarEquations = NULL;
  modelica_metatype _solvedEquations = NULL;
  modelica_metatype _removedEquations = NULL;
  modelica_metatype _aliasEquations = NULL;
  modelica_metatype _systs = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _globalKnownVars = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_integer tmp11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_integer tmp18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_integer tmp24;
  modelica_metatype tmpMeta25;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outInitialEqns = tmpMeta1;
  _ouniqueEqIndex = _iuniqueEqIndex;
  _otempvars = _itempvars;
  // _removedEqs has no default value.
  // _tempvars has no default value.
  // _uniqueEqIndex has no default value.
  // _allEquations has no default value.
  // _knownVarEquations has no default value.
  // _solvedEquations has no default value.
  // _removedEquations has no default value.
  // _aliasEquations has no default value.
  // _systs has no default value.
  // _shared has no default value.
  // _globalKnownVars has no default value.
  // _aliasVars has no default value.
  /* Pattern-matching assignment */
  tmpMeta2 = _inInitDAE;
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 5));
  _systs = tmpMeta3;
  _shared = tmpMeta4;
  _globalKnownVars = tmpMeta5;
  _aliasVars = tmpMeta6;

  _removedEqs = omc_BackendDAEUtil_collapseRemovedEqs(threadData, _inInitDAE);

  /* Pattern-matching assignment */
  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta8 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), tmpMeta7);
  tmpMeta9 = omc_BackendVariable_traverseBackendDAEVars(threadData, _globalKnownVars, boxvar_SimCodeUtil_traverseKnVarsToSimEqSystem, tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
  tmp11 = mmc_unbox_integer(tmpMeta10);
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
  _uniqueEqIndex = tmp11  /* pattern as ty=Integer */;
  _knownVarEquations = tmpMeta12;

  tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
  _uniqueEqIndex = omc_SimCodeUtil_createEquationsForSystems(threadData, _systs, _shared, _uniqueEqIndex, tmpMeta13, _itempvars, ((modelica_integer) 0), _OMC_LIT205, 1 /* true */ ,NULL ,NULL ,NULL ,&_solvedEquations ,NULL ,&_tempvars ,NULL ,NULL ,NULL ,NULL);

  /* Pattern-matching assignment */
  tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta15 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta14);
  tmpMeta16 = omc_BackendEquation_traverseEquationArray(threadData, _removedEqs, boxvar_SimCodeUtil_traversedlowEqToSimEqSystem, tmpMeta15);
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 1));
  tmp18 = mmc_unbox_integer(tmpMeta17);
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
  _uniqueEqIndex = tmp18  /* pattern as ty=Integer */;
  _removedEquations = tmpMeta19;

  /* Pattern-matching assignment */
  tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta21 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta20);
  tmpMeta22 = omc_BackendVariable_traverseBackendDAEVars(threadData, _aliasVars, boxvar_SimCodeUtil_traverseAliasVarsToSimEqSystem, tmpMeta21);
  tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
  tmp24 = mmc_unbox_integer(tmpMeta23);
  tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
  _uniqueEqIndex = tmp24  /* pattern as ty=Integer */;
  _aliasEquations = tmpMeta25;

  _allEquations = listReverseInPlace(_aliasEquations);

  _allEquations = listAppend(_removedEquations, _allEquations);

  _allEquations = omc_List_append__reverse(threadData, _solvedEquations, _allEquations);

  _allEquations = listAppend(_knownVarEquations, _allEquations);

  _outInitialEqns = _allEquations;

  _ouniqueEqIndex = _uniqueEqIndex;

  _otempvars = _tempvars;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _outInitialEqns;
}
modelica_metatype boxptr_SimCodeUtil_createInitialEquations(threadData_t *threadData, modelica_metatype _inInitDAE, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outInitialEqns = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outInitialEqns = omc_SimCodeUtil_createInitialEquations(threadData, _inInitDAE, tmp1, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _outInitialEqns; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _outInitialEqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleAlgorithmCode(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _vars, modelica_boolean _skipDiscinAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_boolean tmp4_2;
    tmp4_1 = _eqns;
    tmp4_2 = _skipDiscinAlgorithm;
    {
      modelica_metatype _alg = NULL;
      modelica_metatype _solvedVars = NULL;
      modelica_metatype _algOutVars = NULL;
      modelica_metatype _knownOutputCrefs = NULL;
      modelica_string _crefsStr = NULL;
      modelica_string _algStr = NULL;
      modelica_metatype _algStatements = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _crefExpand = NULL;
      modelica_metatype _eqAttr = NULL;
      modelica_metatype _result = NULL;
      modelica_metatype _discreteVarsExp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _alg has no default value.
      // _solvedVars has no default value.
      // _algOutVars has no default value.
      // _knownOutputCrefs has no default value.
      // _crefsStr has no default value.
      // _algStr has no default value.
      // _algStatements has no default value.
      // _source has no default value.
      // _crefExpand has no default value.
      // _eqAttr has no default value.
      // _result has no default value.
      // _discreteVarsExp has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_boolean tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,4,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 6));
          _alg = tmpMeta8;
          _source = tmpMeta9;
          _crefExpand = tmpMeta10;
          _eqAttr = tmpMeta11;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _solvedVars = omc_List_map(threadData, _vars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp12 = omc_CheckModel_isCrefListAlgorithmOutput(threadData, _solvedVars, _alg, _source, _crefExpand);
          if (1 /* true */ != tmp12) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta13 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          _algStatements = tmpMeta14;
          tmpMeta16 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _eqAttr);
          tmpMeta15 = mmc_mk_cons(tmpMeta16, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta15;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_boolean tmp23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmp4_1);
          tmpMeta18 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,4,5) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 3));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 4));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 5));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 6));
          _alg = tmpMeta19;
          _source = tmpMeta20;
          _crefExpand = tmpMeta21;
          _eqAttr = tmpMeta22;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _solvedVars = omc_List_map(threadData, _vars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp23 = omc_CheckModel_isCrefListAlgorithmOutput(threadData, _solvedVars, _alg, _source, _crefExpand);
          if (1 /* true */ != tmp23) goto goto_2;

          /* Pattern-matching assignment */
          tmpMeta24 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          _algStatements = tmpMeta25;

          _algStatements = omc_BackendDAEUtil_removeDiscreteAssignments(threadData, _algStatements, omc_BackendVariable_listVar1(threadData, _vars));
          tmpMeta27 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _eqAttr);
          tmpMeta26 = mmc_mk_cons(tmpMeta27, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta26;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta28 = MMC_CAR(tmp4_1);
          tmpMeta29 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta28,4,5) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 3));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 6));
          _alg = tmpMeta30;
          _eqAttr = tmpMeta31;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta32 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 2));
          _algStatements = tmpMeta33;

          _algStatements = omc_SimCodeUtil_solveAlgorithmInverse(threadData, _algStatements, _vars);
          tmpMeta35 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _eqAttr);
          tmpMeta34 = mmc_mk_cons(tmpMeta35, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta34;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta36 = MMC_CAR(tmp4_1);
          tmpMeta37 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta36,4,5) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 3));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 4));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 5));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 6));
          
          _alg = tmpMeta38;
          _algStatements = tmpMeta39;
          _source = tmpMeta40;
          _crefExpand = tmpMeta41;
          _eqAttr = tmpMeta42;
          /* Pattern matching succeeded */
          _solvedVars = omc_List_map(threadData, _vars, boxvar_BackendVariable_varCref);

          _solvedVars = omc_List_unionList(threadData, omc_List_map1(threadData, _solvedVars, boxvar_ComponentReference_expandCref, mmc_mk_boolean(1 /* true */)));

          _algOutVars = omc_CheckModel_checkAndGetAlgorithmOutputs(threadData, _alg, _source, _crefExpand);

          _algOutVars = omc_List_unionList(threadData, omc_List_map1(threadData, _algOutVars, boxvar_ComponentReference_expandCref, mmc_mk_boolean(1 /* true */)));

          _knownOutputCrefs = omc_List_setDifference(threadData, _algOutVars, _solvedVars);

          _solvedVars = omc_List_map(threadData, omc_List_filterOnTrue(threadData, _vars, boxvar_BackendVariable_isVarNonDiscrete), boxvar_BackendVariable_varCref);

          {
            modelica_metatype __omcQ_24tmpVar49;
            modelica_metatype* tmp44;
            modelica_metatype tmpMeta45;
            modelica_metatype __omcQ_24tmpVar48;
            modelica_integer tmp46;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = omc_List_filterOnTrue(threadData, _vars, boxvar_BackendVariable_isVarDiscrete);
            tmpMeta45 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar49 = tmpMeta45; /* defaultValue */
            tmp44 = &__omcQ_24tmpVar49;
            while(1) {
              tmp46 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp46--;
              }
              if (tmp46 == 0) {
                __omcQ_24tmpVar48 = omc_Expression_crefToExp(threadData, omc_BackendVariable_varCref(threadData, _v));
                *tmp44 = mmc_mk_cons(__omcQ_24tmpVar48,0);
                tmp44 = &MMC_CDR(*tmp44);
              } else if (tmp46 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp44 = mmc_mk_nil();
            tmpMeta43 = __omcQ_24tmpVar49;
          }
          _discreteVarsExp = tmpMeta43;

          _algStatements = omc_BackendDAEOptimize_expandAlgorithmStmts(threadData, _algStatements, _discreteVarsExp, omc_BackendVariable_listVar(threadData, _vars), 1 /* true */);

          tmpMeta47 = mmc_mk_box2(3, &DAE_Algorithm_ALGORITHM__STMTS__desc, _algStatements);
          _alg = tmpMeta47;

          /* Pattern-matching assignment */
          tmpMeta48 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 2));
          _algStatements = tmpMeta49;

          if((!listEmpty(_solvedVars)))
          {
            tmpMeta52 = mmc_mk_box6(14, &SimCode_SimEqSystem_SES__INVERSE__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _knownOutputCrefs, mmc_mk_boolean(1 /* true */), _eqAttr);
            tmpMeta51 = mmc_mk_cons(tmpMeta52, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta53 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(((modelica_integer) 1) + _iuniqueEqIndex), tmpMeta51, _solvedVars, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_vars)), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), _clockIndex);
            tmpMeta54 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta53, mmc_mk_none(), _eqAttr);
            tmpMeta50 = mmc_mk_cons(tmpMeta54, MMC_REFSTRUCTLIT(mmc_nil));
            _result = tmpMeta50;

            _ouniqueEqIndex = ((modelica_integer) 2) + _iuniqueEqIndex;
          }
          else
          {
            tmpMeta56 = mmc_mk_box6(14, &SimCode_SimEqSystem_SES__INVERSE__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _knownOutputCrefs, mmc_mk_boolean(0 /* false */), _eqAttr);
            tmpMeta55 = mmc_mk_cons(tmpMeta56, MMC_REFSTRUCTLIT(mmc_nil));
            _result = tmpMeta55;

            _ouniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          }
          tmpMeta[0+0] = _result;
          tmp1_c1 = _ouniqueEqIndex;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_boolean tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta57 = MMC_CAR(tmp4_1);
          tmpMeta58 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta57,4,5) == 0) goto tmp3_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 3));
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 4));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 5));
          
          _alg = tmpMeta59;
          _source = tmpMeta60;
          _crefExpand = tmpMeta61;
          /* Pattern matching succeeded */
          _solvedVars = omc_List_map(threadData, _vars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp62 = omc_CheckModel_isCrefListAlgorithmOutput(threadData, _solvedVars, _alg, _source, _crefExpand);
          if (0 /* false */ != tmp62) goto goto_2;

          _crefsStr = omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _solvedVars);

          tmpMeta64 = mmc_mk_box3(19, &DAE_Element_ALGORITHM__desc, _alg, _source);
          tmpMeta63 = mmc_mk_cons(tmpMeta64, MMC_REFSTRUCTLIT(mmc_nil));
          _algStr = omc_DAEDump_dumpAlgorithmsStr(threadData, tmpMeta63);

          tmpMeta65 = stringAppend(_OMC_LIT554,_crefsStr);
          tmpMeta66 = stringAppend(tmpMeta65,_OMC_LIT555);
          tmpMeta67 = stringAppend(tmpMeta66,_algStr);
          tmpMeta68 = stringAppend(tmpMeta67,_OMC_LIT556);
          omc_Error_addInternalError(threadData, tmpMeta68, _OMC_LIT557);
          goto goto_2;
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT558, _OMC_LIT559);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 6) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleAlgorithmCode(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _vars, modelica_metatype _skipDiscinAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_skipDiscinAlgorithm);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createSingleAlgorithmCode(threadData, _eqns, _vars, tmp1, tmp2, _clockIndex, &_ouniqueEqIndex);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleArrayEqnCode(threadData_t *threadData, modelica_boolean _genDiscrete, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _shared, modelica_metatype *out_noDiscequations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_metatype _noDiscequations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _inEquation = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer tmp8_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _noDiscequations has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _inEquation has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = listHead(_inEquations);
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _inEquation = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_inEquation), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[3] = omc_Expression_replaceDerOpInExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEquation), 3))));
          _inEquation = tmpMeta6;

          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_inEquation), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[4] = omc_Expression_replaceDerOpInExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEquation), 4))));
          _inEquation = tmpMeta7;
          tmpMeta1 = _inEquation;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _inEquation = tmpMeta1;

  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp11_1;volatile modelica_metatype tmp11_2;
    tmp11_1 = _inEquation;
    tmp11_2 = _inVars;
    {
      modelica_metatype _ds = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _lhse = NULL;
      modelica_metatype _rhse = NULL;
      modelica_metatype _expLst = NULL;
      modelica_metatype _expLstTmp = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _cr_1 = NULL;
      modelica_metatype _left = NULL;
      modelica_metatype _funcs = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _equation_ = NULL;
      modelica_metatype _eqSystlst = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_string _str = NULL;
      modelica_metatype _dims = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _eqAttr = NULL;
      modelica_metatype _crefstmp = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _basety = NULL;
      modelica_metatype _exptl = NULL;
      volatile mmc_switch_type tmp11;
      int tmp12;
      // _ds has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _lhse has no default value.
      // _rhse has no default value.
      // _expLst has no default value.
      // _expLstTmp has no default value.
      // _cr has no default value.
      // _cr_1 has no default value.
      // _left has no default value.
      // _funcs has no default value.
      // _source has no default value.
      // _equation_ has no default value.
      // _eqSystlst has no default value.
      // _uniqueEqIndex has no default value.
      // _str has no default value.
      // _dims has no default value.
      // _tempvars has no default value.
      // _eqAttr has no default value.
      // _crefstmp has no default value.
      // _ty has no default value.
      // _basety has no default value.
      // _exptl has no default value.
      tmp11 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp10_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp11 < 7; tmp11++) {
        switch (MMC_SWITCH_CAST(tmp11)) {
        case 0: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,13,3) == 0) goto tmp10_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,1,1) == 0) goto tmp10_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          if (18 != MMC_STRLEN(tmpMeta15) || strcmp(MMC_STRINGDATA(_OMC_LIT564), MMC_STRINGDATA(tmpMeta15)) != 0) goto tmp10_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          
          _rhse = tmpMeta13;
          _source = tmpMeta16;
          _eqAttr = tmpMeta17;
          tmp11 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta19 = mmc_mk_box3(14, &DAE_Statement_STMT__NORETCALL__desc, _rhse, _source);
          tmpMeta18 = mmc_mk_cons(tmpMeta19, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta20 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta18, _eqAttr);
          _equation_ = tmpMeta20;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta21 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta22 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta21;
          tmpMeta[0+1] = tmpMeta22;
          tmp8_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp10_done;
        }
        case 1: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,13,3) == 0) goto tmp10_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,1,1) == 0) goto tmp10_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          if (19 != MMC_STRLEN(tmpMeta25) || strcmp(MMC_STRINGDATA(_OMC_LIT565), MMC_STRINGDATA(tmpMeta25)) != 0) goto tmp10_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          
          _rhse = tmpMeta23;
          _source = tmpMeta26;
          _eqAttr = tmpMeta27;
          /* Pattern matching succeeded */
          tmpMeta29 = mmc_mk_box3(14, &DAE_Statement_STMT__NORETCALL__desc, _rhse, _source);
          tmpMeta28 = mmc_mk_cons(tmpMeta29, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta30 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta28, _eqAttr);
          _equation_ = tmpMeta30;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta31 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta32 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta31;
          tmpMeta[0+1] = tmpMeta32;
          tmp8_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp10_done;
        }
        case 2: {
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 2));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 3));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          
          _ds = tmpMeta33;
          _e1 = tmpMeta34;
          _e2 = tmpMeta35;
          _source = tmpMeta36;
          _eqAttr = tmpMeta37;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_Expression_isMatrix(threadData, _e1) || omc_Expression_isArray(threadData, _e1))) goto tmp10_end;
          _expLst = omc_Expression_flattenArrayExpToList(threadData, _e1);

          _ty = omc_Expression_typeof(threadData, _e1);

          _basety = omc_TypesDump_flattenArrayType(threadData, _ty ,&_dims);

          tmpMeta38 = mmc_mk_box3(9, &DAE_Type_T__ARRAY__desc, _basety, _dims);
          _ty = tmpMeta38;

          tmpMeta39 = stringAppend(_OMC_LIT560,intString(_iuniqueEqIndex));
          tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
          _left = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta39, _ty, tmpMeta40);

          tmpMeta41 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _left, _ty);
          _lhse = tmpMeta41;

          _crefstmp = omc_ComponentReference_expandCref(threadData, _left, 0 /* false */);

          _expLstTmp = omc_List_map(threadData, _crefstmp, boxvar_Expression_crefExp);

          _tempvars = omc_SimCodeUtil_createArrayTempVar(threadData, _left, _ds, _expLstTmp, _itempvars);

          _exptl = omc_List_zip(threadData, _expLst, _expLstTmp);

          /* Pattern-matching tuple assignment */
          tmpMeta44 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta45 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGN, _source, _eqAttr, mmc_mk_integer(_iuniqueEqIndex), tmpMeta44, &tmpMeta42);
          _eqSystlst = tmpMeta45;
          tmp43 = mmc_unbox_integer(tmpMeta42);
          _uniqueEqIndex = tmp43  /* pattern as ty=Integer */;

          tmpMeta47 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex), _lhse, _e2, _source, _eqAttr);
          tmpMeta46 = mmc_mk_cons(tmpMeta47, _eqSystlst);
          _eqSystlst = tmpMeta46;
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = _eqSystlst;
          tmp8_c2 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp10_done;
        }
        case 3: {
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          if (listEmpty(tmp11_2)) goto tmp10_end;
          tmpMeta48 = MMC_CAR(tmp11_2);
          tmpMeta49 = MMC_CDR(tmp11_2);
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta51,6,2) == 0) goto tmp10_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta51), 2));
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          
          _cr = tmpMeta50;
          _e1 = tmpMeta51;
          _cr_1 = tmpMeta52;
          _e2 = tmpMeta53;
          _source = tmpMeta54;
          _eqAttr = tmpMeta55;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_ComponentReferenceBasics_crefEqual(threadData, _cr_1, omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr))) goto tmp10_end;
          _e1 = omc_BackendDAEUtil_collateArrExp(threadData, _e1, mmc_mk_none(), NULL);

          _e2 = omc_BackendDAEUtil_collateArrExp(threadData, _e2, mmc_mk_none(), NULL);

          tmpMeta56 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _e1, _e2, _source, _eqAttr);
          _equation_ = tmpMeta56;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta57 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta58 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta57;
          tmpMeta[0+1] = tmpMeta58;
          tmp8_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp10_done;
        }
        case 4: {
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          if (listEmpty(tmp11_2)) goto tmp10_end;
          tmpMeta59 = MMC_CAR(tmp11_2);
          tmpMeta60 = MMC_CDR(tmp11_2);
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta59), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 3));
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,6,2) == 0) goto tmp10_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          
          _cr = tmpMeta61;
          _e1 = tmpMeta62;
          _e2 = tmpMeta63;
          _cr_1 = tmpMeta64;
          _source = tmpMeta65;
          _eqAttr = tmpMeta66;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_ComponentReferenceBasics_crefEqual(threadData, _cr_1, omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr))) goto tmp10_end;
          _e1 = omc_BackendDAEUtil_collateArrExp(threadData, _e1, mmc_mk_none(), NULL);

          _e2 = omc_BackendDAEUtil_collateArrExp(threadData, _e2, mmc_mk_none(), NULL);

          tmpMeta67 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _e2, _e1, _source, _eqAttr);
          _equation_ = tmpMeta67;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta68 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta69 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta68;
          tmpMeta[0+1] = tmpMeta69;
          tmp8_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp10_done;
        }
        case 5: {
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          if (mmc__uniontype__metarecord__typedef__equal(tmp11_1,1,6) == 0) goto tmp10_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 3));
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 4));
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 5));
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp11_1), 6));
          if (listEmpty(tmp11_2)) goto tmp10_end;
          tmpMeta74 = MMC_CAR(tmp11_2);
          tmpMeta75 = MMC_CDR(tmp11_2);
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta74), 2));
          
          _lhse = tmpMeta70;
          _rhse = tmpMeta71;
          _source = tmpMeta72;
          _eqAttr = tmpMeta73;
          _cr = tmpMeta76;
          /* Pattern matching succeeded */
          _lhse = omc_BackendDAEUtil_collateArrExp(threadData, _lhse, mmc_mk_none(), NULL);

          _rhse = omc_BackendDAEUtil_collateArrExp(threadData, _rhse, mmc_mk_none(), NULL);

          /* Pattern-matching assignment */
          tmpMeta77 = _shared;
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta77), 12));
          _funcs = tmpMeta78;

          _e1 = omc_Expression_crefExp(threadData, _cr);

          _e2 = omc_ExpressionSolve_solve2(threadData, _lhse, _rhse, _e1, mmc_mk_some(_funcs), mmc_mk_some(mmc_mk_integer(_iuniqueEqIndex)), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _shared), NULL, NULL, NULL);

          tmpMeta79 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _e1, _e2, _source, _eqAttr);
          _equation_ = tmpMeta79;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta80 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta81 = mmc_mk_cons(_equation_, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta80;
          tmpMeta[0+1] = tmpMeta81;
          tmp8_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp10_done;
        }
        case 6: {
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta82 = _inVars;
          if (listEmpty(tmpMeta82)) goto goto_9;
          tmpMeta83 = MMC_CAR(tmpMeta82);
          tmpMeta84 = MMC_CDR(tmpMeta82);
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta83), 2));
          _cr = tmpMeta85;

          _str = omc_BackendDump_dumpEqnsStr(threadData, _inEquations);

          tmpMeta86 = stringAppend(_OMC_LIT561,_str);
          tmpMeta87 = stringAppend(tmpMeta86,_OMC_LIT562);
          tmpMeta88 = stringAppend(tmpMeta87,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
          tmpMeta89 = stringAppend(tmpMeta88,_OMC_LIT169);
          _str = tmpMeta89;

          omc_Error_addInternalError(threadData, _str, _OMC_LIT563);
          goto goto_9;
          goto tmp10_done;
        }
        }
        goto tmp10_end;
        tmp10_end: ;
      }
      goto goto_9;
      tmp10_done:
      (void)tmp11;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp10_done2;
      goto_9:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp11 < 7) {
        goto tmp10_top;
      }
      MMC_THROW_INTERNAL();
      tmp10_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _noDiscequations = tmpMeta[0+1];
  _ouniqueEqIndex = tmp8_c2;
  _otempvars = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_noDiscequations) { *out_noDiscequations = _noDiscequations; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleArrayEqnCode(threadData_t *threadData, modelica_metatype _genDiscrete, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _shared, modelica_metatype *out_noDiscequations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_genDiscrete);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createSingleArrayEqnCode(threadData, tmp1, _inEquations, _inVars, tmp2, _itempvars, _shared, out_noDiscequations, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  /* skip box _noDiscequations; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_createSingleComplexEqnCode3(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _iht, modelica_metatype *out_oht)
{
  modelica_boolean _outB;
  modelica_metatype _oht = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outB has no default value.
  // _oht has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inExp;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _ht = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _expLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _ht has no default value.
      // _crefs has no default value.
      // _expLst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 10; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_BaseHashSet_has(threadData, _cr, _iht)) goto tmp3_end;
          _ht = omc_BaseHashSet_delete(threadData, _cr, _iht);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _ht;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_boolean tmp9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta7;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _crefs = omc_ComponentReference_expandCref(threadData, _cr, 1 /* true */);

          /* Pattern-matching assignment */
          tmpMeta8 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmp9 = valueEq(tmpMeta8, _crefs);
          if (0 /* false */ != tmp9) goto goto_2;

          _expLst = omc_List_map(threadData, _crefs, boxvar_Expression_crefExp);

          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _iht);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,1) == 0) goto tmp3_end;
          
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,0) == 0) goto tmp3_end;
          
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _expLst = tmpMeta11;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _iht);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,4) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _expLst = tmpMeta12;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _iht);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _expLst = tmpMeta13;
          /* Pattern matching succeeded */
          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _iht);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        case 9: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = 0 /* false */;
          tmpMeta[0+1] = _iht;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 10) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outB = tmp1_c0;
  _oht = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oht) { *out_oht = _oht; }
  return _outB;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode3(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _iht, modelica_metatype *out_oht)
{
  modelica_boolean _outB;
  modelica_metatype out_outB;
  _outB = omc_SimCodeUtil_createSingleComplexEqnCode3(threadData, _inExp, _iht, out_oht);
  out_outB = mmc_mk_icon(_outB);
  /* skip box _oht; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<DAE.ComponentRef>>>, #Integer, #Integer, tuple<.HashSet.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashSet.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashSet.FuncCrefStr<function>(DAE.ComponentRef cr) => String>> */
  return out_outB;
}

static modelica_metatype closure17_ComponentReferenceBasics_crefPrefixOf(threadData_t *thData, modelica_metatype closure, modelica_metatype fullCref)
{
  modelica_metatype prefixCref = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefPrefixOf(thData, prefixCref, fullCref);
}static modelica_metatype closure18_ComponentReferenceBasics_crefPrefixOf(threadData_t *thData, modelica_metatype closure, modelica_metatype fullCref)
{
  modelica_metatype prefixCref = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefPrefixOf(thData, prefixCref, fullCref);
}static modelica_metatype closure19_Expression_expandCrefs(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp, modelica_metatype $in_dummy, modelica_metatype tmp30)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandCrefs(thData, inExp, expandRecord, $in_dummy, tmp30);
}static modelica_metatype closure20_Expression_expandCrefs(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp, modelica_metatype $in_dummy, modelica_metatype tmp47)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandCrefs(thData, inExp, expandRecord, $in_dummy, tmp47);
}static modelica_metatype closure21_Expression_expandCrefs(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp, modelica_metatype $in_dummy, modelica_metatype tmp68)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandCrefs(thData, inExp, expandRecord, $in_dummy, tmp68);
}static modelica_metatype closure22_Expression_expandCrefs(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp, modelica_metatype $in_dummy, modelica_metatype tmp85)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandCrefs(thData, inExp, expandRecord, $in_dummy, tmp85);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleComplexEqnCode2(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _inExp3, modelica_metatype _inExp4, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _source, modelica_metatype _eqKind, modelica_metatype _iextra, modelica_boolean _genDiscrete, modelica_metatype _inVars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inExp3;
    tmp4_2 = _inExp4;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _e1_1 = NULL;
      modelica_metatype _e2_1 = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _expl1 = NULL;
      modelica_metatype _stms = NULL;
      modelica_metatype _tp = NULL;
      modelica_metatype _path = NULL;
      modelica_metatype _rpath = NULL;
      modelica_metatype _expLst = NULL;
      modelica_metatype _crexplst = NULL;
      modelica_string _ident = NULL;
      modelica_metatype _exptl = NULL;
      modelica_metatype _simeqn_complex = NULL;
      modelica_metatype _eqSystlst = NULL;
      modelica_metatype _eqSystlst_nonflat = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _varLst = NULL;
      modelica_metatype _ht = NULL;
      modelica_string _s = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      modelica_string _s3 = NULL;
      modelica_metatype _eqnLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _e1_1 has no default value.
      // _e2_1 has no default value.
      // _expl has no default value.
      // _expl1 has no default value.
      // _stms has no default value.
      // _tp has no default value.
      // _path has no default value.
      // _rpath has no default value.
      // _expLst has no default value.
      // _crexplst has no default value.
      // _ident has no default value.
      // _exptl has no default value.
      // _simeqn_complex has no default value.
      // _eqSystlst has no default value.
      // _eqSystlst_nonflat has no default value.
      // _tempvars has no default value.
      // _uniqueEqIndex has no default value.
      // _varLst has no default value.
      // _ht has no default value.
      // _s has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      // _s3 has no default value.
      // _eqnLst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 12; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,20,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _e1 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = omc_SimCodeUtil_createSingleComplexEqnCode2(threadData, _crefs, _e1, _inExp4, _iuniqueEqIndex, _itempvars, _source, _eqKind, _iextra, _genDiscrete, _inVars, &tmp1_c1, &tmpMeta[0+2]);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,20,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _e1 = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = omc_SimCodeUtil_createSingleComplexEqnCode2(threadData, _crefs, _inExp3, _e1, _iuniqueEqIndex, _itempvars, _source, _eqKind, _iextra, _genDiscrete, _inVars, &tmp1_c1, &tmpMeta[0+2]);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _e1 = tmp4_1;
          _cr2 = tmpMeta8;
          _e2 = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = mmc_mk_box1(0, _cr2);
          tmp10 = omc_List_all(threadData, _crefs, (modelica_fnptr) mmc_mk_box2(0,closure17_ComponentReferenceBasics_crefPrefixOf,tmpMeta9));
          if (1 /* true */ != tmp10) goto goto_2;

          _e2_1 = omc_Expression_extendArrExp(threadData, _e2, 0 /* false */, NULL);

          _tp = omc_Expression_typeof(threadData, _e1);

          tmpMeta11 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e1, _e2_1, _source);
          _stms = tmpMeta11;
          tmpMeta13 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta14 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta13, _eqKind);
          tmpMeta12 = mmc_mk_cons(tmpMeta14, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta12;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_boolean tmp17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _e2 = tmp4_2;
          _cr2 = tmpMeta15;
          _e1 = tmp4_1;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta16 = mmc_mk_box1(0, _cr2);
          tmp17 = omc_List_all(threadData, _crefs, (modelica_fnptr) mmc_mk_box2(0,closure18_ComponentReferenceBasics_crefPrefixOf,tmpMeta16));
          if (1 /* true */ != tmp17) goto goto_2;

          _e1_1 = omc_Expression_extendArrExp(threadData, _e1, 0 /* false */, NULL);

          _tp = omc_Expression_typeof(threadData, _e2);

          tmpMeta18 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e2, _e1_1, _source);
          _stms = tmpMeta18;
          tmpMeta20 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta21 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta20, _eqKind);
          tmpMeta19 = mmc_mk_cons(tmpMeta21, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta19;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_boolean tmp29;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,9,4) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,3,1) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 3));
          
          _path = tmpMeta22;
          _expLst = tmpMeta23;
          _tp = tmpMeta25;
          _rpath = tmpMeta27;
          _varLst = tmpMeta28;
          _e2 = tmp4_2;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp29 = omc_AbsynUtil_pathEqual(threadData, _path, _rpath);
          if (1 /* true */ != tmp29) goto goto_2;

          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          tmpMeta31 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _expLst = omc_Expression_traverseExpList(threadData, _expLst, (modelica_fnptr) mmc_mk_box2(0,closure19_Expression_expandCrefs,tmpMeta31), mmc_mk_integer(((modelica_integer) 0)), NULL);

          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _e2_1 = omc_Expression_extendArrExp(threadData, _e2, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta32 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta33 = stringAppend(tmpMeta32,intString(_iuniqueEqIndex));
          tmpMeta34 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta33, _tp, tmpMeta34);

          _e1_1 = omc_Expression_crefToExp(threadData, _cr1);

          tmpMeta35 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e1_1, _e2_1, _source);
          _stms = tmpMeta35;

          tmpMeta36 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta37 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta36, _eqKind);
          _simeqn_complex = tmpMeta37;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

          _crexplst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr1);

          _exptl = omc_List_zip(threadData, _expLst, _crexplst);

          /* Pattern-matching tuple assignment */
          tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta41 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray, _source, _eqKind, mmc_mk_integer(_uniqueEqIndex), tmpMeta40, &tmpMeta38);
          _eqSystlst_nonflat = tmpMeta41;
          tmp39 = mmc_unbox_integer(tmpMeta38);
          _uniqueEqIndex = tmp39  /* pattern as ty=Integer */;

          tmpMeta42 = mmc_mk_cons(_simeqn_complex, omc_List_flatten(threadData, _eqSystlst_nonflat));
          _eqSystlst = tmpMeta42;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr1, _itempvars);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_integer tmp56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,4) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta45,9,4) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 3));
          
          _path = tmpMeta43;
          _expLst = tmpMeta44;
          _tp = tmpMeta45;
          _varLst = tmpMeta46;
          _e2 = tmp4_2;
          /* Pattern matching succeeded */
          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          tmpMeta48 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _expLst = omc_Expression_traverseExpList(threadData, _expLst, (modelica_fnptr) mmc_mk_box2(0,closure20_Expression_expandCrefs,tmpMeta48), mmc_mk_integer(((modelica_integer) 0)), NULL);

          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _e2_1 = omc_Expression_extendArrExp(threadData, _e2, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta49 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta50 = stringAppend(tmpMeta49,intString(_iuniqueEqIndex));
          tmpMeta51 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta50, _tp, tmpMeta51);

          _e1_1 = omc_Expression_crefToExp(threadData, _cr1);

          tmpMeta52 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e1_1, _e2_1, _source);
          _stms = tmpMeta52;

          tmpMeta53 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta54 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta53, _eqKind);
          _simeqn_complex = tmpMeta54;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

          _crexplst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr1);

          _exptl = omc_List_zip(threadData, _expLst, _crexplst);

          /* Pattern-matching tuple assignment */
          tmpMeta57 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta58 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray, _source, _eqKind, mmc_mk_integer(_uniqueEqIndex), tmpMeta57, &tmpMeta55);
          _eqSystlst_nonflat = tmpMeta58;
          tmp56 = mmc_unbox_integer(tmpMeta55);
          _uniqueEqIndex = tmp56  /* pattern as ty=Integer */;

          tmpMeta59 = mmc_mk_cons(_simeqn_complex, omc_List_flatten(threadData, _eqSystlst_nonflat));
          _eqSystlst = tmpMeta59;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr1, _itempvars);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_boolean tmp67;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_integer tmp77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,13,3) == 0) goto tmp3_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,9,4) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta64,3,1) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 2));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 3));
          
          _path = tmpMeta60;
          _expLst = tmpMeta61;
          _tp = tmpMeta63;
          _rpath = tmpMeta65;
          _varLst = tmpMeta66;
          _e1 = tmp4_1;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp67 = omc_AbsynUtil_pathEqual(threadData, _path, _rpath);
          if (1 /* true */ != tmp67) goto goto_2;

          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          tmpMeta69 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _expLst = omc_Expression_traverseExpList(threadData, _expLst, (modelica_fnptr) mmc_mk_box2(0,closure21_Expression_expandCrefs,tmpMeta69), mmc_mk_integer(((modelica_integer) 0)), NULL);

          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _e1_1 = omc_Expression_extendArrExp(threadData, _e1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta70 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta71 = stringAppend(tmpMeta70,intString(_iuniqueEqIndex));
          tmpMeta72 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta71, _tp, tmpMeta72);

          _e2_1 = omc_Expression_crefExp(threadData, _cr1);

          tmpMeta73 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e2_1, _e1_1, _source);
          _stms = tmpMeta73;

          tmpMeta74 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta75 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta74, _eqKind);
          _simeqn_complex = tmpMeta75;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

          _crexplst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr1);

          _exptl = omc_List_zip(threadData, _expLst, _crexplst);

          /* Pattern-matching tuple assignment */
          tmpMeta78 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta79 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray, _source, _eqKind, mmc_mk_integer(_uniqueEqIndex), tmpMeta78, &tmpMeta76);
          _eqSystlst_nonflat = tmpMeta79;
          tmp77 = mmc_unbox_integer(tmpMeta76);
          _uniqueEqIndex = tmp77  /* pattern as ty=Integer */;

          tmpMeta80 = mmc_mk_cons(_simeqn_complex, omc_List_flatten(threadData, _eqSystlst_nonflat));
          _eqSystlst = tmpMeta80;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr1, _itempvars);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_integer tmp94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,14,4) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta83,9,4) == 0) goto tmp3_end;
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta83), 3));
          
          _path = tmpMeta81;
          _expLst = tmpMeta82;
          _tp = tmpMeta83;
          _varLst = tmpMeta84;
          _e1 = tmp4_1;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          tmpMeta86 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _expLst = omc_Expression_traverseExpList(threadData, _expLst, (modelica_fnptr) mmc_mk_box2(0,closure22_Expression_expandCrefs,tmpMeta86), mmc_mk_integer(((modelica_integer) 0)), NULL);

          omc_List_foldAllValue(threadData, _expLst, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _e1_1 = omc_Expression_extendArrExp(threadData, _e1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta87 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta88 = stringAppend(tmpMeta87,intString(_iuniqueEqIndex));
          tmpMeta89 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta88, _tp, tmpMeta89);

          _e2_1 = omc_Expression_crefExp(threadData, _cr1);

          tmpMeta90 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e2_1, _e1_1, _source);
          _stms = tmpMeta90;

          tmpMeta91 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta92 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta91, _eqKind);
          _simeqn_complex = tmpMeta92;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

          _crexplst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr1);

          _exptl = omc_List_zip(threadData, _expLst, _crexplst);

          /* Pattern-matching tuple assignment */
          tmpMeta95 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta96 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray, _source, _eqKind, mmc_mk_integer(_uniqueEqIndex), tmpMeta95, &tmpMeta93);
          _eqSystlst_nonflat = tmpMeta96;
          tmp94 = mmc_unbox_integer(tmpMeta93);
          _uniqueEqIndex = tmp94  /* pattern as ty=Integer */;

          tmpMeta97 = mmc_mk_cons(_simeqn_complex, omc_List_flatten(threadData, _eqSystlst_nonflat));
          _eqSystlst = tmpMeta97;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr1, _itempvars);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta98;
          modelica_boolean tmp99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,1) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,13,3) == 0) goto tmp3_end;
          
          _e1 = tmp4_1;
          _expl = tmpMeta98;
          _e2 = tmp4_2;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _tp = omc_Expression_typeof(threadData, _e1);

          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          /* Pattern-matching assignment */
          tmp99 = omc_Expression_expHasCrefsNoPreOrStart(threadData, _e2, _crefs);
          if (0 /* false */ != tmp99) goto goto_2;

          omc_List_foldAllValue(threadData, _expl, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          tmpMeta102 = mmc_mk_box5(4, &DAE_Statement_STMT__TUPLE__ASSIGN__desc, _tp, _expl, _e2, _source);
          tmpMeta101 = mmc_mk_cons(tmpMeta102, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta103 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta101, _eqKind);
          tmpMeta100 = mmc_mk_cons(tmpMeta103, MMC_REFSTRUCTLIT(mmc_nil));
          _eqSystlst = tmpMeta100;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,1) == 0) goto tmp3_end;
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,19,1) == 0) goto tmp3_end;
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _expl = tmpMeta104;
          _expl1 = tmpMeta105;
          /* Pattern matching succeeded */
          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          omc_List_foldAllValue(threadData, _expl, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _eqnLst = omc_List_threadMap2(threadData, _expl, _expl1, boxvar_BackendEquation_generateEquation, _source, _eqKind);
          tmpMeta[0+0] = omc_SimCodeUtil_createEquationsfromList(threadData, _eqnLst, _inVars, _iuniqueEqIndex, _itempvars, _iextra, _genDiscrete, 0 /* false */, 0 /* false */, 0 /* false */, &tmp1_c1, &tmpMeta[0+2]);
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,1) == 0) goto tmp3_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,19,1) == 0) goto tmp3_end;
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _expl1 = tmpMeta106;
          _expl = tmpMeta107;
          /* Pattern matching succeeded */
          _ht = omc_HashSet_emptyHashSet(threadData);

          _ht = omc_List_fold(threadData, _crefs, boxvar_BaseHashSet_add, _ht);

          omc_List_foldAllValue(threadData, _expl, boxvar_SimCodeUtil_createSingleComplexEqnCode3, mmc_mk_boolean(1 /* true */), _ht);

          _eqnLst = omc_List_threadMap2(threadData, _expl, _expl1, boxvar_BackendEquation_generateEquation, _source, _eqKind);

          _eqSystlst = omc_SimCodeUtil_createEquationsfromList(threadData, _eqnLst, _inVars, _iuniqueEqIndex, _itempvars, _iextra, _genDiscrete, 0 /* false */, 0 /* false */, 0 /* false */ ,&_uniqueEqIndex ,NULL);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 11: {
          modelica_boolean tmp108;
          modelica_metatype tmpMeta109;
          
          _e1 = tmp4_1;
          _e2 = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp108 = omc_Flags_isSet(threadData, _OMC_LIT227);
          if (1 /* true */ != tmp108) goto goto_2;

          _s1 = omc_ExpressionBasics_printExpStr(threadData, _e1);

          _s2 = omc_ExpressionBasics_printExpStr(threadData, _e2);

          _s3 = omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _crefs);

          tmpMeta109 = mmc_mk_cons(_OMC_LIT567, mmc_mk_cons(_s1, mmc_mk_cons(_OMC_LIT224, mmc_mk_cons(_s2, mmc_mk_cons(_OMC_LIT568, mmc_mk_cons(_s3, MMC_REFSTRUCTLIT(mmc_nil)))))));
          _s = stringAppendList(tmpMeta109);

          omc_Debug_traceln(threadData, _s);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 12) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode2(threadData_t *threadData, modelica_metatype _crefs, modelica_metatype _inExp3, modelica_metatype _inExp4, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _source, modelica_metatype _eqKind, modelica_metatype _iextra, modelica_metatype _genDiscrete, modelica_metatype _inVars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_genDiscrete);
  _equations_ = omc_SimCodeUtil_createSingleComplexEqnCode2(threadData, _crefs, _inExp3, _inExp4, tmp1, _itempvars, _source, _eqKind, _iextra, tmp2, _inVars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleComplexEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_boolean _genDiscrete, modelica_metatype _funcTree, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_integer _uniqueEqIndex;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _resEqs = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_string _s = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      modelica_string _s3 = NULL;
      modelica_boolean _homotopySupport;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _uniqueEqIndex has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _source has no default value.
      // _crefs has no default value.
      // _resEqs has no default value.
      // _tempvars has no default value.
      // _s has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      // _s3 has no default value.
      // _homotopySupport has no default value.
      // _eqAttr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta6;
          _e2 = tmpMeta7;
          _source = tmpMeta8;
          _eqAttr = tmpMeta9;
          /* Pattern matching succeeded */
          _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

          _e1 = omc_Expression_replaceDerOpInExp(threadData, _e1);

          _e2 = omc_Expression_replaceDerOpInExp(threadData, _e2);
          tmpMeta[0+0] = omc_SimCodeUtil_createSingleComplexEqnCode2(threadData, _crefs, _e1, _e2, _iuniqueEqIndex, _itempvars, _source, _eqAttr, _iextra, _genDiscrete, _inVars, &tmp1_c1, &tmpMeta[0+2]);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_boolean tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta10;
          _e2 = tmpMeta11;
          _source = tmpMeta12;
          _eqAttr = tmpMeta13;
          /* Pattern matching succeeded */
          _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp14 = omc_List_mapMapBoolAnd(threadData, _crefs, boxvar_ComponentReference_crefLastType, boxvar_Types_isRealOrSubTypeReal);
          if (1 /* true */ != tmp14) goto goto_2;

          _e1 = omc_ExpressionSimplify_simplify(threadData, _e1, NULL);

          _e1 = omc_Expression_replaceDerOpInExp(threadData, _e1);

          _e2 = omc_ExpressionSimplify_simplify(threadData, _e2, NULL);

          _e2 = omc_Expression_replaceDerOpInExp(threadData, _e2);

          _resEqs = omc_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData, _e1, _e2, _source, _eqAttr, _iuniqueEqIndex, _itempvars, _crefs ,&_uniqueEqIndex ,&_tempvars ,&_crefs);

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_BackendEquation_traverseExpsOfEquation(threadData, _inEquation, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta15);
          tmp16 = mmc_unbox_integer(tmpMeta15);
          _homotopySupport = tmp16  /* pattern as ty=Boolean */;
          tmpMeta18 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _resEqs, _crefs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_inVars) + listLength(_tempvars) - listLength(_itempvars)), mmc_mk_none(), mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), _clockIndex);
          tmpMeta19 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta18, mmc_mk_none(), _eqAttr);
          tmpMeta17 = mmc_mk_cons(tmpMeta19, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta17;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta20;
          modelica_boolean tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _eqAttr = tmpMeta20;
          /* Pattern matching succeeded */
          _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp21 = omc_List_mapMapBoolAnd(threadData, _crefs, boxvar_ComponentReference_crefLastType, boxvar_Types_isRealOrSubTypeReal);
          if (1 /* true */ != tmp21) goto goto_2;

          /* Pattern-matching tuple assignment */
          tmpMeta26 = mmc_mk_cons(_inEquation, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta27 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta28 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, tmpMeta26, tmpMeta27, _itempvars, _funcTree, &tmpMeta22, &tmpMeta25);
          _resEqs = tmpMeta28;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          _uniqueEqIndex = tmp24  /* pattern as ty=Integer */;
          _tempvars = tmpMeta25;

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_BackendEquation_traverseExpsOfEquation(threadData, _inEquation, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta29);
          tmp30 = mmc_unbox_integer(tmpMeta29);
          _homotopySupport = tmp30  /* pattern as ty=Boolean */;
          tmpMeta32 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _resEqs, _crefs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_inVars) + listLength(_tempvars) - listLength(_itempvars)), mmc_mk_none(), mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), _clockIndex);
          tmpMeta33 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta32, mmc_mk_none(), _eqAttr);
          tmpMeta31 = mmc_mk_cons(tmpMeta33, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta31;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_boolean tmp36;
          modelica_metatype tmpMeta37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta34;
          _e2 = tmpMeta35;
          /* Pattern matching succeeded */
          _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp36 = omc_List_mapMapBoolAnd(threadData, _crefs, boxvar_ComponentReference_crefLastType, boxvar_Types_isRealOrSubTypeReal);
          if (0 /* false */ != tmp36) goto goto_2;

          _s1 = omc_ExpressionBasics_printExpStr(threadData, _e1);

          _s2 = omc_ExpressionBasics_printExpStr(threadData, _e2);

          _s3 = omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _crefs);

          tmpMeta37 = mmc_mk_cons(_OMC_LIT569, mmc_mk_cons(_s1, mmc_mk_cons(_OMC_LIT224, mmc_mk_cons(_s2, mmc_mk_cons(_OMC_LIT568, mmc_mk_cons(_s3, MMC_REFSTRUCTLIT(mmc_nil)))))));
          _s = stringAppendList(tmpMeta37);

          omc_Error_addInternalError(threadData, _s, _OMC_LIT570);
          goto goto_2;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_boolean tmp40;
          modelica_metatype tmpMeta41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta38;
          _e2 = tmpMeta39;
          /* Pattern matching succeeded */
          _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

          /* Pattern-matching assignment */
          tmp40 = omc_List_mapMapBoolAnd(threadData, _crefs, boxvar_ComponentReference_crefLastType, boxvar_Types_isRealOrSubTypeReal);
          if (1 /* true */ != tmp40) goto goto_2;

          _s1 = omc_ExpressionBasics_printExpStr(threadData, _e1);

          _s2 = omc_ExpressionBasics_printExpStr(threadData, _e2);

          _s3 = omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _crefs);

          tmpMeta41 = mmc_mk_cons(_OMC_LIT571, mmc_mk_cons(_s1, mmc_mk_cons(_OMC_LIT224, mmc_mk_cons(_s2, mmc_mk_cons(_OMC_LIT568, mmc_mk_cons(_s3, MMC_REFSTRUCTLIT(mmc_nil)))))));
          _s = stringAppendList(tmpMeta41);

          omc_Error_addInternalError(threadData, _s, _OMC_LIT572);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleComplexEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_metatype _genDiscrete, modelica_metatype _funcTree, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_genDiscrete);
  _equations_ = omc_SimCodeUtil_createSingleComplexEqnCode(threadData, _inEquation, _inVars, tmp1, _itempvars, _iextra, tmp2, _funcTree, _clockIndex, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createEquationsfromList(threadData_t *threadData, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_boolean _genDiscrete, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _skipDiscInAlgorithm, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEquations;
    {
      modelica_metatype _vars1 = NULL;
      modelica_metatype _eqns_1 = NULL;
      modelica_metatype _subsystem_dae = NULL;
      modelica_metatype _comps = NULL;
      modelica_metatype _syst = NULL;
      modelica_metatype _shared = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _tempvars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars1 has no default value.
      // _eqns_1 has no default value.
      // _subsystem_dae has no default value.
      // _comps has no default value.
      // _syst has no default value.
      // _shared has no default value.
      // _uniqueEqIndex has no default value.
      // _tempvars has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta6;
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          
          /* Pattern matching succeeded */
          _eqns_1 = omc_BackendEquation_listEquation(threadData, _inEquations);

          _vars1 = omc_BackendVariable_listVar1(threadData, _inVars);

          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          _syst = omc_BackendDAEUtil_createEqSystem(threadData, _vars1, _eqns_1, tmpMeta7, _OMC_LIT521, omc_BackendEquation_emptyEqns(threadData));

          _shared = omc_BackendDAEUtil_createEmptyShared(threadData, _OMC_LIT573, _iextra, omc_FCore_emptyCache(threadData), omc_FGraph_empty(threadData));

          tmpMeta8 = mmc_mk_cons(_syst, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta9 = mmc_mk_box3(3, &BackendDAE_BackendDAE_DAE__desc, tmpMeta8, _shared);
          _subsystem_dae = tmpMeta9;

          /* Pattern-matching assignment */
          tmpMeta10 = omc_BackendDAEUtil_transformBackendDAE(threadData, _subsystem_dae, _OMC_LIT577, mmc_mk_none(), mmc_mk_none());
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          if (listEmpty(tmpMeta11)) goto goto_2;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,1,3) == 0) goto goto_2;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 4));
          if (!listEmpty(tmpMeta13)) goto goto_2;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
          _syst = tmpMeta12;
          _comps = tmpMeta15;
          _shared = tmpMeta16;

          _equations_ = omc_SimCodeUtil_createEquations(threadData, _includeWhen, _skipDiscInZc, _genDiscrete, _skipDiscInAlgorithm, _syst, _shared, _comps, _iuniqueEqIndex, _itempvars ,NULL ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta[0+0] = _equations_;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT578, _OMC_LIT579);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
modelica_metatype boxptr_SimCodeUtil_createEquationsfromList(threadData_t *threadData, modelica_metatype _inEquations, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iextra, modelica_metatype _genDiscrete, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _skipDiscInAlgorithm, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_genDiscrete);
  tmp3 = mmc_unbox_integer(_includeWhen);
  tmp4 = mmc_unbox_integer(_skipDiscInZc);
  tmp5 = mmc_unbox_integer(_skipDiscInAlgorithm);
  _equations_ = omc_SimCodeUtil_createEquationsfromList(threadData, _inEquations, _inVars, tmp1, _itempvars, _iextra, tmp2, tmp3, tmp4, tmp5, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createEquationsfromBackendDAE(threadData_t *threadData, modelica_metatype _inBDAE, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_boolean _genDiscrete, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _skipDiscInAlgorithm, modelica_integer *out_uniqueEqIndex, modelica_metatype *out_tempvars)
{
  modelica_metatype _outEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _tempvars = NULL;
  modelica_metatype _comps = NULL;
  modelica_metatype _simEqs = NULL;
  modelica_metatype _zeroVarEquations = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEquations = tmpMeta1;
  _uniqueEqIndex = _iuniqueEqIndex;
  _tempvars = _itempvars;
  // _comps has no default value.
  // _simEqs has no default value.
  // _zeroVarEquations has no default value.
  {
    modelica_metatype _syst;
    for (tmpMeta2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inBDAE), 2))); !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _syst = MMC_CAR(tmpMeta2);
      _comps = omc_BackendDAEUtil_getCompsOfMatching(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 7))));

      _simEqs = omc_SimCodeUtil_createEquations(threadData, _includeWhen, _skipDiscInZc, _genDiscrete, _skipDiscInAlgorithm, _syst, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inBDAE), 3))), _comps, _uniqueEqIndex, _tempvars ,NULL ,&_uniqueEqIndex ,&_tempvars);

      /* Pattern-matching assignment */
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      tmpMeta4 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta3);
      tmpMeta5 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 10))), boxvar_SimCodeUtil_traversedlowEqToSimEqSystem, tmpMeta4);
      tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 1));
      tmp7 = mmc_unbox_integer(tmpMeta6);
      tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
      _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
      _zeroVarEquations = tmpMeta8;

      tmpMeta9 = mmc_mk_cons(listAppend(_simEqs, _zeroVarEquations), _outEquations);
      _outEquations = tmpMeta9;
    }
  }

  _outEquations = listReverseInPlace(_outEquations);
  _return: OMC_LABEL_UNUSED
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  if (out_tempvars) { *out_tempvars = _tempvars; }
  return _outEquations;
}
modelica_metatype boxptr_SimCodeUtil_createEquationsfromBackendDAE(threadData_t *threadData, modelica_metatype _inBDAE, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _genDiscrete, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _skipDiscInAlgorithm, modelica_metatype *out_uniqueEqIndex, modelica_metatype *out_tempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _outEquations = NULL;
  modelica_metatype tmpMeta6;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_genDiscrete);
  tmp3 = mmc_unbox_integer(_includeWhen);
  tmp4 = mmc_unbox_integer(_skipDiscInZc);
  tmp5 = mmc_unbox_integer(_skipDiscInAlgorithm);
  _outEquations = omc_SimCodeUtil_createEquationsfromBackendDAE(threadData, _inBDAE, tmp1, _itempvars, tmp2, tmp3, tmp4, tmp5, &_uniqueEqIndex, out_tempvars);
  /* skip box _outEquations; list<list<SimCode.SimEqSystem>> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  /* skip box _tempvars; list<SimCodeVar.SimVar> */
  return _outEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsIfBranch(threadData_t *threadData, modelica_metatype _inConditions, modelica_metatype _inEquationsLst, modelica_metatype _inVars, modelica_metatype _shared, modelica_boolean _genDiscrete, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _outEquations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquations has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _inConditions;
    tmp4_2 = _inEquationsLst;
    tmp4_3 = _shared;
    {
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqnsLst = NULL;
      modelica_metatype _condition = NULL;
      modelica_metatype _conditionList = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _equations_ = NULL;
      modelica_metatype _ifbranch = NULL;
      modelica_metatype _ifbranches = NULL;
      modelica_metatype _ei = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqns has no default value.
      // _eqnsLst has no default value.
      // _condition has no default value.
      // _conditionList has no default value.
      // _tempvars has no default value.
      // _uniqueEqIndex has no default value.
      // _equations_ has no default value.
      // _ifbranch has no default value.
      // _ifbranches has no default value.
      // _ei has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta6;
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_2);
          tmpMeta10 = MMC_CDR(tmp4_2);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 17));
          
          _condition = tmpMeta7;
          _conditionList = tmpMeta8;
          _eqns = tmpMeta9;
          _eqnsLst = tmpMeta10;
          _ei = tmpMeta11;
          /* Pattern matching succeeded */
          _equations_ = omc_SimCodeUtil_createEquationsfromList(threadData, _eqns, _inVars, _iuniqueEqIndex, _itempvars, _ei, _genDiscrete, 0 /* false */, 0 /* false */, 0 /* false */ ,&_uniqueEqIndex ,&_tempvars);

          tmpMeta12 = mmc_mk_box2(0, _condition, _equations_);
          _ifbranch = tmpMeta12;

          _ifbranches = omc_SimCodeUtil_createEquationsIfBranch(threadData, _conditionList, _eqnsLst, _inVars, _shared, _genDiscrete, _uniqueEqIndex, _tempvars ,&_uniqueEqIndex ,&_tempvars);

          tmpMeta13 = mmc_mk_cons(_ifbranch, _ifbranches);
          _ifbranches = tmpMeta13;
          tmpMeta[0+0] = _ifbranches;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT578, _OMC_LIT580);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outEquations = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _outEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsIfBranch(threadData_t *threadData, modelica_metatype _inConditions, modelica_metatype _inEquationsLst, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _genDiscrete, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outEquations = NULL;
  tmp1 = mmc_unbox_integer(_genDiscrete);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _outEquations = omc_SimCodeUtil_createEquationsIfBranch(threadData, _inConditions, _inEquationsLst, _inVars, _shared, tmp1, tmp2, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _outEquations; list<tuple<DAE.Exp, list<SimCode.SimEqSystem>>> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _outEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleIfEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_boolean _genDiscrete, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inEquation;
    tmp4_2 = _shared;
    {
      modelica_metatype _conditions = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _eqnsLst = NULL;
      modelica_metatype _elseqns = NULL;
      modelica_metatype _ifbranches = NULL;
      modelica_metatype _source_ = NULL;
      modelica_metatype _ei = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _conditions has no default value.
      // _uniqueEqIndex has no default value.
      // _tempvars has no default value.
      // _eqnsLst has no default value.
      // _elseqns has no default value.
      // _ifbranches has no default value.
      // _source_ has no default value.
      // _ei has no default value.
      // _eqAttr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 17));
          
          _conditions = tmpMeta6;
          _eqnsLst = tmpMeta7;
          _elseqns = tmpMeta8;
          _source_ = tmpMeta9;
          _eqAttr = tmpMeta10;
          _ei = tmpMeta11;
          /* Pattern matching succeeded */
          _ifbranches = omc_SimCodeUtil_createEquationsIfBranch(threadData, _conditions, _eqnsLst, _inVars, _shared, _genDiscrete, _iuniqueEqIndex, _itempvars ,&_uniqueEqIndex ,&_tempvars);

          _equations_ = omc_SimCodeUtil_createEquationsfromList(threadData, _elseqns, _inVars, _uniqueEqIndex, _tempvars, _ei, _genDiscrete, 0 /* false */, 0 /* false */, 0 /* false */ ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta13 = mmc_mk_box6(12, &SimCode_SimEqSystem_SES__IFEQUATION__desc, mmc_mk_integer(_uniqueEqIndex), _ifbranches, _equations_, _source_, _eqAttr);
          tmpMeta12 = mmc_mk_cons(tmpMeta13, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta12;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT581, _OMC_LIT582);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleIfEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _genDiscrete, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_genDiscrete);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createSingleIfEqnCode(threadData, _inEquation, _inVars, _shared, tmp1, tmp2, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

static modelica_metatype closure23_ComponentReferenceBasics_crefPrefixOf(threadData_t *thData, modelica_metatype closure, modelica_metatype fullCref)
{
  modelica_metatype prefixCref = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefPrefixOf(thData, prefixCref, fullCref);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createElseWhenEquation(threadData_t *threadData, modelica_metatype _inElseWhenEquation, modelica_metatype _inVars, modelica_integer _iuniqueEqIndex, modelica_metatype _inElementSource, modelica_metatype _inEqAttr, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outSimEqSystem = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqSystem has no default value.
  // _ouniqueEqIndex has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inElseWhenEquation;
    {
      modelica_metatype _left = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _elseWhenEquation = NULL;
      modelica_metatype _oelseWhenEquation = NULL;
      modelica_metatype _simElseWhenEq = NULL;
      modelica_metatype _osimElseWhenEq = NULL;
      modelica_metatype _conditions = NULL;
      modelica_boolean _initialCall;
      modelica_metatype _whenStmtLst = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _crefs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _left has no default value.
      // _cond has no default value.
      // _elseWhenEquation has no default value.
      // _oelseWhenEquation has no default value.
      // _simElseWhenEq has no default value.
      // _osimElseWhenEq has no default value.
      // _conditions has no default value.
      // _initialCall has no default value.
      // _whenStmtLst has no default value.
      // _uniqueEqIndex has no default value.
      // _crefs has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _cond = tmpMeta6;
          _whenStmtLst = tmpMeta7;
          _oelseWhenEquation = tmpMeta8;
          /* Pattern matching succeeded */
          {
            modelica_metatype _stmt;
            for (tmpMeta9 = _whenStmtLst; !listEmpty(tmpMeta9); tmpMeta9=MMC_CDR(tmpMeta9))
            {
              _stmt = MMC_CAR(tmpMeta9);
              { /* match expression */
                modelica_metatype tmp12_1;
                tmp12_1 = _stmt;
                {
                  volatile mmc_switch_type tmp12;
                  int tmp13;
                  tmp12 = 0;
                  for (; tmp12 < 2; tmp12++) {
                    switch (MMC_SWITCH_CAST(tmp12)) {
                    case 0: {
                      modelica_metatype tmpMeta14;
                      modelica_metatype tmpMeta15;
                      modelica_metatype tmpMeta16;
                      modelica_boolean tmp17;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp12_1,0,3) == 0) goto tmp11_end;
                      tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp12_1), 2));
                      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,6,2) == 0) goto tmp11_end;
                      tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
                      
                      _left = tmpMeta15;
                      /* Pattern matching succeeded */
                      _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

                      /* Pattern-matching assignment */
                      tmpMeta16 = mmc_mk_box1(0, _left);
                      tmp17 = omc_List_all(threadData, _crefs, (modelica_fnptr) mmc_mk_box2(0,closure23_ComponentReferenceBasics_crefPrefixOf,tmpMeta16));
                      if (1 /* true */ != tmp17) goto goto_10;
                      goto tmp11_done;
                    }
                    case 1: {
                      
                      /* Pattern matching succeeded */
                      goto tmp11_done;
                    }
                    }
                    goto tmp11_end;
                    tmp11_end: ;
                  }
                  goto goto_10;
                  goto_10:;
                  goto goto_2;
                  goto tmp11_done;
                  tmp11_done:;
                }
              }
              ;
            }
          }

          if(isSome(_oelseWhenEquation))
          {
            /* Pattern-matching assignment */
            tmpMeta19 = _oelseWhenEquation;
            if (optionNone(tmpMeta19)) goto goto_2;
            tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 1));
            _elseWhenEquation = tmpMeta20;

            _simElseWhenEq = omc_SimCodeUtil_createElseWhenEquation(threadData, _elseWhenEquation, _inVars, ((modelica_integer) 1) + _iuniqueEqIndex, _inElementSource, _inEqAttr ,&_uniqueEqIndex);

            _osimElseWhenEq = mmc_mk_some(_simElseWhenEq);
          }
          else
          {
            _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

            _osimElseWhenEq = mmc_mk_none();
          }

          _conditions = omc_BackendDAEUtil_getConditionList(threadData, _cond ,&_initialCall);
          tmpMeta21 = mmc_mk_box8(18, &SimCode_SimEqSystem_SES__WHEN__desc, mmc_mk_integer(_iuniqueEqIndex), _conditions, mmc_mk_boolean(_initialCall), _whenStmtLst, _osimElseWhenEq, _inElementSource, _inEqAttr);
          tmpMeta[0+0] = tmpMeta21;
          tmp1_c1 = _uniqueEqIndex;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outSimEqSystem = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outSimEqSystem;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createElseWhenEquation(threadData_t *threadData, modelica_metatype _inElseWhenEquation, modelica_metatype _inVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _inElementSource, modelica_metatype _inEqAttr, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outSimEqSystem = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outSimEqSystem = omc_SimCodeUtil_createElseWhenEquation(threadData, _inElseWhenEquation, _inVars, tmp1, _inElementSource, _inEqAttr, &_ouniqueEqIndex);
  /* skip box _outSimEqSystem; SimCode.SimEqSystem */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outSimEqSystem;
}

static modelica_metatype closure24_ComponentReferenceBasics_crefPrefixOf(threadData_t *thData, modelica_metatype closure, modelica_metatype fullCref)
{
  modelica_metatype prefixCref = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefPrefixOf(thData, prefixCref, fullCref);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createSingleWhenEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _cond = NULL;
      modelica_metatype _left = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _elseWhen = NULL;
      modelica_metatype _conditions = NULL;
      modelica_boolean _initialCall;
      modelica_metatype _whenStmtLst = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _oelseWhen = NULL;
      modelica_metatype _simElseWhenEq = NULL;
      modelica_metatype _osimElseWhenEq = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cond has no default value.
      // _left has no default value.
      // _source has no default value.
      // _crefs has no default value.
      // _elseWhen has no default value.
      // _conditions has no default value.
      // _initialCall has no default value.
      // _whenStmtLst has no default value.
      // _uniqueEqIndex has no default value.
      // _oelseWhen has no default value.
      // _simElseWhenEq has no default value.
      // _osimElseWhenEq has no default value.
      // _eqAttr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _cond = tmpMeta7;
          _whenStmtLst = tmpMeta8;
          _oelseWhen = tmpMeta9;
          _source = tmpMeta10;
          _eqAttr = tmpMeta11;
          /* Pattern matching succeeded */
          {
            modelica_metatype _stmt;
            for (tmpMeta12 = _whenStmtLst; !listEmpty(tmpMeta12); tmpMeta12=MMC_CDR(tmpMeta12))
            {
              _stmt = MMC_CAR(tmpMeta12);
              { /* match expression */
                modelica_metatype tmp15_1;
                tmp15_1 = _stmt;
                {
                  volatile mmc_switch_type tmp15;
                  int tmp16;
                  tmp15 = 0;
                  for (; tmp15 < 2; tmp15++) {
                    switch (MMC_SWITCH_CAST(tmp15)) {
                    case 0: {
                      modelica_metatype tmpMeta17;
                      modelica_metatype tmpMeta18;
                      modelica_metatype tmpMeta19;
                      modelica_boolean tmp20;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,0,3) == 0) goto tmp14_end;
                      tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 2));
                      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,6,2) == 0) goto tmp14_end;
                      tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
                      
                      _left = tmpMeta18;
                      /* Pattern matching succeeded */
                      _crefs = omc_List_map(threadData, _inVars, boxvar_BackendVariable_varCref);

                      /* Pattern-matching assignment */
                      tmpMeta19 = mmc_mk_box1(0, _left);
                      tmp20 = omc_List_all(threadData, _crefs, (modelica_fnptr) mmc_mk_box2(0,closure24_ComponentReferenceBasics_crefPrefixOf,tmpMeta19));
                      if (1 /* true */ != tmp20) goto goto_13;
                      goto tmp14_done;
                    }
                    case 1: {
                      
                      /* Pattern matching succeeded */
                      goto tmp14_done;
                    }
                    }
                    goto tmp14_end;
                    tmp14_end: ;
                  }
                  goto goto_13;
                  goto_13:;
                  goto goto_2;
                  goto tmp14_done;
                  tmp14_done:;
                }
              }
              ;
            }
          }

          if(isSome(_oelseWhen))
          {
            /* Pattern-matching assignment */
            tmpMeta22 = _oelseWhen;
            if (optionNone(tmpMeta22)) goto goto_2;
            tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
            _elseWhen = tmpMeta23;

            _simElseWhenEq = omc_SimCodeUtil_createElseWhenEquation(threadData, _elseWhen, _inVars, ((modelica_integer) 1) + _iuniqueEqIndex, _source, _eqAttr ,&_uniqueEqIndex);

            _osimElseWhenEq = mmc_mk_some(_simElseWhenEq);
          }
          else
          {
            _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

            _osimElseWhenEq = mmc_mk_none();
          }

          _conditions = omc_BackendDAEUtil_getConditionList(threadData, _cond ,&_initialCall);
          tmpMeta25 = mmc_mk_box8(18, &SimCode_SimEqSystem_SES__WHEN__desc, mmc_mk_integer(_iuniqueEqIndex), _conditions, mmc_mk_boolean(_initialCall), _whenStmtLst, _osimElseWhenEq, _source, _eqAttr);
          tmpMeta24 = mmc_mk_cons(tmpMeta25, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta24;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT583, _OMC_LIT584);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createSingleWhenEqnCode(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars, modelica_metatype _shared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createSingleWhenEqnCode(threadData, _inEquation, _inVars, _shared, tmp1, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_simJacCSRToCSC(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2)
{
  modelica_boolean _isGt;
  modelica_integer _r1;
  modelica_integer _r2;
  modelica_integer _c1;
  modelica_integer _c2;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_integer tmp8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isGt has no default value.
  // _r1 has no default value.
  // _r2 has no default value.
  // _c1 has no default value.
  // _c2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _e1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _r1 = tmp3  /* pattern as ty=Integer */;
  _c1 = tmp5  /* pattern as ty=Integer */;

  /* Pattern-matching assignment */
  tmpMeta6 = _e2;
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
  tmp8 = mmc_unbox_integer(tmpMeta7);
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  _r2 = tmp8  /* pattern as ty=Integer */;
  _c2 = tmp10  /* pattern as ty=Integer */;

  if((_c1 != _c2))
  {
    _isGt = (_c1 > _c2);
  }
  else
  {
    _isGt = (_r1 > _r2);
  }
  _return: OMC_LABEL_UNUSED
  return _isGt;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_simJacCSRToCSC(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2)
{
  modelica_boolean _isGt;
  modelica_metatype out_isGt;
  _isGt = omc_SimCodeUtil_simJacCSRToCSC(threadData, _e1, _e2);
  out_isGt = mmc_mk_icon(_isGt);
  return out_isGt;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_jacToSimjac(threadData_t *threadData, modelica_metatype _jac, modelica_metatype _v)
{
  modelica_metatype _simJac = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simJac has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _jac;
    {
      modelica_integer _row;
      modelica_integer _col;
      modelica_metatype _e = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _row has no default value.
      // _col has no default value.
      // _e has no default value.
      // _source has no default value.
      // _eqAttr has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,3) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 4));
          _row = tmp7  /* pattern as ty=Integer */;
          _col = tmp9  /* pattern as ty=Integer */;
          _e = tmpMeta11;
          _source = tmpMeta12;
          _eqAttr = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta14 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), _e, _source, _eqAttr);
          tmpMeta15 = mmc_mk_box3(0, mmc_mk_integer(((modelica_integer) -1) + _row), mmc_mk_integer(((modelica_integer) -1) + _col), tmpMeta14);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _simJac = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simJac;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_traversingisVarDiscreteCrefFinder(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _v = NULL;
      modelica_metatype _cr_lst = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _cr_lst has no default value.
      // _cr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_boolean tmp6;
          modelica_metatype tmpMeta7;
          
          _v = tmp4_1;
          _cr_lst = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp6 = omc_BackendVariable_isVarDiscrete(threadData, _v);
          if (1 /* true */ != tmp6) goto goto_2;

          _cr = omc_BackendVariable_varCref(threadData, _v);
          tmpMeta7 = mmc_mk_cons(_cr, _cr_lst);
          tmpMeta[0+0] = _v;
          tmpMeta[0+1] = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_extractDiscreteModelVars(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _discreteModelVars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _discreteModelVars has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _syst;
    {
      modelica_metatype _v = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _v = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendVariable_traverseBackendDAEVars(threadData, _v, boxvar_SimCodeUtil_traversingisVarDiscreteCrefFinder, _acc);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT585, _OMC_LIT586);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _discreteModelVars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _discreteModelVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_traversedlowEqToSimEqSystem(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outEq = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEq has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inEq;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _se = NULL;
      modelica_metatype _seqnlst = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _se has no default value.
      // _seqnlst has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _e = tmp4_1;
          _uniqueEqIndex = tmp7  /* pattern as ty=Integer */;
          _seqnlst = tmpMeta8;
          /* Pattern matching succeeded */
          _se = omc_SimCodeUtil_dlowEqToSimEqSystem(threadData, _e, _uniqueEqIndex ,&_uniqueEqIndex);
          tmpMeta9 = mmc_mk_cons(_se, _seqnlst);
          tmpMeta10 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta9);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = tmpMeta10;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inEq;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outEq = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outEq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAlgorithmAndEquationAsserts(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _acc)
{
  modelica_metatype _algorithmAndEquationAsserts = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _algorithmAndEquationAsserts has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _syst;
    tmp4_2 = _shared;
    tmp4_3 = _acc;
    {
      modelica_metatype _simeqns = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _result = NULL;
      modelica_integer _uniqueEqIndex;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _simeqns has no default value.
      // _res has no default value.
      // _vars has no default value.
      // _result has no default value.
      // _uniqueEqIndex has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          _vars = tmpMeta6;
          _uniqueEqIndex = tmp8  /* pattern as ty=Integer */;
          _simeqns = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          _res = omc_BackendVariable_traverseBackendDAEVars(threadData, _vars, boxvar_BackendVariable_getMinMaxAsserts, tmpMeta10);

          /* Pattern-matching tuple assignment */
          tmpMeta13 = omc_List_mapFold(threadData, _res, boxvar_SimCodeUtil_dlowAlgToSimEqSystem, mmc_mk_integer(_uniqueEqIndex), &tmpMeta11);
          _result = tmpMeta13;
          tmp12 = mmc_unbox_integer(tmpMeta11);
          _uniqueEqIndex = tmp12  /* pattern as ty=Integer */;
          tmpMeta14 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), listAppend(_result, _simeqns));
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT587, _OMC_LIT588);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _algorithmAndEquationAsserts = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _algorithmAndEquationAsserts;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_extractExtObjInfo2(threadData_t *threadData, modelica_metatype _varLst, modelica_metatype _evars, modelica_metatype *out_aliases)
{
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _aliases = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta16;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _vars = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _aliases = tmpMeta2;
  {
    modelica_metatype _bv;
    for (tmpMeta3 = _varLst; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _bv = MMC_CAR(tmpMeta3);
      { /* match expression */
        modelica_metatype tmp6_1;
        tmp6_1 = _bv;
        {
          modelica_metatype _cr = NULL;
          modelica_metatype _name = NULL;
          modelica_metatype _sv = NULL;
          volatile mmc_switch_type tmp6;
          int tmp7;
          // _cr has no default value.
          // _name has no default value.
          // _sv has no default value.
          tmp6 = 0;
          for (; tmp6 < 2; tmp6++) {
            switch (MMC_SWITCH_CAST(tmp6)) {
            case 0: {
              modelica_metatype tmpMeta8;
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              modelica_metatype tmpMeta11;
              modelica_metatype tmpMeta12;
              modelica_metatype tmpMeta13;
              modelica_metatype tmpMeta14;
              tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 2));
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 3));
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,9,1) == 0) goto tmp5_end;
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 7));
              if (optionNone(tmpMeta10)) goto tmp5_end;
              tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,6,2) == 0) goto tmp5_end;
              tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
              
              _name = tmpMeta8;
              _cr = tmpMeta12;
              /* Pattern matching succeeded */
              tmpMeta14 = mmc_mk_box2(0, _name, _cr);
              tmpMeta13 = mmc_mk_cons(tmpMeta14, _aliases);
              _aliases = tmpMeta13;
              goto tmp5_done;
            }
            case 1: {
              modelica_metatype tmpMeta15;
              
              /* Pattern matching succeeded */
              _sv = omc_SimCodeUtil_dlowvarToSimvar(threadData, _bv, mmc_mk_none(), _evars, mmc_mk_none());

              tmpMeta15 = mmc_mk_cons(_sv, _vars);
              _vars = tmpMeta15;
              goto tmp5_done;
            }
            }
            goto tmp5_end;
            tmp5_end: ;
          }
          goto goto_4;
          goto_4:;
          MMC_THROW_INTERNAL();
          goto tmp5_done;
          tmp5_done:;
        }
      }
      ;
    }
  }

  _vars = listReverseInPlace(_vars);

  _aliases = listReverseInPlace(_aliases);
  _return: OMC_LABEL_UNUSED
  if (out_aliases) { *out_aliases = _aliases; }
  return _vars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_orderExtVars(threadData_t *threadData, modelica_metatype _varLstIn, modelica_boolean _isInitial)
{
  modelica_metatype _varLstOut = NULL;
  modelica_metatype _order = NULL;
  modelica_metatype _ass1 = NULL;
  modelica_metatype _ass2 = NULL;
  modelica_metatype _comps = NULL;
  modelica_metatype _varsWithBind = NULL;
  modelica_metatype _varsWithoutBind = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _varLstOut has no default value.
  // _order has no default value.
  // _ass1 has no default value.
  // _ass2 has no default value.
  // _comps has no default value.
  // _varsWithBind has no default value.
  // _varsWithoutBind has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          /* Pattern matching succeeded */
          _varsWithBind = omc_List_separateOnTrue(threadData, _varLstIn, boxvar_BackendVariable_varHasBindExp ,&_varsWithoutBind);

          _comps = omc_BackendDAEUtil_causalizeVarBindSystem(threadData, _varsWithBind, _isInitial ,&_ass1 ,&_ass2);

          _order = omc_List_map1(threadData, omc_List_flatten(threadData, _comps), boxvar_Array_getIndexFirst, _ass1);

          _varsWithBind = omc_List_map1(threadData, _order, boxvar_List_getIndexFirst, _varsWithBind);

          _varLstOut = listAppend(_varsWithoutBind, _varsWithBind);
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          _varLstOut = _varLstIn;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _varLstOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_orderExtVars(threadData_t *threadData, modelica_metatype _varLstIn, modelica_metatype _isInitial)
{
  modelica_integer tmp1;
  modelica_metatype _varLstOut = NULL;
  tmp1 = mmc_unbox_integer(_isInitial);
  _varLstOut = omc_SimCodeUtil_orderExtVars(threadData, _varLstIn, tmp1);
  /* skip box _varLstOut; list<BackendDAE.Var> */
  return _varLstOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createExtObjInfo(threadData_t *threadData, modelica_metatype _shared)
{
  modelica_metatype _extObjInfo = NULL;
  modelica_metatype _evars = NULL;
  modelica_metatype _evarLst = NULL;
  modelica_metatype _aliases = NULL;
  modelica_metatype _simvars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _extObjInfo has no default value.
  // _evars has no default value.
  // _evarLst has no default value.
  // _aliases has no default value.
  // _simvars has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _shared;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _evars = tmpMeta2;

  _evarLst = omc_BackendVariable_varList(threadData, _evars);

  _evarLst = omc_SimCodeUtil_orderExtVars(threadData, _evarLst, omc_BackendDAEUtil_isInitializationDAE(threadData, _shared));

  _simvars = omc_SimCodeUtil_extractExtObjInfo2(threadData, _evarLst, _evars ,&_aliases);

  tmpMeta3 = mmc_mk_box3(3, &SimCode_ExtObjInfo_EXTOBJINFO__desc, _simvars, _aliases);
  _extObjInfo = tmpMeta3;
  _return: OMC_LABEL_UNUSED
  return _extObjInfo;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_extractSpatialDistributionInfoExp(threadData_t *threadData, modelica_metatype __omcQ_24in_5FcallExp, modelica_metatype __omcQ_24in_5FspatialInfo, modelica_metatype _maxIndex_ptr, modelica_metatype *out_spatialInfo)
{
  modelica_metatype _callExp = NULL;
  modelica_metatype _spatialInfo = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _callExp = __omcQ_24in_5FcallExp;
  _spatialInfo = __omcQ_24in_5FspatialInfo;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _callExp;
    {
      modelica_integer _i;
      modelica_integer _initSize;
      modelica_metatype _in0 = NULL;
      modelica_metatype _in1 = NULL;
      modelica_metatype _pos = NULL;
      modelica_metatype _dir = NULL;
      modelica_metatype _initPnts = NULL;
      modelica_metatype _initVals = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _i has no default value.
      // _initSize has no default value.
      // _in0 has no default value.
      // _in1 has no default value.
      // _pos has no default value.
      // _dir has no default value.
      // _initPnts has no default value.
      // _initVals has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (19 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT591), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmpMeta8);
          tmpMeta10 = MMC_CDR(tmpMeta8);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          if (listEmpty(tmpMeta10)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmpMeta10);
          tmpMeta14 = MMC_CDR(tmpMeta10);
          if (listEmpty(tmpMeta14)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmpMeta14);
          tmpMeta16 = MMC_CDR(tmpMeta14);
          if (listEmpty(tmpMeta16)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmpMeta16);
          tmpMeta18 = MMC_CDR(tmpMeta16);
          if (listEmpty(tmpMeta18)) goto tmp3_end;
          tmpMeta19 = MMC_CAR(tmpMeta18);
          tmpMeta20 = MMC_CDR(tmpMeta18);
          if (listEmpty(tmpMeta20)) goto tmp3_end;
          tmpMeta21 = MMC_CAR(tmpMeta20);
          tmpMeta22 = MMC_CDR(tmpMeta20);
          if (listEmpty(tmpMeta22)) goto tmp3_end;
          tmpMeta23 = MMC_CAR(tmpMeta22);
          tmpMeta24 = MMC_CDR(tmpMeta22);
          if (!listEmpty(tmpMeta24)) goto tmp3_end;
          
          _i = tmp12  /* pattern as ty=Integer */;
          _in0 = tmpMeta13;
          _in1 = tmpMeta15;
          _pos = tmpMeta17;
          _dir = tmpMeta19;
          _initPnts = tmpMeta21;
          _initVals = tmpMeta23;
          /* Pattern matching succeeded */
          if((_i > mmc_unbox_integer(omc_Mutable_access(threadData, _maxIndex_ptr))))
          {
            omc_Mutable_update(threadData, _maxIndex_ptr, mmc_mk_integer(_i));
          }

          if((!(omc_Expression_sizeOf(threadData, omc_Expression_typeof(threadData, _initPnts)) == omc_Expression_sizeOf(threadData, omc_Expression_typeof(threadData, _initVals)))))
          {
            omc_Error_addInternalError(threadData, _OMC_LIT589, _OMC_LIT590);
          }

          _initSize = omc_Expression_sizeOf(threadData, omc_Expression_typeof(threadData, _initPnts));
          tmpMeta26 = mmc_mk_box9(3, &SimCode_SpatialDistribution_SPATIAL__DISTRIBUTION__desc, mmc_mk_integer(_i), _in0, _in1, _pos, _dir, _initPnts, _initVals, mmc_mk_integer(_initSize));
          tmpMeta25 = mmc_mk_cons(tmpMeta26, _spatialInfo);
          tmpMeta1 = tmpMeta25;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _spatialInfo;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _spatialInfo = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_spatialInfo) { *out_spatialInfo = _spatialInfo; }
  return _callExp;
}

static modelica_metatype closure25_SimCodeUtil_extractSpatialDistributionInfoExp(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_callExp, modelica_metatype $in_spatialInfo, modelica_metatype tmp1)
{
  modelica_metatype maxIndex_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_SimCodeUtil_extractSpatialDistributionInfoExp(thData, $in_callExp, $in_spatialInfo, maxIndex_ptr, tmp1);
}
DLLDirection
modelica_metatype omc_SimCodeUtil_extractSpatialDistributionInfo(threadData_t *threadData, modelica_metatype _dlow)
{
  modelica_metatype _spatialInfo = NULL;
  modelica_metatype _spatial_lst = NULL;
  modelica_metatype _maxIndex_ptr = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _spatialInfo has no default value.
  // _spatial_lst has no default value.
  _maxIndex_ptr = omc_Mutable_create(threadData, mmc_mk_integer(((modelica_integer) -1)));
  /* Pattern-matching assignment */
  tmpMeta2 = mmc_mk_box1(0, _maxIndex_ptr);
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta4 = mmc_mk_box2(0, (modelica_fnptr) mmc_mk_box2(0,closure25_SimCodeUtil_extractSpatialDistributionInfoExp,tmpMeta2), tmpMeta3);
  tmpMeta5 = omc_BackendDAEUtil_traverseBackendDAEExps(threadData, _dlow, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta4);
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
  _spatial_lst = tmpMeta6;

  tmpMeta7 = mmc_mk_box3(3, &SimCode_SpatialDistributionInfo_SPATIAL__DISTRIBUTION__INFO__desc, _spatial_lst, omc_Mutable_access(threadData, _maxIndex_ptr));
  _spatialInfo = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  return _spatialInfo;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_extractIdAndExpFromDelayExp(threadData_t *threadData, modelica_metatype _delayCallExp)
{
  modelica_metatype _delayedExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _delayedExp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _delayCallExp;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _delay = NULL;
      modelica_metatype _delayMax = NULL;
      modelica_integer _i;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _delay has no default value.
      // _delayMax has no default value.
      // _i has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (5 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT592), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmpMeta8);
          tmpMeta10 = MMC_CDR(tmpMeta8);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          if (listEmpty(tmpMeta10)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmpMeta10);
          tmpMeta14 = MMC_CDR(tmpMeta10);
          if (listEmpty(tmpMeta14)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmpMeta14);
          tmpMeta16 = MMC_CDR(tmpMeta14);
          if (listEmpty(tmpMeta16)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmpMeta16);
          tmpMeta18 = MMC_CDR(tmpMeta16);
          if (!listEmpty(tmpMeta18)) goto tmp3_end;
          
          _i = tmp12  /* pattern as ty=Integer */;
          _e = tmpMeta13;
          _delay = tmpMeta15;
          _delayMax = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta19 = mmc_mk_box3(0, _e, _delay, _delayMax);
          tmpMeta20 = mmc_mk_box2(0, mmc_mk_integer(_i), tmpMeta19);
          tmpMeta1 = tmpMeta20;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _delayedExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _delayedExp;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData_t *threadData, modelica_metatype __omcQ_24in_5FdelayedExps, modelica_integer __omcQ_24in_5FmaxDelayedExpIndex, modelica_metatype __omcQ_24in_5FSymJacs, modelica_integer *out_maxDelayedExpIndex, modelica_metatype *out_SymJacs)
{
  modelica_metatype _delayedExps = NULL;
  modelica_integer _maxDelayedExpIndex;
  modelica_metatype _SymJacs = NULL;
  modelica_metatype _tmpJacs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _tmpCols = NULL;
  modelica_metatype _tmpSysts = NULL;
  modelica_metatype _new_delayedExps = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _delayedExps = __omcQ_24in_5FdelayedExps;
  _maxDelayedExpIndex = __omcQ_24in_5FmaxDelayedExpIndex;
  _SymJacs = __omcQ_24in_5FSymJacs;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpJacs = tmpMeta1;
  // _tmpCols has no default value.
  // _tmpSysts has no default value.
  // _new_delayedExps has no default value.
  {
    modelica_metatype _jac;
    for (tmpMeta2 = listReverse(_SymJacs); !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _jac = MMC_CAR(tmpMeta2);
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmpCols = tmpMeta3;

      {
        modelica_metatype _col;
        for (tmpMeta4 = listReverse((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_jac), 2)))); !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
        {
          _col = MMC_CAR(tmpMeta4);
          /* Pattern-matching tuple assignment */
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta11 = mmc_mk_box2(0, tmpMeta10, mmc_mk_integer(_maxDelayedExpIndex));
          tmpMeta12 = mmc_mk_box2(0, boxvar_SimCodeUtil_updateDelayExpressions, tmpMeta11);
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta14 = omc_SimCodeUtil_traverseExpsEqSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_col), 2))), boxvar_Expression_traverseSubexpressionsHelper, tmpMeta12, tmpMeta13, &tmpMeta5);
          _tmpSysts = tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          _new_delayedExps = tmpMeta7;
          _maxDelayedExpIndex = tmp9  /* pattern as ty=Integer */;

          _delayedExps = listAppend(omc_List_map(threadData, _new_delayedExps, boxvar_SimCodeUtil_extractIdAndExpFromDelayExp), _delayedExps);

          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_col), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[2] = _tmpSysts;
          _col = tmpMeta15;

          tmpMeta16 = mmc_mk_cons(_col, _tmpCols);
          _tmpCols = tmpMeta16;
        }
      }

      tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(17));
      memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_jac), 17*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[2] = _tmpCols;
      _jac = tmpMeta18;

      tmpMeta19 = mmc_mk_cons(_jac, _tmpJacs);
      _tmpJacs = tmpMeta19;
    }
  }

  _SymJacs = _tmpJacs;
  _return: OMC_LABEL_UNUSED
  if (out_maxDelayedExpIndex) { *out_maxDelayedExpIndex = _maxDelayedExpIndex; }
  if (out_SymJacs) { *out_SymJacs = _SymJacs; }
  return _delayedExps;
}
modelica_metatype boxptr_SimCodeUtil_extractJacobianDelayedExpressions(threadData_t *threadData, modelica_metatype __omcQ_24in_5FdelayedExps, modelica_metatype __omcQ_24in_5FmaxDelayedExpIndex, modelica_metatype __omcQ_24in_5FSymJacs, modelica_metatype *out_maxDelayedExpIndex, modelica_metatype *out_SymJacs)
{
  modelica_integer tmp1;
  modelica_integer _maxDelayedExpIndex;
  modelica_metatype _delayedExps = NULL;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FmaxDelayedExpIndex);
  _delayedExps = omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData, __omcQ_24in_5FdelayedExps, tmp1, __omcQ_24in_5FSymJacs, &_maxDelayedExpIndex, out_SymJacs);
  /* skip box _delayedExps; list<tuple<#Integer, tuple<DAE.Exp, DAE.Exp, DAE.Exp>>> */
  if (out_maxDelayedExpIndex) { *out_maxDelayedExpIndex = mmc_mk_icon(_maxDelayedExpIndex); }
  /* skip box _SymJacs; list<SimCode.JacobianMatrix> */
  return _delayedExps;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_extractDelayedExpressions(threadData_t *threadData, modelica_metatype _dlow, modelica_integer *out_maxDelayedExpIndex)
{
  modelica_metatype _delayedExps = NULL;
  modelica_integer _maxDelayedExpIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _delayedExps has no default value.
  // _maxDelayedExpIndex has no default value.
  
  
  { /* matchcontinue expression */
    {
      modelica_metatype _exps = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exps has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta7 = mmc_mk_box2(0, boxvar_SimCodeUtil_collectDelayExpressions, tmpMeta6);
          tmpMeta8 = omc_BackendDAEUtil_traverseBackendDAEExps(threadData, _dlow, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          _exps = tmpMeta9;

          _delayedExps = omc_List_map(threadData, _exps, boxvar_SimCodeUtil_extractIdAndExpFromDelayExp);

          _maxDelayedExpIndex = mmc_unbox_integer(omc_List_applyAndFold(threadData, _delayedExps, boxvar_intMax, boxvar_Util_tuple21, mmc_mk_integer(((modelica_integer) -1))));
          tmpMeta[0+0] = _delayedExps;
          tmp1_c1 = ((modelica_integer) 1) + _maxDelayedExpIndex;
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT593, _OMC_LIT594);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _delayedExps = tmpMeta[0+0];
  _maxDelayedExpIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_maxDelayedExpIndex) { *out_maxDelayedExpIndex = _maxDelayedExpIndex; }
  return _delayedExps;
}
modelica_metatype boxptr_SimCodeUtil_extractDelayedExpressions(threadData_t *threadData, modelica_metatype _dlow, modelica_metatype *out_maxDelayedExpIndex)
{
  modelica_integer _maxDelayedExpIndex;
  modelica_metatype _delayedExps = NULL;
  _delayedExps = omc_SimCodeUtil_extractDelayedExpressions(threadData, _dlow, &_maxDelayedExpIndex);
  /* skip box _delayedExps; list<tuple<#Integer, tuple<DAE.Exp, DAE.Exp, DAE.Exp>>> */
  if (out_maxDelayedExpIndex) { *out_maxDelayedExpIndex = mmc_mk_icon(_maxDelayedExpIndex); }
  return _delayedExps;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateDelayExpressions(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fe, modelica_metatype __omcQ_24in_5Facc, modelica_metatype *out_acc)
{
  modelica_metatype _e = NULL;
  modelica_metatype _acc = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _e = __omcQ_24in_5Fe;
  _acc = __omcQ_24in_5Facc;
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _e;
    tmp4_2 = _acc;
    {
      modelica_metatype _res = NULL;
      modelica_integer _i;
      modelica_integer _index;
      modelica_metatype _lst = NULL;
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _res has no default value.
      // _i has no default value.
      // _index has no default value.
      // _lst has no default value.
      // _rest has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (5 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT592), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmpMeta8);
          tmpMeta10 = MMC_CDR(tmpMeta8);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          _i = tmp12  /* pattern as ty=Integer */;
          _rest = tmpMeta10;
          _lst = tmpMeta13;
          _index = tmp15  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(_i < ((modelica_integer) 0))) goto tmp3_end;
          tmpMeta17 = mmc_mk_box2(3, &DAE_Exp_ICONST__desc, mmc_mk_integer(_index));
          tmpMeta16 = mmc_mk_cons(tmpMeta17, _rest);
          tmpMeta18 = mmc_mk_box4(16, &DAE_Exp_CALL__desc, _OMC_LIT595, tmpMeta16, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 4))));
          _res = tmpMeta18;
          tmpMeta19 = mmc_mk_cons(_res, _lst);
          tmpMeta20 = mmc_mk_box2(0, tmpMeta19, mmc_mk_integer(((modelica_integer) 1) + _index));
          tmpMeta[0+0] = _res;
          tmpMeta[0+1] = tmpMeta20;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _acc;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _e = tmpMeta[0+0];
  _acc = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_acc) { *out_acc = _acc; }
  return _e;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectDelayExpressions(threadData_t *threadData, modelica_metatype _e, modelica_metatype _acc, modelica_metatype *out_outAcc)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outAcc = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outAcc has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _e;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (5 != MMC_STRLEN(tmpMeta7) || strcmp(MMC_STRINGDATA(_OMC_LIT592), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta8 = mmc_mk_cons(_e, _acc);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = tmpMeta8;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _acc;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outExp = tmpMeta[0+0];
  _outAcc = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outAcc) { *out_outAcc = _outAcc; }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_isSimEqSys(threadData_t *threadData, modelica_metatype _simEqSysIn)
{
  modelica_boolean _isEqSys;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isEqSys has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simEqSysIn;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _isEqSys = tmp1;
  _return: OMC_LABEL_UNUSED
  return _isEqSys;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_isSimEqSys(threadData_t *threadData, modelica_metatype _simEqSysIn)
{
  modelica_boolean _isEqSys;
  modelica_metatype out_isEqSys;
  _isEqSys = omc_SimCodeUtil_isSimEqSys(threadData, _simEqSysIn);
  out_isEqSys = mmc_mk_icon(_isEqSys);
  return out_isEqSys;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createDerivativeMatrix(threadData_t *threadData, modelica_metatype _inJacobian, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _res = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_boolean _debug;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  // _ouniqueEqIndex has no default value.
  _debug = 0 /* false */;
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inJacobian;
    {
      modelica_metatype _emptyVars = NULL;
      modelica_metatype _independentVars = NULL;
      modelica_metatype _residualVars = NULL;
      modelica_metatype _systvars = NULL;
      modelica_metatype _independentVarsLst = NULL;
      modelica_metatype _dependentVarsLst = NULL;
      modelica_metatype _residualVarsLst = NULL;
      modelica_metatype _allVars = NULL;
      modelica_metatype _independentComRefs = NULL;
      modelica_metatype _dependentVarsComRefs = NULL;
      modelica_metatype _x = NULL;
      modelica_metatype _pattern = NULL;
      modelica_metatype _sparseColoring = NULL;
      modelica_metatype _coloring = NULL;
      modelica_metatype _sparsepatternComRefs = NULL;
      modelica_metatype _sparsepatternComRefsT = NULL;
      modelica_metatype _sparseInts = NULL;
      modelica_metatype _sparseIntsT = NULL;
      modelica_metatype _syst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _comps = NULL;
      modelica_string _name = NULL;
      modelica_string _dummyVar = NULL;
      modelica_integer _maxColor;
      modelica_integer _uniqueEqIndex;
      modelica_integer _index;
      modelica_integer _nAllVars;
      modelica_metatype _columnVars = NULL;
      modelica_metatype _innerVars = NULL;
      modelica_metatype _varsSeedIndex = NULL;
      modelica_metatype _seedVars = NULL;
      modelica_metatype _indexVars = NULL;
      modelica_string _errorMessage = NULL;
      modelica_metatype _hashTable = NULL;
      modelica_metatype _outRes = NULL;
      modelica_metatype _omsiJacFunction = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _emptyVars has no default value.
      // _independentVars has no default value.
      // _residualVars has no default value.
      // _systvars has no default value.
      // _independentVarsLst has no default value.
      // _dependentVarsLst has no default value.
      // _residualVarsLst has no default value.
      // _allVars has no default value.
      // _independentComRefs has no default value.
      // _dependentVarsComRefs has no default value.
      // _x has no default value.
      // _pattern has no default value.
      // _sparseColoring has no default value.
      // _coloring has no default value.
      // _sparsepatternComRefs has no default value.
      // _sparsepatternComRefsT has no default value.
      // _sparseInts has no default value.
      // _sparseIntsT has no default value.
      // _syst has no default value.
      // _shared has no default value.
      // _comps has no default value.
      // _name has no default value.
      // _dummyVar has no default value.
      // _maxColor has no default value.
      // _uniqueEqIndex has no default value.
      // _index has no default value.
      // _nAllVars has no default value.
      // _columnVars has no default value.
      // _innerVars has no default value.
      // _varsSeedIndex has no default value.
      // _seedVars has no default value.
      // _indexVars has no default value.
      // _errorMessage has no default value.
      // _hashTable has no default value.
      // _outRes has no default value.
      // _omsiJacFunction has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,0) == 0) goto tmp3_end;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (!optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _pattern = tmpMeta7;
          _sparsepatternComRefs = tmpMeta8;
          _sparsepatternComRefsT = tmpMeta9;
          _independentComRefs = tmpMeta11;
          _dependentVarsComRefs = tmpMeta12;
          _sparseColoring = tmpMeta13;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta14 = stringAppend(_OMC_LIT596,realString(mmc_clock()));
            tmpMeta15 = stringAppend(tmpMeta14,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta15),stdout);

            omc_BackendDump_dumpSparsityPattern(threadData, _pattern, _OMC_LIT597);
          }

          {
            modelica_metatype __omcQ_24tmpVar51;
            modelica_metatype* tmp17;
            modelica_metatype tmpMeta18;
            modelica_metatype __omcQ_24tmpVar50;
            modelica_integer tmp19;
            modelica_metatype _cr_loopVar = 0;
            modelica_metatype _cr;
            _cr_loopVar = _independentComRefs;
            tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar51 = tmpMeta18; /* defaultValue */
            tmp17 = &__omcQ_24tmpVar51;
            while(1) {
              tmp19 = 1;
              if (!listEmpty(_cr_loopVar)) {
                _cr = MMC_CAR(_cr_loopVar);
                _cr_loopVar = MMC_CDR(_cr_loopVar);
                tmp19--;
              }
              if (tmp19 == 0) {
                __omcQ_24tmpVar50 = omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData, _cr, _OMC_LIT601);
                *tmp17 = mmc_mk_cons(__omcQ_24tmpVar50,0);
                tmp17 = &MMC_CDR(*tmp17);
              } else if (tmp19 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp17 = mmc_mk_nil();
            tmpMeta16 = __omcQ_24tmpVar51;
          }
          _seedVars = tmpMeta16;

          {
            modelica_metatype __omcQ_24tmpVar53;
            modelica_metatype* tmp21;
            modelica_metatype tmpMeta22;
            modelica_metatype __omcQ_24tmpVar52;
            modelica_integer tmp23;
            modelica_metatype _cr_loopVar = 0;
            modelica_metatype _cr;
            _cr_loopVar = _dependentVarsComRefs;
            tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar53 = tmpMeta22; /* defaultValue */
            tmp21 = &__omcQ_24tmpVar53;
            while(1) {
              tmp23 = 1;
              if (!listEmpty(_cr_loopVar)) {
                _cr = MMC_CAR(_cr_loopVar);
                _cr_loopVar = MMC_CDR(_cr_loopVar);
                tmp23--;
              }
              if (tmp23 == 0) {
                __omcQ_24tmpVar52 = omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData, _cr, _OMC_LIT87);
                *tmp21 = mmc_mk_cons(__omcQ_24tmpVar52,0);
                tmp21 = &MMC_CDR(*tmp21);
              } else if (tmp23 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp21 = mmc_mk_nil();
            tmpMeta20 = __omcQ_24tmpVar53;
          }
          _indexVars = tmpMeta20;

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, _seedVars, ((modelica_integer) 0) ,&_index);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, _indexVars, _index ,&_index);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT602),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT603),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);
          }

          _varsSeedIndex = listAppend(_seedVars, _indexVars);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefs, 0 /* false */);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefsT, 0 /* false */);

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _seedVars, _sparseColoring);

          _maxColor = listLength(_sparseColoring);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta24 = stringAppend(_OMC_LIT604,realString(mmc_clock()));
            tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta25),stdout);
          }
          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta27 = mmc_mk_box7(3, &SimCode_DerivativeMatrix_DERIVATIVE__MATRIX__desc, tmpMeta26, _OMC_LIT31, _sparseInts, _sparseIntsT, _coloring, mmc_mk_integer(_maxColor));
          tmpMeta[0+0] = mmc_mk_some(tmpMeta27);
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (optionNone(tmpMeta28)) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 1));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          if (listEmpty(tmpMeta31)) goto tmp3_end;
          tmpMeta32 = MMC_CAR(tmpMeta31);
          tmpMeta33 = MMC_CDR(tmpMeta31);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,1,3) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 4));
          if (!listEmpty(tmpMeta33)) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 3));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 3));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 4));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 5));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 1));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 2));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _syst = tmpMeta32;
          _comps = tmpMeta35;
          _shared = tmpMeta36;
          _name = tmpMeta37;
          _independentVarsLst = tmpMeta38;
          _residualVarsLst = tmpMeta39;
          _dependentVarsLst = tmpMeta40;
          _sparsepatternComRefs = tmpMeta42;
          _sparsepatternComRefsT = tmpMeta43;
          _sparseColoring = tmpMeta44;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta45 = stringAppend(_OMC_LIT605,_name);
            tmpMeta46 = stringAppend(tmpMeta45,_OMC_LIT606);
            tmpMeta47 = stringAppend(tmpMeta46,realString(mmc_clock()));
            tmpMeta48 = stringAppend(tmpMeta47,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta48),stdout);
          }

          _omsiJacFunction = omc_SimCodeUtil_generateEquationsForComponents(threadData, _comps, _syst, _shared, _iuniqueEqIndex ,&_uniqueEqIndex);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta49 = stringAppend(_OMC_LIT607,_name);
            tmpMeta50 = stringAppend(tmpMeta49,_OMC_LIT606);
            tmpMeta51 = stringAppend(tmpMeta50,realString(mmc_clock()));
            tmpMeta52 = stringAppend(tmpMeta51,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta52),stdout);
          }

          tmpMeta53 = stringAppend(_OMC_LIT608,_name);
          _dummyVar = tmpMeta53;

          tmpMeta54 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta55 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _dummyVar, _OMC_LIT86, tmpMeta54);
          _x = tmpMeta55;

          _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

          _residualVars = omc_BackendVariable_listVar1(threadData, _residualVarsLst);

          _independentVars = omc_BackendVariable_listVar1(threadData, _independentVarsLst);

          /* Pattern-matching assignment */
          tmpMeta56 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta57 = mmc_mk_box2(0, tmpMeta56, _x);
          tmpMeta58 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), boxvar_SimCodeUtil_getFurtherVars, tmpMeta57);
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 1));
          _allVars = tmpMeta59;

          _systvars = omc_BackendVariable_listVar1(threadData, _allVars);

          /* Pattern-matching assignment */
          tmpMeta60 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta61 = mmc_mk_box2(0, tmpMeta60, _emptyVars);
          tmpMeta62 = omc_BackendVariable_traverseBackendDAEVars(threadData, _systvars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta61);
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 1));
          _columnVars = tmpMeta63;

          _columnVars = omc_List_map1(threadData, _columnVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT609);

          _columnVars = omc_List_map1(threadData, _columnVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          _innerVars = omc_SimCodeUtil_rewriteIndex(threadData, _columnVars, ((modelica_integer) 0), NULL);

          tmpMeta64 = MMC_REFSTRUCTLIT(mmc_nil);
          _innerVars = omc_SimCodeUtil_createJacSimVarsColumn(threadData, _dependentVarsLst, _x, _residualVars, ((modelica_integer) 0), listLength(_innerVars), _name, _innerVars, tmpMeta64 ,&_columnVars);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT610),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _columnVars)),stdout);

            tmpMeta65 = stringAppend(_OMC_LIT611,_name);
            tmpMeta66 = stringAppend(tmpMeta65,_OMC_LIT606);
            tmpMeta67 = stringAppend(tmpMeta66,realString(mmc_clock()));
            tmpMeta68 = stringAppend(tmpMeta67,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta68),stdout);
          }

          /* Pattern-matching assignment */
          tmpMeta69 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta70 = mmc_mk_box2(0, tmpMeta69, _emptyVars);
          tmpMeta71 = omc_BackendVariable_traverseBackendDAEVars(threadData, _independentVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta70);
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 1));
          _seedVars = tmpMeta72;

          /* Pattern-matching assignment */
          tmpMeta73 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta74 = mmc_mk_box2(0, tmpMeta73, _emptyVars);
          tmpMeta75 = omc_BackendVariable_traverseBackendDAEVars(threadData, _residualVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta74);
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta75), 1));
          _indexVars = tmpMeta76;

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, listReverse(_seedVars), ((modelica_integer) 0), NULL);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, listReverse(_indexVars), ((modelica_integer) 0), NULL);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT602),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT603),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);
          }

          _varsSeedIndex = listAppend(_seedVars, _indexVars);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefs, 0 /* false */);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefsT, 0 /* false */);

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _varsSeedIndex, _sparseColoring);

          _maxColor = listLength(_sparseColoring);

          _seedVars = omc_SimCodeUtil_replaceSeedVarsName(threadData, _seedVars, _name);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT601);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta77 = stringAppend(_OMC_LIT612,_name);
            tmpMeta78 = stringAppend(tmpMeta77,_OMC_LIT606);
            tmpMeta79 = stringAppend(tmpMeta78,realString(mmc_clock()));
            tmpMeta80 = stringAppend(tmpMeta79,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta80),stdout);
          }

          _columnVars = omc_SimCodeUtil_rewriteIndex(threadData, _columnVars, ((modelica_integer) 0) ,&_index);

          _innerVars = omc_SimCodeUtil_rewriteIndex(threadData, _innerVars, _index ,&_index);

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, _seedVars, _index ,&_index);

          _nAllVars = listLength(_seedVars) + listLength(_innerVars) + listLength(_indexVars);

          tmpMeta81 = mmc_mk_cons(_seedVars, mmc_mk_cons(_innerVars, mmc_mk_cons(_columnVars, MMC_REFSTRUCTLIT(mmc_nil))));
          _hashTable = omc_SimCodeUtil_fillLocalHashTable(threadData, tmpMeta81, _nAllVars);

          tmpMeta82 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta82), MMC_UNTAGPTR(_omsiJacFunction), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta82))[3] = _seedVars;
          _omsiJacFunction = tmpMeta82;

          tmpMeta83 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta83), MMC_UNTAGPTR(_omsiJacFunction), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta83))[5] = _innerVars;
          _omsiJacFunction = tmpMeta83;

          tmpMeta84 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta84), MMC_UNTAGPTR(_omsiJacFunction), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta84))[4] = _columnVars;
          _omsiJacFunction = tmpMeta84;

          tmpMeta85 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta85), MMC_UNTAGPTR(_omsiJacFunction), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta85))[6] = mmc_mk_integer(_nAllVars);
          _omsiJacFunction = tmpMeta85;

          tmpMeta87 = mmc_mk_box3(6, &SimCodeFunction_Context_JACOBIAN__CONTEXT__desc, _name, mmc_mk_some(_hashTable));
          tmpMeta86 = MMC_TAGPTR(mmc_alloc_words(9));
          memcpy(MMC_UNTAGPTR(tmpMeta86), MMC_UNTAGPTR(_omsiJacFunction), 9*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta86))[7] = tmpMeta87;
          _omsiJacFunction = tmpMeta86;

          if(_debug)
          {
            omc_SimCodeUtil_dumpOMSIFunc(threadData, _omsiJacFunction, _OMC_LIT613);

            fputs(MMC_STRINGDATA(_OMC_LIT614),stdout);

            omc_BaseHashTable_dumpHashTableStatistics(threadData, _hashTable);
          }

          tmpMeta88 = mmc_mk_cons(_omsiJacFunction, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta89 = mmc_mk_box7(3, &SimCode_DerivativeMatrix_DERIVATIVE__MATRIX__desc, tmpMeta88, _name, _sparseInts, _sparseIntsT, _coloring, mmc_mk_integer(_maxColor));
          _outRes = mmc_mk_some(tmpMeta89);
          tmpMeta[0+0] = _outRes;
          tmp1_c1 = _uniqueEqIndex;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT619))
          {
            _errorMessage = _OMC_LIT615;

            omc_Error_addInternalError(threadData, _errorMessage, _OMC_LIT616);
          }
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _res = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _res;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createDerivativeMatrix(threadData_t *threadData, modelica_metatype _inJacobian, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _res = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _res = omc_SimCodeUtil_createDerivativeMatrix(threadData, _inJacobian, tmp1, &_ouniqueEqIndex);
  /* skip box _res; Option<SimCode.DerivativeMatrix> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _res;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSparsePattern(threadData_t *threadData, modelica_metatype _sparsePattern)
{
  modelica_metatype _cr = NULL;
  modelica_metatype _crefs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cr has no default value.
  // _crefs has no default value.
  {
    modelica_metatype _tpl;
    for (tmpMeta1 = _sparsePattern; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _tpl = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _tpl;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _cr = tmpMeta3;
      _crefs = tmpMeta4;

      tmpMeta5 = stringAppend(_OMC_LIT620,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
      tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT48);
      fputs(MMC_STRINGDATA(tmpMeta6),stdout);

      tmpMeta7 = stringAppend(_OMC_LIT621,stringDelimitList(omc_List_map(threadData, _crefs, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT349));
      tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT48);
      fputs(MMC_STRINGDATA(tmpMeta8),stdout);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSparsePatternInt(threadData_t *threadData, modelica_metatype _sparsePattern)
{
  modelica_integer _i;
  modelica_metatype _lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _i has no default value.
  // _lst has no default value.
  {
    modelica_metatype _tpl;
    for (tmpMeta1 = _sparsePattern; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _tpl = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _tpl;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmp4 = mmc_unbox_integer(tmpMeta3);
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _i = tmp4  /* pattern as ty=Integer */;
      _lst = tmpMeta5;

      tmpMeta6 = stringAppend(_OMC_LIT620,intString(_i));
      tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT48);
      fputs(MMC_STRINGDATA(tmpMeta7),stdout);

      tmpMeta8 = stringAppend(_OMC_LIT621,stringDelimitList(omc_List_map(threadData, _lst, boxvar_intString), _OMC_LIT349));
      tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT48);
      fputs(MMC_STRINGDATA(tmpMeta9),stdout);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortColoring(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inColoring)
{
  modelica_metatype _outColoring = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _ht = NULL;
  modelica_integer _size;
  modelica_integer _i;
  modelica_integer _j;
  modelica_metatype _intLst = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outColoring = tmpMeta1;
  // _ht has no default value.
  // _size has no default value.
  // _i has no default value.
  // _j has no default value.
  // _intLst has no default value.
  // _cref has no default value.
  _size = listLength(_inSimVars);

  if((_size > ((modelica_integer) 0)))
  {
    _ht = omc_HashTable_emptyHashTableSized(threadData, _size);

    {
      modelica_metatype _var;
      for (tmpMeta2 = _inSimVars; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
      {
        _var = MMC_CAR(tmpMeta2);
        /* Pattern-matching assignment */
        tmpMeta3 = _var;
        tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
        tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 7));
        tmp6 = mmc_unbox_integer(tmpMeta5);
        _cref = tmpMeta4;
        _i = tmp6  /* pattern as ty=Integer */;

        tmpMeta7 = mmc_mk_box2(0, _cref, mmc_mk_integer(_i));
        _ht = omc_BaseHashTable_add(threadData, tmpMeta7, _ht);
      }
    }

    {
      modelica_metatype _crefs;
      for (tmpMeta9 = _inColoring; !listEmpty(tmpMeta9); tmpMeta9=MMC_CDR(tmpMeta9))
      {
        _crefs = MMC_CAR(tmpMeta9);
        tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
        _intLst = tmpMeta10;

        {
          modelica_metatype _cr;
          for (tmpMeta11 = _crefs; !listEmpty(tmpMeta11); tmpMeta11=MMC_CDR(tmpMeta11))
          {
            _cr = MMC_CAR(tmpMeta11);
            _j = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _cr, _ht));

            tmpMeta12 = mmc_mk_cons(mmc_mk_integer(_j), _intLst);
            _intLst = tmpMeta12;
          }
        }

        tmpMeta14 = mmc_mk_cons(_intLst, _outColoring);
        _outColoring = tmpMeta14;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outColoring;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortSparsePattern(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inSparsePattern, modelica_boolean _useFMIIndex)
{
  modelica_metatype _outSparse = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _ht = NULL;
  modelica_metatype _cref = NULL;
  modelica_integer _size;
  modelica_integer _i;
  modelica_integer _j;
  modelica_metatype _intLst = NULL;
  modelica_metatype _crefs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSparse = tmpMeta1;
  // _ht has no default value.
  // _cref has no default value.
  // _size has no default value.
  // _i has no default value.
  // _j has no default value.
  // _intLst has no default value.
  // _crefs has no default value.
  _size = listLength(_inSimVars);

  if((_size > ((modelica_integer) 0)))
  {
    _ht = omc_HashTable_emptyHashTableSized(threadData, _size);

    {
      modelica_metatype _var;
      for (tmpMeta2 = _inSimVars; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
      {
        _var = MMC_CAR(tmpMeta2);
        if((!_useFMIIndex))
        {
          /* Pattern-matching assignment */
          tmpMeta3 = _var;
          tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 7));
          tmp6 = mmc_unbox_integer(tmpMeta5);
          _cref = tmpMeta4;
          _i = tmp6  /* pattern as ty=Integer */;
        }
        else
        {
          /* Pattern-matching assignment */
          tmpMeta7 = _var;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          _cref = tmpMeta8;

          _i = omc_SimCodeUtil_getVariableFMIIndex(threadData, _var);
        }

        tmpMeta9 = mmc_mk_box2(0, _cref, mmc_mk_integer(_i));
        _ht = omc_BaseHashTable_add(threadData, tmpMeta9, _ht);
      }
    }

    {
      modelica_metatype _tpl;
      for (tmpMeta11 = _inSparsePattern; !listEmpty(tmpMeta11); tmpMeta11=MMC_CDR(tmpMeta11))
      {
        _tpl = MMC_CAR(tmpMeta11);
        /* Pattern-matching assignment */
        tmpMeta12 = _tpl;
        tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
        tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
        _cref = tmpMeta13;
        _crefs = tmpMeta14;

        _i = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _cref, _ht));

        if(((!_useFMIIndex) || (_i > ((modelica_integer) 0))))
        {
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          _intLst = tmpMeta15;

          {
            modelica_metatype _cr;
            for (tmpMeta16 = _crefs; !listEmpty(tmpMeta16); tmpMeta16=MMC_CDR(tmpMeta16))
            {
              _cr = MMC_CAR(tmpMeta16);
              _j = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _cr, _ht));

              if(((!_useFMIIndex) || (_j > ((modelica_integer) 0))))
              {
                tmpMeta17 = mmc_mk_cons(mmc_mk_integer(_j), _intLst);
                _intLst = tmpMeta17;
              }
            }
          }

          _intLst = omc_List_heapSortIntList(threadData, _intLst);

          tmpMeta20 = mmc_mk_box2(0, mmc_mk_integer(_i), _intLst);
          tmpMeta19 = mmc_mk_cons(tmpMeta20, _outSparse);
          _outSparse = tmpMeta19;
        }
      }
    }

    _outSparse = omc_List_sort(threadData, _outSparse, boxvar_Util_compareTupleIntGt);
  }
  _return: OMC_LABEL_UNUSED
  return _outSparse;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_sortSparsePattern(threadData_t *threadData, modelica_metatype _inSimVars, modelica_metatype _inSparsePattern, modelica_metatype _useFMIIndex)
{
  modelica_integer tmp1;
  modelica_metatype _outSparse = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_useFMIIndex);
  _outSparse = omc_SimCodeUtil_sortSparsePattern(threadData, _inSimVars, _inSparsePattern, tmp1);
  /* skip box _outSparse; list<tuple<#Integer, list<#Integer>>> */
  return _outSparse;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_dumpSortedInitialUnknownCrefs(threadData_t *threadData, modelica_metatype _sortedCrefs)
{
  modelica_metatype _cref = NULL;
  modelica_integer _index;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cref has no default value.
  // _index has no default value.
  {
    modelica_metatype _i;
    for (tmpMeta1 = _sortedCrefs; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _i = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _i;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmp4 = mmc_unbox_integer(tmpMeta3);
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _index = tmp4  /* pattern as ty=Integer */;
      _cref = tmpMeta5;

      tmpMeta6 = stringAppend(_OMC_LIT622,intString(_index));
      tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT623);
      tmpMeta8 = stringAppend(tmpMeta7,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref));
      fputs(MMC_STRINGDATA(tmpMeta8),stdout);
    }
  }

  fputs(MMC_STRINGDATA(_OMC_LIT624),stdout);
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortInitialUnknowsSimVars(threadData_t *threadData, modelica_metatype _inSimVars)
{
  modelica_metatype _sortedCrefs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _cref = NULL;
  modelica_metatype _unsortedCrefs = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _index;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _sortedCrefs = tmpMeta1;
  // _cref has no default value.
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _unsortedCrefs = tmpMeta2;
  // _index has no default value.
  {
    modelica_metatype _var;
    for (tmpMeta3 = _inSimVars; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _var = MMC_CAR(tmpMeta3);
      if(omc_SimCodeUtil_isRealInput(threadData, _var))
      {
        tmpMeta5 = mmc_mk_box2(0, mmc_mk_integer(omc_SimCodeUtil_getVariableFMIIndex(threadData, _var)), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))));
        tmpMeta4 = mmc_mk_cons(tmpMeta5, _unsortedCrefs);
        _unsortedCrefs = tmpMeta4;
      }
    }
  }

  _index = ((modelica_integer) 0);

  {
    modelica_metatype _i;
    for (tmpMeta7 = omc_List_sort(threadData, _unsortedCrefs, boxvar_Util_compareTupleIntGt); !listEmpty(tmpMeta7); tmpMeta7=MMC_CDR(tmpMeta7))
    {
      _i = MMC_CAR(tmpMeta7);
      /* Pattern-matching assignment */
      tmpMeta8 = _i;
      tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
      _cref = tmpMeta9;

      tmpMeta11 = mmc_mk_box2(0, mmc_mk_integer(_index), _cref);
      tmpMeta10 = mmc_mk_cons(tmpMeta11, _sortedCrefs);
      _sortedCrefs = tmpMeta10;

      _index = ((modelica_integer) 1) + _index;
    }
  }

  _sortedCrefs = listReverse(_sortedCrefs);
  _return: OMC_LABEL_UNUSED
  return _sortedCrefs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData_t *threadData, modelica_metatype _inName, modelica_metatype _inVarKind)
{
  modelica_metatype _outSimVar = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimVar has no default value.
  if(omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData)))
  {
    tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
    tmpMeta2 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _inName, _inVarKind, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _OMC_LIT86, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), tmpMeta1, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_inName), mmc_mk_boolean(0 /* false */));
    _outSimVar = tmpMeta2;
  }
  else
  {
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    tmpMeta4 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _inName, _inVarKind, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _OMC_LIT86, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT626, mmc_mk_none(), mmc_mk_none(), tmpMeta3, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_inName), mmc_mk_boolean(0 /* false */));
    _outSimVar = tmpMeta4;
  }
  _return: OMC_LABEL_UNUSED
  return _outSimVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimVarMatrixName(threadData_t *threadData, modelica_metatype __omcQ_24in_5FsimVar, modelica_metatype _optName)
{
  modelica_metatype _simVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simVar = __omcQ_24in_5FsimVar;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[28] = _optName;
  _simVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSimVarKind(threadData_t *threadData, modelica_metatype __omcQ_24in_5FsimVar, modelica_metatype _varKind)
{
  modelica_metatype _simVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _simVar = __omcQ_24in_5FsimVar;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(33));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[3] = _varKind;
  _simVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _simVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_collectAllSeedVars(threadData_t *threadData, modelica_metatype _inJacobianMatrices)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _seedVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = tmpMeta1;
  // _seedVars has no default value.
  {
    modelica_metatype _m;
    for (tmpMeta2 = _inJacobianMatrices; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _m = MMC_CAR(tmpMeta2);
      /* Pattern-matching assignment */
      tmpMeta3 = _m;
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 3));
      _seedVars = tmpMeta4;

      _outVars = listAppend(_seedVars, _outVars);
    }
  }

  _outVars = omc_List_map1(threadData, _outVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT601);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_collectAllJacobianVars(threadData_t *threadData, modelica_metatype _inJacobianMatrix)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _column = NULL;
  modelica_metatype _tmp = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = tmpMeta1;
  // _column has no default value.
  // _tmp has no default value.
  {
    modelica_metatype _m;
    for (tmpMeta2 = _inJacobianMatrix; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _m = MMC_CAR(tmpMeta2);
      /* Pattern-matching assignment */
      tmpMeta3 = _m;
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
      _column = tmpMeta4;

      {
        modelica_metatype _c;
        for (tmpMeta5 = _column; !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
        {
          _c = MMC_CAR(tmpMeta5);
          /* Pattern-matching assignment */
          tmpMeta6 = _c;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          _tmp = tmpMeta7;

          _outVars = listAppend(_tmp, _outVars);
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_collectAllJacobianEquations(threadData_t *threadData, modelica_metatype _inJacobianMatrix)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _column = NULL;
  modelica_metatype _tmp = NULL;
  modelica_metatype _constantEqns = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEqn = tmpMeta1;
  // _column has no default value.
  // _tmp has no default value.
  // _constantEqns has no default value.
  {
    modelica_metatype _m;
    for (tmpMeta2 = _inJacobianMatrix; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _m = MMC_CAR(tmpMeta2);
      /* Pattern-matching assignment */
      tmpMeta3 = _m;
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
      _column = tmpMeta4;

      {
        modelica_metatype _c;
        for (tmpMeta5 = _column; !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
        {
          _c = MMC_CAR(tmpMeta5);
          /* Pattern-matching assignment */
          tmpMeta6 = _c;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          _tmp = tmpMeta7;
          _constantEqns = tmpMeta8;

          _outEqn = listAppend(_tmp, _outEqn);

          _outEqn = listAppend(_constantEqns, _outEqn);
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllDiffedSimVars(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_integer _inResIndex, modelica_integer _inTmpIndex, modelica_string _inMatrixName, modelica_metatype _iVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _lst1 = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _lst1 has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVars = omc_SimCodeUtil_createJacSimVarsColumn(threadData, _inVars, _inCref, _inAllVars, _inResIndex, _inTmpIndex, _inMatrixName, _iVars, tmpMeta1 ,&_lst1);

  _outVars = listAppend(_lst1, _outVars);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllDiffedSimVars(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_metatype _inResIndex, modelica_metatype _inTmpIndex, modelica_metatype _inMatrixName, modelica_metatype _iVars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_inResIndex);
  tmp2 = mmc_unbox_integer(_inTmpIndex);
  _outVars = omc_SimCodeUtil_createAllDiffedSimVars(threadData, _inVars, _inCref, _inAllVars, tmp1, tmp2, _inMatrixName, _iVars);
  /* skip box _outVars; list<SimCodeVar.SimVar> */
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createJacSimVarsColumn(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_integer _inResIndex, modelica_integer _inTmpIndex, modelica_string _inMatrixName, modelica_metatype __omcQ_24in_5FtmpVars, modelica_metatype __omcQ_24in_5FresVars, modelica_metatype *out_resVars)
{
  modelica_metatype _tmpVars = NULL;
  modelica_metatype _resVars = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _tmpVars = __omcQ_24in_5FtmpVars;
  _resVars = __omcQ_24in_5FresVars;
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVars;
    {
      modelica_metatype _v = NULL;
      modelica_metatype _v1 = NULL;
      modelica_metatype _simVar = NULL;
      modelica_metatype _currVar = NULL;
      modelica_metatype _derivedCref = NULL;
      modelica_metatype _restVar = NULL;
      modelica_integer _resIndex;
      modelica_integer _tmpIndex;
      modelica_metatype _varkind = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _v1 has no default value.
      // _simVar has no default value.
      // _currVar has no default value.
      // _derivedCref has no default value.
      // _restVar has no default value.
      _resIndex = _inResIndex;
      _tmpIndex = _inTmpIndex;
      // _varkind has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = listReverse(_tmpVars);
          tmpMeta[0+1] = listReverse(_resVars);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          
          _v = tmpMeta6;
          _currVar = tmpMeta8;
          _varkind = tmpMeta9;
          _restVar = tmpMeta7;
          /* Pattern matching succeeded */
          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp12;
              int tmp13;
              tmp12 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp11_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp12 < 2; tmp12++) {
                switch (MMC_SWITCH_CAST(tmp12)) {
                case 0: {
                  modelica_metatype tmpMeta14;
                  modelica_metatype tmpMeta19;
                  modelica_metatype tmpMeta20;
                  modelica_metatype tmpMeta21;
                  /* Pattern matching succeeded */
                  omc_BackendVariable_getVarSingle(threadData, _currVar, _inAllVars, NULL);

                  { /* match expression */
                    modelica_metatype tmp17_1;
                    tmp17_1 = _varkind;
                    {
                      volatile mmc_switch_type tmp17;
                      int tmp18;
                      tmp17 = 0;
                      for (; tmp17 < 2; tmp17++) {
                        switch (MMC_SWITCH_CAST(tmp17)) {
                        case 0: {
                          if (mmc__uniontype__metarecord__typedef__equal(tmp17_1,1,3) == 0) goto tmp16_end;
                          
                          /* Pattern matching succeeded */
                          tmpMeta14 = omc_ComponentReference_crefPrefixDer(threadData, _currVar);
                          goto tmp16_done;
                        }
                        case 1: {
                          
                          /* Pattern matching succeeded */
                          tmpMeta14 = _currVar;
                          goto tmp16_done;
                        }
                        }
                        goto tmp16_end;
                        tmp16_end: ;
                      }
                      goto goto_15;
                      goto_15:;
                      goto goto_10;
                      goto tmp16_done;
                      tmp16_done:;
                    }
                  }
                  _currVar = tmpMeta14;

                  _derivedCref = omc_ComponentReference_createDifferentiatedCrefName(threadData, _currVar, _inCref, _inMatrixName);

                  _v1 = omc_BackendVariable_copyVarNewName(threadData, _derivedCref, _v);

                  _v1 = omc_BackendVariable_setVarKind(threadData, _v1, _OMC_LIT627);

                  _simVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _v1, mmc_mk_none(), _inAllVars, mmc_mk_none());

                  tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(33));
                  memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
                  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[7] = mmc_mk_integer(_inResIndex);
                  _simVar = tmpMeta19;

                  _resIndex = ((modelica_integer) 1) + _inResIndex;

                  tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(33));
                  memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
                  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[28] = mmc_mk_some(_inMatrixName);
                  _simVar = tmpMeta20;

                  tmpMeta21 = mmc_mk_cons(_simVar, _resVars);
                  _resVars = tmpMeta21;
                  goto tmp11_done;
                }
                case 1: {
                  modelica_metatype tmpMeta22;
                  modelica_metatype tmpMeta27;
                  modelica_metatype tmpMeta28;
                  modelica_metatype tmpMeta29;
                  /* Pattern matching succeeded */
                  { /* match expression */
                    modelica_metatype tmp25_1;
                    tmp25_1 = _varkind;
                    {
                      volatile mmc_switch_type tmp25;
                      int tmp26;
                      tmp25 = 0;
                      for (; tmp25 < 2; tmp25++) {
                        switch (MMC_SWITCH_CAST(tmp25)) {
                        case 0: {
                          if (mmc__uniontype__metarecord__typedef__equal(tmp25_1,1,3) == 0) goto tmp24_end;
                          
                          /* Pattern matching succeeded */
                          tmpMeta22 = omc_ComponentReference_crefPrefixDer(threadData, _currVar);
                          goto tmp24_done;
                        }
                        case 1: {
                          
                          /* Pattern matching succeeded */
                          tmpMeta22 = _currVar;
                          goto tmp24_done;
                        }
                        }
                        goto tmp24_end;
                        tmp24_end: ;
                      }
                      goto goto_23;
                      goto_23:;
                      goto goto_10;
                      goto tmp24_done;
                      tmp24_done:;
                    }
                  }
                  _currVar = tmpMeta22;

                  _derivedCref = omc_ComponentReference_createDifferentiatedCrefName(threadData, _currVar, _inCref, _inMatrixName);

                  _v1 = omc_BackendVariable_copyVarNewName(threadData, _derivedCref, _v);

                  _v1 = omc_BackendVariable_setVarKind(threadData, _v1, _OMC_LIT609);

                  _simVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _v1, mmc_mk_none(), _inAllVars, mmc_mk_none());

                  tmpMeta27 = MMC_TAGPTR(mmc_alloc_words(33));
                  memcpy(MMC_UNTAGPTR(tmpMeta27), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
                  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta27))[7] = mmc_mk_integer(_inTmpIndex);
                  _simVar = tmpMeta27;

                  tmpMeta28 = MMC_TAGPTR(mmc_alloc_words(33));
                  memcpy(MMC_UNTAGPTR(tmpMeta28), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
                  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta28))[28] = mmc_mk_some(_inMatrixName);
                  _simVar = tmpMeta28;

                  _tmpIndex = ((modelica_integer) 1) + _inTmpIndex;

                  tmpMeta29 = mmc_mk_cons(_simVar, _tmpVars);
                  _tmpVars = tmpMeta29;
                  goto tmp11_done;
                }
                }
                goto tmp11_end;
                tmp11_end: ;
              }
              goto goto_10;
              tmp11_done:
              (void)tmp12;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp11_done2;
              goto_10:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp12 < 2) {
                goto tmp11_top;
              }
              goto goto_2;
              tmp11_done2:;
            }
          }
          ;
          /* Tail recursive call */
          _inVars = _restVar;
          _inResIndex = _resIndex;
          _inTmpIndex = _tmpIndex;
          __omcQ_24in_5FtmpVars = _tmpVars;
          __omcQ_24in_5FresVars = _resVars;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT628, _OMC_LIT629);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _tmpVars = tmpMeta[0+0];
  _resVars = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_resVars) { *out_resVars = _resVars; }
  return _tmpVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createJacSimVarsColumn(threadData_t *threadData, modelica_metatype _inVars, modelica_metatype _inCref, modelica_metatype _inAllVars, modelica_metatype _inResIndex, modelica_metatype _inTmpIndex, modelica_metatype _inMatrixName, modelica_metatype __omcQ_24in_5FtmpVars, modelica_metatype __omcQ_24in_5FresVars, modelica_metatype *out_resVars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _tmpVars = NULL;
  tmp1 = mmc_unbox_integer(_inResIndex);
  tmp2 = mmc_unbox_integer(_inTmpIndex);
  _tmpVars = omc_SimCodeUtil_createJacSimVarsColumn(threadData, _inVars, _inCref, _inAllVars, tmp1, tmp2, _inMatrixName, __omcQ_24in_5FtmpVars, __omcQ_24in_5FresVars, out_resVars);
  /* skip box _tmpVars; list<SimCodeVar.SimVar> */
  /* skip box _resVars; list<SimCodeVar.SimVar> */
  return _tmpVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_sortBackVarWithSimVarsOrder(threadData_t *threadData, modelica_metatype _var, modelica_metatype _vars)
{
  modelica_metatype _outVar = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVar = omc_BackendVariable_getVarSingle(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), _vars, NULL);
  _return: OMC_LABEL_UNUSED
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceSeedVarsName(threadData_t *threadData, modelica_metatype _inVars, modelica_string _inMatrixName)
{
  modelica_metatype _outSimVars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  {
    modelica_metatype __omcQ_24tmpVar57;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar56;
    modelica_integer tmp4;
    modelica_metatype _v_loopVar = 0;
    modelica_metatype _v;
    _v_loopVar = _inVars;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar57 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar57;
    while(1) {
      tmp4 = 1;
      if (!listEmpty(_v_loopVar)) {
        _v = MMC_CAR(_v_loopVar);
        _v_loopVar = MMC_CDR(_v_loopVar);
        tmp4--;
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar56 = omc_SimCodeUtil_replaceSimVarName(threadData, omc_Differentiate_createSeedCrefName(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2))), _inMatrixName), _v);
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar56,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar57;
  }
  _outSimVars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outSimVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimVars2Crefs(threadData_t *threadData, modelica_metatype _inCrefs, modelica_metatype _inSimVarHT)
{
  modelica_metatype _outSimVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSimVars = tmpMeta1;
  {
    modelica_metatype _cref;
    for (tmpMeta2 = _inCrefs; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _cref = MMC_CAR(tmpMeta2);
      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp5;
          int tmp6;
          tmp5 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp4_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp5 < 2; tmp5++) {
            switch (MMC_SWITCH_CAST(tmp5)) {
            case 0: {
              modelica_metatype tmpMeta7;
              /* Pattern matching succeeded */
              tmpMeta7 = mmc_mk_cons(omc_BaseHashTable_get(threadData, _cref, _inSimVarHT), _outSimVars);
              _outSimVars = tmpMeta7;
              goto tmp4_done;
            }
            case 1: {
              /* Pattern matching succeeded */
              goto tmp4_done;
            }
            }
            goto tmp4_end;
            tmp4_end: ;
          }
          goto goto_3;
          tmp4_done:
          (void)tmp5;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp4_done2;
          goto_3:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp5 < 2) {
            goto tmp4_top;
          }
          MMC_THROW_INTERNAL();
          tmp4_done2:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outSimVars;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData_t *threadData, modelica_metatype _inSymJacobians, modelica_metatype _inSimVarHT, modelica_integer _iuniqueEqIndex, modelica_metatype _inNames, modelica_metatype _inJacobianMatrices, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outJacobianMatrices = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outJacobianMatrices has no default value.
  // _ouniqueEqIndex has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp6_1;volatile modelica_integer tmp6_2;volatile modelica_metatype tmp6_3;
    tmp6_1 = _inSymJacobians;
    tmp6_2 = _iuniqueEqIndex;
    tmp6_3 = _inNames;
    {
      modelica_metatype _systs = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _empty = NULL;
      modelica_metatype _systvars = NULL;
      modelica_metatype _emptyVars = NULL;
      modelica_metatype _x = NULL;
      modelica_metatype _diffedVars = NULL;
      modelica_metatype _alldiffedVars = NULL;
      modelica_metatype _allVars = NULL;
      modelica_metatype _diffCompRefs = NULL;
      modelica_metatype _diffedCompRefs = NULL;
      modelica_metatype _allCrefs = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_integer _nRows;
      modelica_metatype _restnames = NULL;
      modelica_string _name = NULL;
      modelica_string _dummyVar = NULL;
      modelica_metatype _allEquations = NULL;
      modelica_metatype tmpMeta3;
      modelica_metatype _constantEqns = NULL;
      modelica_metatype tmpMeta4;
      modelica_metatype _columnVars = NULL;
      modelica_metatype _otherColumnVars = NULL;
      modelica_metatype _seedVars = NULL;
      modelica_metatype _indexVars = NULL;
      modelica_metatype _seedIndexVars = NULL;
      modelica_metatype _sparsepattern = NULL;
      modelica_metatype _sparsepatternT = NULL;
      modelica_metatype _nonlinearpattern = NULL;
      modelica_metatype _nonlinearpatternT = NULL;
      modelica_metatype _colsColors = NULL;
      modelica_integer _maxColor;
      modelica_metatype _rest = NULL;
      modelica_metatype _linearModelMatrices = NULL;
      modelica_metatype _sparseInts = NULL;
      modelica_metatype _sparseIntsT = NULL;
      modelica_metatype _nonlinearPat = NULL;
      modelica_metatype _nonlinearPatT = NULL;
      modelica_metatype _coloring = NULL;
      modelica_metatype _optionBDAE = NULL;
      modelica_metatype _tmpJac = NULL;
      modelica_metatype _crefToSimVarHTJacobian = NULL;
      volatile mmc_switch_type tmp6;
      int tmp7;
      // _systs has no default value.
      // _shared has no default value.
      // _vars has no default value.
      // _empty has no default value.
      // _systvars has no default value.
      // _emptyVars has no default value.
      // _x has no default value.
      // _diffedVars has no default value.
      // _alldiffedVars has no default value.
      // _allVars has no default value.
      // _diffCompRefs has no default value.
      // _diffedCompRefs has no default value.
      // _allCrefs has no default value.
      // _uniqueEqIndex has no default value.
      // _nRows has no default value.
      // _restnames has no default value.
      // _name has no default value.
      // _dummyVar has no default value.
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      _allEquations = tmpMeta3;
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _constantEqns = tmpMeta4;
      // _columnVars has no default value.
      // _otherColumnVars has no default value.
      // _seedVars has no default value.
      // _indexVars has no default value.
      // _seedIndexVars has no default value.
      // _sparsepattern has no default value.
      // _sparsepatternT has no default value.
      // _nonlinearpattern has no default value.
      // _nonlinearpatternT has no default value.
      // _colsColors has no default value.
      // _maxColor has no default value.
      // _rest has no default value.
      // _linearModelMatrices has no default value.
      // _sparseInts has no default value.
      // _sparseIntsT has no default value.
      // _nonlinearPat has no default value.
      // _nonlinearPatT has no default value.
      // _coloring has no default value.
      // _optionBDAE has no default value.
      // _tmpJac has no default value.
      // _crefToSimVarHTJacobian has no default value.
      tmp6 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp5_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp6 < 6; tmp6++) {
        switch (MMC_SWITCH_CAST(tmp6)) {
        case 0: {
          if (!listEmpty(tmp6_3)) goto tmp5_end;
          
          tmp6 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _inJacobianMatrices;
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp5_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (!listEmpty(tmp6_1)) goto tmp5_end;
          if (listEmpty(tmp6_3)) goto tmp5_end;
          tmpMeta8 = MMC_CAR(tmp6_3);
          tmpMeta9 = MMC_CDR(tmp6_3);
          
          _name = tmpMeta8;
          _restnames = tmpMeta9;
          tmp6 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _tmpJac = _OMC_LIT630;

          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(17));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_tmpJac), 17*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[4] = _name;
          _tmpJac = tmpMeta10;

          tmpMeta11 = mmc_mk_cons(_tmpJac, _inJacobianMatrices);
          _linearModelMatrices = tmpMeta11;
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, tmpMeta12, _inSimVarHT, _iuniqueEqIndex, _restnames, _linearModelMatrices, &tmp1_c1);
          goto tmp5_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (listEmpty(tmp6_3)) goto tmp5_end;
          tmpMeta13 = MMC_CAR(tmp6_3);
          tmpMeta14 = MMC_CDR(tmp6_3);
          if (listEmpty(tmp6_1)) goto tmp5_end;
          tmpMeta15 = MMC_CAR(tmp6_1);
          tmpMeta16 = MMC_CDR(tmp6_1);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          if (!optionNone(tmpMeta17)) goto tmp5_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 1));
          if (!listEmpty(tmpMeta19)) goto tmp5_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          if (!listEmpty(tmpMeta20)) goto tmp5_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 3));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
          if (!listEmpty(tmpMeta22)) goto tmp5_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          if (!listEmpty(tmpMeta23)) goto tmp5_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
          if (!listEmpty(tmpMeta24)) goto tmp5_end;
          
          _name = tmpMeta13;
          _restnames = tmpMeta14;
          _rest = tmpMeta16;
          /* Pattern matching succeeded */
          _tmpJac = _OMC_LIT630;

          tmpMeta25 = MMC_TAGPTR(mmc_alloc_words(17));
          memcpy(MMC_UNTAGPTR(tmpMeta25), MMC_UNTAGPTR(_tmpJac), 17*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta25))[4] = _name;
          _tmpJac = tmpMeta25;

          tmpMeta26 = mmc_mk_cons(_tmpJac, _inJacobianMatrices);
          _linearModelMatrices = tmpMeta26;
          tmpMeta[0+0] = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _rest, _inSimVarHT, _iuniqueEqIndex, _restnames, _linearModelMatrices, &tmp1_c1);
          goto tmp5_done;
        }
        case 3: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          if (listEmpty(tmp6_1)) goto tmp5_end;
          tmpMeta27 = MMC_CAR(tmp6_1);
          tmpMeta28 = MMC_CDR(tmp6_1);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 1));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 1));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 3));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 1));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 3));
          if (listEmpty(tmp6_3)) goto tmp5_end;
          tmpMeta37 = MMC_CAR(tmp6_3);
          tmpMeta38 = MMC_CDR(tmp6_3);
          
          _optionBDAE = tmpMeta29;
          _sparsepattern = tmpMeta31;
          _sparsepatternT = tmpMeta32;
          _diffCompRefs = tmpMeta34;
          _diffedCompRefs = tmpMeta35;
          _colsColors = tmpMeta36;
          _rest = tmpMeta28;
          _name = tmpMeta37;
          _restnames = tmpMeta38;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_SimCodeUtil_checkForEmptyBDAE(threadData, _optionBDAE)) goto tmp5_end;
          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT631),stdout);
          }

          _seedVars = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffCompRefs, _inSimVarHT);

          _seedVars = omc_List_sort(threadData, _seedVars, boxvar_SimCodeUtil_compareVarIndexGt);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta39 = stringAppend(_OMC_LIT632,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _diffCompRefs));
            tmpMeta40 = stringAppend(tmpMeta39,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta40),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT633),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);
          }

          _indexVars = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffedCompRefs, _inSimVarHT);

          _indexVars = omc_List_sort(threadData, _indexVars, boxvar_SimCodeUtil_compareVarIndexGt);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta41 = stringAppend(_OMC_LIT634,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _diffedCompRefs));
            tmpMeta42 = stringAppend(tmpMeta41,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta42),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT635),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT636),stdout);

            omc_SimCodeUtil_dumpSparsePattern(threadData, _sparsepattern);

            fputs(MMC_STRINGDATA(_OMC_LIT637),stdout);

            omc_SimCodeUtil_dumpSparsePattern(threadData, _sparsepatternT);
          }

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, _seedVars, ((modelica_integer) 0), NULL);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, _indexVars, ((modelica_integer) 0), NULL);

          _seedIndexVars = listAppend(_seedVars, _indexVars);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _sparsepattern, 0 /* false */);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _sparsepatternT, 0 /* false */);

          tmpMeta43 = MMC_REFSTRUCTLIT(mmc_nil);
          _nonlinearPat = tmpMeta43;

          tmpMeta44 = MMC_REFSTRUCTLIT(mmc_nil);
          _nonlinearPatT = tmpMeta44;

          _maxColor = listLength(_colsColors);

          _nRows = listLength(_diffedCompRefs);

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _seedVars, _colsColors);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta45 = stringAppend(_OMC_LIT612,_name);
            tmpMeta46 = stringAppend(tmpMeta45,_OMC_LIT606);
            tmpMeta47 = stringAppend(tmpMeta46,realString(mmc_clock()));
            tmpMeta48 = stringAppend(tmpMeta47,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta48),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT636),stdout);

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparseInts);

            fputs(MMC_STRINGDATA(_OMC_LIT637),stdout);

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparseIntsT);
          }

          _seedVars = omc_SimCodeUtil_replaceSeedVarsName(threadData, _seedVars, _name);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT601);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          tmpMeta50 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta51 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta52 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta53 = mmc_mk_box5(3, &SimCode_JacobianColumn_JAC__COLUMN__desc, tmpMeta50, tmpMeta51, mmc_mk_integer(_nRows), tmpMeta52);
          tmpMeta49 = mmc_mk_cons(tmpMeta53, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta54 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta55 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta56 = mmc_mk_box16(3, &SimCode_JacobianMatrix_JAC__MATRIX__desc, tmpMeta49, _seedVars, _name, _sparseInts, _sparseIntsT, _nonlinearPat, _nonlinearPatT, _coloring, tmpMeta54, mmc_mk_integer(_maxColor), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) 0)), tmpMeta55, mmc_mk_none(), mmc_mk_boolean(0 /* false */));
          _tmpJac = tmpMeta56;

          tmpMeta57 = mmc_mk_cons(_tmpJac, _inJacobianMatrices);
          _linearModelMatrices = tmpMeta57;
          tmpMeta[0+0] = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _rest, _inSimVarHT, _iuniqueEqIndex, _restnames, _linearModelMatrices, &tmp1_c1);
          goto tmp5_done;
        }
        case 4: {
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_metatype tmpMeta117;
          modelica_metatype tmpMeta118;
          modelica_metatype tmpMeta119;
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          modelica_metatype tmpMeta125;
          if (listEmpty(tmp6_3)) goto tmp5_end;
          tmpMeta58 = MMC_CAR(tmp6_3);
          tmpMeta59 = MMC_CDR(tmp6_3);
          if (listEmpty(tmp6_1)) goto tmp5_end;
          tmpMeta60 = MMC_CAR(tmp6_1);
          tmpMeta61 = MMC_CDR(tmp6_1);
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 1));
          if (optionNone(tmpMeta62)) goto tmp5_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 1));
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 1));
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 2));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 3));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 4));
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 5));
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 2));
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 1));
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 2));
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 3));
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 1));
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 2));
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 3));
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 4));
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta77), 1));
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta77), 2));
          
          _restnames = tmpMeta59;
          _systs = tmpMeta65;
          _shared = tmpMeta66;
          _name = tmpMeta67;
          _diffedVars = tmpMeta68;
          _alldiffedVars = tmpMeta69;
          _sparsepattern = tmpMeta71;
          _sparsepatternT = tmpMeta72;
          _diffCompRefs = tmpMeta74;
          _diffedCompRefs = tmpMeta75;
          _colsColors = tmpMeta76;
          _nonlinearpattern = tmpMeta78;
          _nonlinearpatternT = tmpMeta79;
          _rest = tmpMeta61;
          _uniqueEqIndex = tmp6_2;
          /* Pattern matching succeeded */
          tmpMeta80 = stringAppend(_OMC_LIT608,_name);
          _dummyVar = tmpMeta80;

          tmpMeta81 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta82 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _dummyVar, _OMC_LIT86, tmpMeta81);
          _x = tmpMeta82;

          _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

          /* Pattern-matching assignment */
          tmpMeta83 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta84 = mmc_mk_box2(0, tmpMeta83, _x);
          tmpMeta85 = omc_BackendVariable_traverseBackendDAEVars(threadData, omc_BackendVariable_listVar1(threadData, omc_BackendVariable_equationSystemsVarsLst(threadData, _systs)), boxvar_SimCodeUtil_getFurtherVars, tmpMeta84);
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta85), 1));
          _allVars = tmpMeta86;

          _systvars = omc_BackendVariable_listVar1(threadData, _allVars);

          /* Pattern-matching assignment */
          tmpMeta87 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta88 = mmc_mk_box2(0, tmpMeta87, _emptyVars);
          tmpMeta89 = omc_BackendVariable_traverseBackendDAEVars(threadData, _systvars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta88);
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta89), 1));
          _otherColumnVars = tmpMeta90;

          _otherColumnVars = omc_List_map1(threadData, _otherColumnVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT609);

          _otherColumnVars = omc_List_map1(threadData, _otherColumnVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          _otherColumnVars = omc_SimCodeUtil_rewriteIndex(threadData, _otherColumnVars, ((modelica_integer) 0), NULL);

          _empty = omc_BackendVariable_listVar1(threadData, _alldiffedVars);

          _allCrefs = omc_List_map(threadData, _alldiffedVars, boxvar_BackendVariable_varCref);

          _columnVars = omc_SimCodeUtil_getSimVars2Crefs(threadData, _allCrefs, _inSimVarHT);

          _columnVars = omc_List_sort(threadData, _columnVars, boxvar_SimCodeUtil_compareVarIndexGt);

          {
            modelica_metatype __omcQ_24tmpVar59;
            modelica_metatype* tmp92;
            modelica_metatype tmpMeta93;
            modelica_metatype __omcQ_24tmpVar58;
            modelica_integer tmp94;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _columnVars;
            tmpMeta93 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar59 = tmpMeta93; /* defaultValue */
            tmp92 = &__omcQ_24tmpVar59;
            while(1) {
              tmp94 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp94--;
              }
              if (tmp94 == 0) {
                __omcQ_24tmpVar58 = omc_SimCodeUtil_sortBackVarWithSimVarsOrder(threadData, _v, _empty);
                *tmp92 = mmc_mk_cons(__omcQ_24tmpVar58,0);
                tmp92 = &MMC_CDR(*tmp92);
              } else if (tmp94 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp92 = mmc_mk_nil();
            tmpMeta91 = __omcQ_24tmpVar59;
          }
          _alldiffedVars = tmpMeta91;

          _vars = omc_BackendVariable_listVar1(threadData, _diffedVars);

          _columnVars = omc_SimCodeUtil_createAllDiffedSimVars(threadData, _alldiffedVars, _x, _vars, ((modelica_integer) 0), listLength(_otherColumnVars), _name, _otherColumnVars);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT638),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _columnVars)),stdout);

            tmpMeta95 = stringAppend(_OMC_LIT639,_name);
            tmpMeta96 = stringAppend(tmpMeta95,_OMC_LIT606);
            tmpMeta97 = stringAppend(tmpMeta96,realString(mmc_clock()));
            tmpMeta98 = stringAppend(tmpMeta97,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta98),stdout);
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta99 = stringAppend(_OMC_LIT611,_name);
            tmpMeta100 = stringAppend(tmpMeta99,_OMC_LIT606);
            tmpMeta101 = stringAppend(tmpMeta100,realString(mmc_clock()));
            tmpMeta102 = stringAppend(tmpMeta101,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta102),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT640),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _columnVars)),stdout);
          }

          _seedVars = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffCompRefs, _inSimVarHT);

          _seedVars = omc_List_sort(threadData, _seedVars, boxvar_SimCodeUtil_compareVarIndexGt);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta103 = stringAppend(_OMC_LIT632,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _diffCompRefs));
            tmpMeta104 = stringAppend(tmpMeta103,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta104),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT633),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);
          }

          _indexVars = omc_SimCodeUtil_getSimVars2Crefs(threadData, _diffedCompRefs, _inSimVarHT);

          _indexVars = omc_List_sort(threadData, _indexVars, boxvar_SimCodeUtil_compareVarIndexGt);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta105 = stringAppend(_OMC_LIT634,omc_ComponentReferenceBasics_printComponentRefListStr(threadData, _diffedCompRefs));
            tmpMeta106 = stringAppend(tmpMeta105,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta106),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT635),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT636),stdout);

            omc_SimCodeUtil_dumpSparsePattern(threadData, _sparsepattern);

            fputs(MMC_STRINGDATA(_OMC_LIT637),stdout);

            omc_SimCodeUtil_dumpSparsePattern(threadData, _sparsepatternT);
          }

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, _seedVars, ((modelica_integer) 0), NULL);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, _indexVars, ((modelica_integer) 0), NULL);

          _seedIndexVars = listAppend(_seedVars, _indexVars);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _sparsepatternT, 0 /* false */);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _sparsepattern, 0 /* false */);

          _nonlinearPat = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _nonlinearpattern, 0 /* false */);

          _nonlinearPatT = omc_SimCodeUtil_sortSparsePattern(threadData, _seedIndexVars, _nonlinearpatternT, 0 /* false */);

          _maxColor = listLength(_colsColors);

          _nRows = listLength(_diffedVars);

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _seedVars, _colsColors);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta107 = stringAppend(_OMC_LIT612,_name);
            tmpMeta108 = stringAppend(tmpMeta107,_OMC_LIT606);
            tmpMeta109 = stringAppend(tmpMeta108,realString(mmc_clock()));
            tmpMeta110 = stringAppend(tmpMeta109,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta110),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT636),stdout);

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparseInts);

            fputs(MMC_STRINGDATA(_OMC_LIT637),stdout);

            omc_SimCodeUtil_dumpSparsePatternInt(threadData, _sparseIntsT);
          }

          _seedVars = omc_SimCodeUtil_replaceSeedVarsName(threadData, _seedVars, _name);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT601);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          _crefToSimVarHTJacobian = omc_HashTableCrefSimVar_emptyHashTableSized(threadData, listLength(_seedVars) + listLength(_columnVars));

          _crefToSimVarHTJacobian = omc_List_fold(threadData, _seedVars, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _crefToSimVarHTJacobian);

          _crefToSimVarHTJacobian = omc_List_fold(threadData, _columnVars, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _crefToSimVarHTJacobian);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta111 = stringAppend(_OMC_LIT605,_name);
            tmpMeta112 = stringAppend(tmpMeta111,_OMC_LIT606);
            tmpMeta113 = stringAppend(tmpMeta112,realString(mmc_clock()));
            tmpMeta114 = stringAppend(tmpMeta113,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta114),stdout);
          }

          tmpMeta115 = MMC_REFSTRUCTLIT(mmc_nil);
          _allEquations = omc_SimCodeUtil_getSimEqSystemForJacobians(threadData, _systs, _shared, _uniqueEqIndex, tmpMeta115 ,&_constantEqns ,&_uniqueEqIndex ,NULL);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta116 = stringAppend(_OMC_LIT607,_name);
            tmpMeta117 = stringAppend(tmpMeta116,_OMC_LIT606);
            tmpMeta118 = stringAppend(tmpMeta117,realString(mmc_clock()));
            tmpMeta119 = stringAppend(tmpMeta118,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta119),stdout);
          }

          tmpMeta121 = mmc_mk_box5(3, &SimCode_JacobianColumn_JAC__COLUMN__desc, _allEquations, _columnVars, mmc_mk_integer(_nRows), _constantEqns);
          tmpMeta120 = mmc_mk_cons(tmpMeta121, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta122 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta123 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta124 = mmc_mk_box16(3, &SimCode_JacobianMatrix_JAC__MATRIX__desc, tmpMeta120, _seedVars, _name, _sparseInts, _sparseIntsT, _nonlinearPat, _nonlinearPatT, _coloring, tmpMeta122, mmc_mk_integer(_maxColor), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) 0)), tmpMeta123, mmc_mk_some(_crefToSimVarHTJacobian), mmc_mk_boolean(0 /* false */));
          _tmpJac = tmpMeta124;

          tmpMeta125 = mmc_mk_cons(_tmpJac, _inJacobianMatrices);
          _linearModelMatrices = tmpMeta125;
          tmpMeta[0+0] = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _rest, _inSimVarHT, _uniqueEqIndex, _restnames, _linearModelMatrices, &tmp1_c1);
          goto tmp5_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT641, _OMC_LIT642);
          goto goto_2;
          goto tmp5_done;
        }
        }
        goto tmp5_end;
        tmp5_end: ;
      }
      goto goto_2;
      tmp5_done:
      (void)tmp6;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp5_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp6 < 6) {
        goto tmp5_top;
      }
      MMC_THROW_INTERNAL();
      tmp5_done2:;
    }
  }
  _outJacobianMatrices = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outJacobianMatrices;
}
modelica_metatype boxptr_SimCodeUtil_createSymbolicJacobianssSimCode(threadData_t *threadData, modelica_metatype _inSymJacobians, modelica_metatype _inSimVarHT, modelica_metatype _iuniqueEqIndex, modelica_metatype _inNames, modelica_metatype _inJacobianMatrices, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outJacobianMatrices = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outJacobianMatrices = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _inSymJacobians, _inSimVarHT, tmp1, _inNames, _inJacobianMatrices, &_ouniqueEqIndex);
  /* skip box _outJacobianMatrices; list<SimCode.JacobianMatrix> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outJacobianMatrices;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_checkForEmptyBDAE(threadData_t *threadData, modelica_metatype _inBDAE)
{
  modelica_boolean _result;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _result has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inBDAE;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!optionNone(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          if (!listEmpty(tmpMeta9)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _result = tmp1;
  _return: OMC_LABEL_UNUSED
  return _result;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_checkForEmptyBDAE(threadData_t *threadData, modelica_metatype _inBDAE)
{
  modelica_boolean _result;
  modelica_metatype out_result;
  _result = omc_SimCodeUtil_checkForEmptyBDAE(threadData, _inBDAE);
  out_result = mmc_mk_icon(_result);
  return out_result;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createJacobianLinearCode(threadData_t *threadData, modelica_metatype _inSymjacs, modelica_metatype _inModelInfo, modelica_integer _iuniqueEqIndex, modelica_metatype _shared, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _res = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp2_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _res = tmpMeta1;
  // _ouniqueEqIndex has no default value.
  
  
  { /* match expression */
    {
      modelica_metatype _crefSimVarHT = NULL;
      modelica_metatype _matrixnames = NULL;
      modelica_metatype _jacH = NULL;
      volatile mmc_switch_type tmp5;
      int tmp6;
      // _crefSimVarHT has no default value.
      // _matrixnames has no default value.
      // _jacH has no default value.
      tmp5 = 0;
      for (; tmp5 < 1; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          /* Pattern matching succeeded */
          _crefSimVarHT = omc_SimCodeUtil_createCrefToSimVarHT(threadData, _inModelInfo);

          if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20)))))
          {
            /* Pattern-matching assignment */
            tmpMeta7 = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20))));
            tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 6));
            _jacH = tmpMeta8;

            if(isSome(_jacH))
            {
              _matrixnames = _OMC_LIT664;
            }
            else
            {
              _matrixnames = _OMC_LIT660;
            }
          }
          else
          {
            _matrixnames = _OMC_LIT656;
          }
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = omc_SimCodeUtil_createSymbolicJacobianssSimCode(threadData, _inSymjacs, _crefSimVarHT, _iuniqueEqIndex, _matrixnames, tmpMeta9, &tmp2_c1);
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  _res = tmpMeta[0+0];
  _ouniqueEqIndex = tmp2_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _res;
}
modelica_metatype boxptr_SimCodeUtil_createJacobianLinearCode(threadData_t *threadData, modelica_metatype _inSymjacs, modelica_metatype _inModelInfo, modelica_metatype _iuniqueEqIndex, modelica_metatype _shared, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _res = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _res = omc_SimCodeUtil_createJacobianLinearCode(threadData, _inSymjacs, _inModelInfo, tmp1, _shared, &_ouniqueEqIndex);
  /* skip box _res; list<SimCode.JacobianMatrix> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _res;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimEqSystemForJacobians(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_constantEqns, modelica_integer *out_uniqueEqIndex, modelica_metatype *out_tempvars)
{
  modelica_metatype _allEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _constantEqns = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _tempvars = NULL;
  modelica_metatype _comps = NULL;
  modelica_metatype _rest = NULL;
  modelica_metatype _syst = NULL;
  modelica_metatype _accEqns = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _allEquations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _constantEqns = tmpMeta2;
  _uniqueEqIndex = _iuniqueEqIndex;
  _tempvars = _itempvars;
  // _comps has no default value.
  // _rest has no default value.
  // _syst has no default value.
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _accEqns = tmpMeta3;
  /* Pattern-matching assignment */
  tmpMeta4 = _inSysts;
  if (listEmpty(tmpMeta4)) MMC_THROW_INTERNAL();
  tmpMeta5 = MMC_CAR(tmpMeta4);
  tmpMeta6 = MMC_CDR(tmpMeta4);
  _syst = tmpMeta5;
  _rest = tmpMeta6;

  /* Pattern-matching assignment */
  tmpMeta7 = _syst;
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 7));
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,1,3) == 0) MMC_THROW_INTERNAL();
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
  _comps = tmpMeta9;

  _allEquations = omc_SimCodeUtil_createEquations(threadData, 0 /* false */, 0 /* false */, 1 /* true */, 0 /* false */, _syst, _inShared, _comps, _uniqueEqIndex, _tempvars ,NULL ,&_uniqueEqIndex ,&_tempvars);

  {
    modelica_metatype _eq;
    for (tmpMeta10 = _rest; !listEmpty(tmpMeta10); tmpMeta10=MMC_CDR(tmpMeta10))
    {
      _eq = MMC_CAR(tmpMeta10);
      /* Pattern-matching assignment */
      tmpMeta11 = _eq;
      tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 7));
      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,3) == 0) MMC_THROW_INTERNAL();
      tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 4));
      _comps = tmpMeta13;

      _constantEqns = omc_SimCodeUtil_createEquations(threadData, 0 /* false */, 0 /* false */, 1 /* true */, 0 /* false */, _eq, _inShared, _comps, _uniqueEqIndex, _tempvars ,NULL ,&_uniqueEqIndex ,&_tempvars);

      tmpMeta14 = mmc_mk_cons(_constantEqns, _accEqns);
      _accEqns = tmpMeta14;
    }
  }

  _constantEqns = omc_List_flattenReverse(threadData, _accEqns);
  _return: OMC_LABEL_UNUSED
  if (out_constantEqns) { *out_constantEqns = _constantEqns; }
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  if (out_tempvars) { *out_tempvars = _tempvars; }
  return _allEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_getSimEqSystemForJacobians(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_constantEqns, modelica_metatype *out_uniqueEqIndex, modelica_metatype *out_tempvars)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _allEquations = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _allEquations = omc_SimCodeUtil_getSimEqSystemForJacobians(threadData, _inSysts, _inShared, tmp1, _itempvars, out_constantEqns, &_uniqueEqIndex, out_tempvars);
  /* skip box _allEquations; list<SimCode.SimEqSystem> */
  /* skip box _constantEqns; list<SimCode.SimEqSystem> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  /* skip box _tempvars; list<SimCodeVar.SimVar> */
  return _allEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getFurtherVars(threadData_t *threadData, modelica_metatype _v, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _diffCref = NULL;
  modelica_metatype _vars = NULL;
  modelica_boolean _b;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVar = _v;
  _outTpl = _inTpl;
  // _diffCref has no default value.
  // _vars has no default value.
  // _b has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _vars = tmpMeta2;
  _diffCref = tmpMeta3;

  _b = omc_ComponentReferenceBasics_crefLastIdentEqual(threadData, omc_BackendVariable_varCref(threadData, _v), _diffCref);

  if((!_b))
  {
    tmpMeta4 = mmc_mk_cons(_v, _vars);
    _vars = tmpMeta4;

    tmpMeta5 = mmc_mk_box2(0, _vars, _diffCref);
    _outTpl = tmpMeta5;
  }
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_updateSimVarIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcolumn, modelica_metatype _crefsHT)
{
  modelica_metatype _column = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _column = __omcQ_24in_5Fcolumn;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _crefsHT;
    {
      modelica_metatype _table = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _table has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _table = tmpMeta6;
          /* Pattern matching succeeded */
          {
            modelica_metatype __omcQ_24tmpVar61;
            modelica_metatype* tmp9;
            modelica_metatype tmpMeta10;
            modelica_metatype __omcQ_24tmpVar60;
            modelica_integer tmp11;
            modelica_metatype _var_loopVar = 0;
            modelica_metatype _var;
            _var_loopVar = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_column), 3)));
            tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar61 = tmpMeta10; /* defaultValue */
            tmp9 = &__omcQ_24tmpVar61;
            while(1) {
              tmp11 = 1;
              if (!listEmpty(_var_loopVar)) {
                _var = MMC_CAR(_var_loopVar);
                _var_loopVar = MMC_CDR(_var_loopVar);
                tmp11--;
              }
              if (tmp11 == 0) {
                __omcQ_24tmpVar60 = omc_BaseHashTable_getOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2))), _table, _var);
                *tmp9 = mmc_mk_cons(__omcQ_24tmpVar60,0);
                tmp9 = &MMC_CDR(*tmp9);
              } else if (tmp11 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp9 = mmc_mk_nil();
            tmpMeta8 = __omcQ_24tmpVar61;
          }
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_column), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[3] = tmpMeta8;
          _column = tmpMeta7;
          tmpMeta1 = _column;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _column;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _column = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _column;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_syncDAEandSimJac(threadData_t *threadData, modelica_metatype _symJac, modelica_metatype __omcQ_24in_5FdaeJac)
{
  modelica_metatype __omcQ_24mrfa_5F28 = NULL;
  modelica_metatype __omcQ_24mrfa_5F29 = NULL;
  modelica_metatype _daeJac = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F28 has no default value.
  // __omcQ_24mrfa_5F29 has no default value.
  _daeJac = __omcQ_24in_5FdaeJac;
  if((stringEqual((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_symJac), 4))), _OMC_LIT643)))
  {
    {
      modelica_metatype __omcQ_24tmpVar63;
      modelica_metatype* tmp2;
      modelica_metatype tmpMeta3;
      modelica_metatype __omcQ_24tmpVar62;
      modelica_integer tmp4;
      modelica_metatype _col_loopVar = 0;
      modelica_metatype _col;
      _col_loopVar = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_symJac), 2)));
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      __omcQ_24tmpVar63 = tmpMeta3; /* defaultValue */
      tmp2 = &__omcQ_24tmpVar63;
      while(1) {
        tmp4 = 1;
        if (!listEmpty(_col_loopVar)) {
          _col = MMC_CAR(_col_loopVar);
          _col_loopVar = MMC_CDR(_col_loopVar);
          tmp4--;
        }
        if (tmp4 == 0) {
          __omcQ_24tmpVar62 = omc_SimCodeUtil_updateSimVarIndex(threadData, _col, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 15))));
          *tmp2 = mmc_mk_cons(__omcQ_24tmpVar62,0);
          tmp2 = &MMC_CDR(*tmp2);
        } else if (tmp4 == 1) {
          break;
        } else {
          MMC_THROW_INTERNAL();
        }
      }
      *tmp2 = mmc_mk_nil();
      tmpMeta1 = __omcQ_24tmpVar63;
    }
    __omcQ_24mrfa_5F28 = tmpMeta1;

    __omcQ_24mrfa_5F29 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_symJac), 12)));

    tmpMeta5 = mmc_mk_box16(3, &SimCode_JacobianMatrix_JAC__MATRIX__desc, __omcQ_24mrfa_5F28, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 6))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 7))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 8))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 9))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 11))), __omcQ_24mrfa_5F29, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 13))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 14))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 15))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeJac), 16))));
    _daeJac = tmpMeta5;
  }
  else
  {
    _daeJac = _symJac;
  }
  _return: OMC_LABEL_UNUSED
  return _daeJac;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData_t *threadData, modelica_metatype _inJacobian, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_boolean _detectNonlinearPattern, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _res = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp6_1;volatile modelica_integer tmp6_2;volatile modelica_metatype tmp6_3;
    tmp6_1 = _inJacobian;
    tmp6_2 = _iuniqueEqIndex;
    tmp6_3 = _itempvars;
    {
      modelica_metatype _emptyVars = NULL;
      modelica_metatype _independentVars = NULL;
      modelica_metatype _residualVars = NULL;
      modelica_metatype _systvars = NULL;
      modelica_metatype _independentVarsLst = NULL;
      modelica_metatype _dependentVarsLst = NULL;
      modelica_metatype _residualVarsLst = NULL;
      modelica_metatype _allVars = NULL;
      modelica_metatype _independentComRefs = NULL;
      modelica_metatype _dependentVarsComRefs = NULL;
      modelica_metatype _x = NULL;
      modelica_metatype _pattern = NULL;
      modelica_metatype _sparseColoring = NULL;
      modelica_metatype _coloring = NULL;
      modelica_metatype _sparsepatternComRefs = NULL;
      modelica_metatype _sparsepatternComRefsT = NULL;
      modelica_metatype _nonlinearpatternComRefs = NULL;
      modelica_metatype _nonlinearpatternComRefsT = NULL;
      modelica_metatype _sparseInts = NULL;
      modelica_metatype _sparseIntsT = NULL;
      modelica_metatype _nonlinearPat = NULL;
      modelica_metatype _nonlinearPatT = NULL;
      modelica_metatype _systs = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_string _name = NULL;
      modelica_string _dummyVar = NULL;
      modelica_integer _maxColor;
      modelica_integer _uniqueEqIndex;
      modelica_integer _nRows;
      modelica_metatype _allEquations = NULL;
      modelica_metatype tmpMeta3;
      modelica_metatype _constantEqns = NULL;
      modelica_metatype tmpMeta4;
      modelica_metatype _columnVars = NULL;
      modelica_metatype _varsSeedIndex = NULL;
      modelica_metatype _seedVars = NULL;
      modelica_metatype _indexVars = NULL;
      modelica_string _errorMessage = NULL;
      modelica_metatype _crefToSimVarHTJacobian = NULL;
      volatile mmc_switch_type tmp6;
      int tmp7;
      // _emptyVars has no default value.
      // _independentVars has no default value.
      // _residualVars has no default value.
      // _systvars has no default value.
      // _independentVarsLst has no default value.
      // _dependentVarsLst has no default value.
      // _residualVarsLst has no default value.
      // _allVars has no default value.
      // _independentComRefs has no default value.
      // _dependentVarsComRefs has no default value.
      // _x has no default value.
      // _pattern has no default value.
      // _sparseColoring has no default value.
      // _coloring has no default value.
      // _sparsepatternComRefs has no default value.
      // _sparsepatternComRefsT has no default value.
      // _nonlinearpatternComRefs has no default value.
      // _nonlinearpatternComRefsT has no default value.
      // _sparseInts has no default value.
      // _sparseIntsT has no default value.
      // _nonlinearPat has no default value.
      // _nonlinearPatT has no default value.
      // _systs has no default value.
      // _shared has no default value.
      // _tempvars has no default value.
      // _name has no default value.
      // _dummyVar has no default value.
      // _maxColor has no default value.
      // _uniqueEqIndex has no default value.
      // _nRows has no default value.
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      _allEquations = tmpMeta3;
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _constantEqns = tmpMeta4;
      // _columnVars has no default value.
      // _varsSeedIndex has no default value.
      // _seedVars has no default value.
      // _indexVars has no default value.
      // _errorMessage has no default value.
      // _crefToSimVarHTJacobian has no default value.
      tmp6 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp5_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp6 < 5; tmp6++) {
        switch (MMC_SWITCH_CAST(tmp6)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,2,0) == 0) goto tmp5_end;
          
          tmp6 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp5_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,0,1) == 0) goto tmp5_end;
          
          tmp6 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp5_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,1,4) == 0) goto tmp5_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 2));
          if (!optionNone(tmpMeta8)) goto tmp5_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 4));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 5));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 1));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          
          _pattern = tmpMeta9;
          _sparsepatternComRefs = tmpMeta10;
          _sparsepatternComRefsT = tmpMeta11;
          _independentComRefs = tmpMeta13;
          _dependentVarsComRefs = tmpMeta14;
          _sparseColoring = tmpMeta15;
          _nonlinearpatternComRefs = tmpMeta17;
          _nonlinearpatternComRefsT = tmpMeta18;
          tmp6 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta19 = stringAppend(_OMC_LIT596,realString(mmc_clock()));
            tmpMeta20 = stringAppend(tmpMeta19,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta20),stdout);

            omc_BackendDump_dumpSparsityPattern(threadData, _pattern, _OMC_LIT597);
          }

          {
            modelica_metatype __omcQ_24tmpVar65;
            modelica_metatype* tmp22;
            modelica_metatype tmpMeta23;
            modelica_metatype __omcQ_24tmpVar64;
            modelica_integer tmp24;
            modelica_metatype _cr_loopVar = 0;
            modelica_metatype _cr;
            _cr_loopVar = _independentComRefs;
            tmpMeta23 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar65 = tmpMeta23; /* defaultValue */
            tmp22 = &__omcQ_24tmpVar65;
            while(1) {
              tmp24 = 1;
              if (!listEmpty(_cr_loopVar)) {
                _cr = MMC_CAR(_cr_loopVar);
                _cr_loopVar = MMC_CDR(_cr_loopVar);
                tmp24--;
              }
              if (tmp24 == 0) {
                __omcQ_24tmpVar64 = omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData, _cr, _OMC_LIT601);
                *tmp22 = mmc_mk_cons(__omcQ_24tmpVar64,0);
                tmp22 = &MMC_CDR(*tmp22);
              } else if (tmp24 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp22 = mmc_mk_nil();
            tmpMeta21 = __omcQ_24tmpVar65;
          }
          _seedVars = tmpMeta21;

          {
            modelica_metatype __omcQ_24tmpVar67;
            modelica_metatype* tmp26;
            modelica_metatype tmpMeta27;
            modelica_metatype __omcQ_24tmpVar66;
            modelica_integer tmp28;
            modelica_metatype _cr_loopVar = 0;
            modelica_metatype _cr;
            _cr_loopVar = _dependentVarsComRefs;
            tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar67 = tmpMeta27; /* defaultValue */
            tmp26 = &__omcQ_24tmpVar67;
            while(1) {
              tmp28 = 1;
              if (!listEmpty(_cr_loopVar)) {
                _cr = MMC_CAR(_cr_loopVar);
                _cr_loopVar = MMC_CDR(_cr_loopVar);
                tmp28--;
              }
              if (tmp28 == 0) {
                __omcQ_24tmpVar66 = omc_SimCodeUtil_makeTmpRealSimCodeVar(threadData, _cr, _OMC_LIT87);
                *tmp26 = mmc_mk_cons(__omcQ_24tmpVar66,0);
                tmp26 = &MMC_CDR(*tmp26);
              } else if (tmp28 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp26 = mmc_mk_nil();
            tmpMeta25 = __omcQ_24tmpVar67;
          }
          _indexVars = tmpMeta25;

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, _seedVars, ((modelica_integer) 0), NULL);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, _indexVars, ((modelica_integer) 0), NULL);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT602),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT603),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);
          }

          _varsSeedIndex = listAppend(_seedVars, _indexVars);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefs, 0 /* false */);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefsT, 0 /* false */);

          _nonlinearPat = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _nonlinearpatternComRefs, 0 /* false */);

          _nonlinearPatT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _nonlinearpatternComRefsT, 0 /* false */);

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _seedVars, _sparseColoring);

          _maxColor = listLength(_sparseColoring);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta29 = stringAppend(_OMC_LIT604,realString(mmc_clock()));
            tmpMeta30 = stringAppend(tmpMeta29,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta30),stdout);
          }
          tmpMeta31 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta32 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta33 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta34 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta35 = mmc_mk_box16(3, &SimCode_JacobianMatrix_JAC__MATRIX__desc, tmpMeta31, tmpMeta32, _OMC_LIT31, _sparseInts, _sparseIntsT, _nonlinearPat, _nonlinearPatT, _coloring, tmpMeta33, mmc_mk_integer(_maxColor), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) 0)), tmpMeta34, mmc_mk_none(), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = mmc_mk_some(tmpMeta35);
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp5_done;
        }
        case 3: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,1,4) == 0) goto tmp5_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 2));
          if (optionNone(tmpMeta36)) goto tmp5_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 1));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 1));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 3));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 3));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 4));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 5));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 3));
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 1));
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 2));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 4));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 5));
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 1));
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          
          _systs = tmpMeta39;
          _shared = tmpMeta40;
          _name = tmpMeta41;
          _independentVarsLst = tmpMeta42;
          _residualVarsLst = tmpMeta43;
          _dependentVarsLst = tmpMeta44;
          _sparsepatternComRefs = tmpMeta46;
          _sparsepatternComRefsT = tmpMeta47;
          _sparseColoring = tmpMeta48;
          _nonlinearpatternComRefs = tmpMeta50;
          _nonlinearpatternComRefsT = tmpMeta51;
          _uniqueEqIndex = tmp6_2;
          _tempvars = tmp6_3;
          /* Pattern matching succeeded */
          tmpMeta52 = stringAppend(_OMC_LIT608,_name);
          _dummyVar = tmpMeta52;

          tmpMeta53 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta54 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _dummyVar, _OMC_LIT86, tmpMeta53);
          _x = tmpMeta54;

          _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

          _residualVars = omc_BackendVariable_listVar1(threadData, _residualVarsLst);

          _independentVars = omc_BackendVariable_listVar1(threadData, _independentVarsLst);

          /* Pattern-matching assignment */
          tmpMeta55 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta56 = mmc_mk_box2(0, tmpMeta55, _x);
          tmpMeta57 = omc_BackendVariable_traverseBackendDAEVars(threadData, omc_BackendVariable_listVar1(threadData, omc_BackendVariable_equationSystemsVarsLst(threadData, _systs)), boxvar_SimCodeUtil_getFurtherVars, tmpMeta56);
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 1));
          _allVars = tmpMeta58;

          _systvars = omc_BackendVariable_listVar1(threadData, _allVars);

          /* Pattern-matching assignment */
          tmpMeta59 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta60 = mmc_mk_box2(0, tmpMeta59, _emptyVars);
          tmpMeta61 = omc_BackendVariable_traverseBackendDAEVars(threadData, _systvars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta60);
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta61), 1));
          _columnVars = tmpMeta62;

          _columnVars = omc_List_map1(threadData, _columnVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT609);

          _columnVars = omc_List_map1(threadData, _columnVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          _columnVars = omc_SimCodeUtil_rewriteIndex(threadData, _columnVars, ((modelica_integer) 0), NULL);

          _columnVars = omc_SimCodeUtil_createAllDiffedSimVars(threadData, _dependentVarsLst, _x, _residualVars, ((modelica_integer) 0), listLength(_columnVars), _name, _columnVars);

          _columnVars = listReverse(_columnVars);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT610),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _columnVars)),stdout);

            tmpMeta63 = stringAppend(_OMC_LIT611,_name);
            tmpMeta64 = stringAppend(tmpMeta63,_OMC_LIT606);
            tmpMeta65 = stringAppend(tmpMeta64,realString(mmc_clock()));
            tmpMeta66 = stringAppend(tmpMeta65,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta66),stdout);
          }

          /* Pattern-matching assignment */
          tmpMeta67 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta68 = mmc_mk_box2(0, tmpMeta67, _emptyVars);
          tmpMeta69 = omc_BackendVariable_traverseBackendDAEVars(threadData, _independentVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta68);
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 1));
          _seedVars = tmpMeta70;

          /* Pattern-matching assignment */
          tmpMeta71 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta72 = mmc_mk_box2(0, tmpMeta71, _emptyVars);
          tmpMeta73 = omc_BackendVariable_traverseBackendDAEVars(threadData, _residualVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta72);
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 1));
          _indexVars = tmpMeta74;

          _seedVars = omc_SimCodeUtil_rewriteIndex(threadData, listReverse(_seedVars), ((modelica_integer) 0), NULL);

          _indexVars = omc_SimCodeUtil_rewriteIndex(threadData, listReverse(_indexVars), ((modelica_integer) 0), NULL);

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            fputs(MMC_STRINGDATA(_OMC_LIT602),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _seedVars)),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT603),stdout);

            fputs(MMC_STRINGDATA(omc_Tpl_tplString(threadData, boxvar_SimCodeDump_dumpVarsShort, _indexVars)),stdout);
          }

          _varsSeedIndex = listAppend(_seedVars, _indexVars);

          _sparseInts = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefs, 0 /* false */);

          _sparseIntsT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _sparsepatternComRefsT, 0 /* false */);

          if(_detectNonlinearPattern)
          {
            _nonlinearPat = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _nonlinearpatternComRefs, 0 /* false */);

            _nonlinearPatT = omc_SimCodeUtil_sortSparsePattern(threadData, _varsSeedIndex, _nonlinearpatternComRefsT, 0 /* false */);
          }
          else
          {
            tmpMeta75 = MMC_REFSTRUCTLIT(mmc_nil);
            _nonlinearPat = tmpMeta75;

            tmpMeta76 = MMC_REFSTRUCTLIT(mmc_nil);
            _nonlinearPatT = tmpMeta76;
          }

          _coloring = omc_SimCodeUtil_sortColoring(threadData, _varsSeedIndex, _sparseColoring);

          _maxColor = listLength(_sparseColoring);

          _nRows = listLength(_residualVarsLst);

          _seedVars = omc_SimCodeUtil_replaceSeedVarsName(threadData, _seedVars, _name);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarKind, _OMC_LIT601);

          _seedVars = omc_List_map1(threadData, _seedVars, boxvar_SimCodeUtil_setSimVarMatrixName, mmc_mk_some(_name));

          if(omc_Flags_isSet(threadData, _OMC_LIT600))
          {
            tmpMeta77 = stringAppend(_OMC_LIT612,_name);
            tmpMeta78 = stringAppend(tmpMeta77,_OMC_LIT606);
            tmpMeta79 = stringAppend(tmpMeta78,realString(mmc_clock()));
            tmpMeta80 = stringAppend(tmpMeta79,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta80),stdout);
          }

          _crefToSimVarHTJacobian = omc_HashTableCrefSimVar_emptyHashTableSized(threadData, listLength(_seedVars) + listLength(_columnVars));

          _crefToSimVarHTJacobian = omc_List_fold(threadData, _seedVars, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _crefToSimVarHTJacobian);

          _crefToSimVarHTJacobian = omc_List_fold(threadData, _columnVars, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _crefToSimVarHTJacobian);

          _allEquations = omc_SimCodeUtil_getSimEqSystemForJacobians(threadData, _systs, _shared, _uniqueEqIndex, _tempvars ,&_constantEqns ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta82 = mmc_mk_box5(3, &SimCode_JacobianColumn_JAC__COLUMN__desc, _allEquations, _columnVars, mmc_mk_integer(_nRows), _constantEqns);
          tmpMeta81 = mmc_mk_cons(tmpMeta82, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta83 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta84 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta85 = mmc_mk_box16(3, &SimCode_JacobianMatrix_JAC__MATRIX__desc, tmpMeta81, _seedVars, _name, _sparseInts, _sparseIntsT, _nonlinearPat, _nonlinearPatT, _coloring, tmpMeta83, mmc_mk_integer(_maxColor), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) 0)), tmpMeta84, mmc_mk_some(_crefToSimVarHTJacobian), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = mmc_mk_some(tmpMeta85);
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp5_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT619))
          {
            _errorMessage = _OMC_LIT615;

            omc_Error_addInternalError(threadData, _errorMessage, _OMC_LIT665);
          }
          tmpMeta[0+0] = mmc_mk_none();
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp5_done;
        }
        }
        goto tmp5_end;
        tmp5_end: ;
      }
      goto goto_2;
      tmp5_done:
      (void)tmp6;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp5_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp6 < 5) {
        goto tmp5_top;
      }
      MMC_THROW_INTERNAL();
      tmp5_done2:;
    }
  }
  _res = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _res;
}
modelica_metatype boxptr_SimCodeUtil_createSymbolicSimulationJacobian(threadData_t *threadData, modelica_metatype _inJacobian, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _detectNonlinearPattern, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _res = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_detectNonlinearPattern);
  _res = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, tmp1, _itempvars, tmp2, &_ouniqueEqIndex, out_otempvars);
  /* skip box _res; Option<SimCode.JacobianMatrix> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _res;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createStateSetsSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iVars, modelica_metatype _iEqns, modelica_metatype _comps, modelica_metatype _iEquations, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _iNumStateSets, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_integer *out_oNumStateSets)
{
  modelica_metatype _oEquations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer _oNumStateSets;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_integer tmp1_c3 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEquations has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _oNumStateSets has no default value.
  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _iStateSets;
    {
      modelica_metatype _sets = NULL;
      modelica_integer _rang;
      modelica_integer _nCandidates;
      modelica_metatype _crset = NULL;
      modelica_metatype _crA = NULL;
      modelica_metatype _aVars = NULL;
      modelica_metatype _statevars = NULL;
      modelica_metatype _crstates = NULL;
      modelica_metatype _jacobianMatrix = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _simCodeAVars = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _jacobian = NULL;
      modelica_string _errorMessage = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _sets has no default value.
      // _rang has no default value.
      // _nCandidates has no default value.
      // _crset has no default value.
      // _crA has no default value.
      // _aVars has no default value.
      // _statevars has no default value.
      // _crstates has no default value.
      // _jacobianMatrix has no default value.
      // _tempvars has no default value.
      // _simCodeAVars has no default value.
      // _uniqueEqIndex has no default value.
      // _jacobian has no default value.
      // _errorMessage has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _iEquations;
          tmp1_c1 = _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          tmp1_c3 = _iNumStateSets;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 6));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 7));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 13));
          _rang = tmp9  /* pattern as ty=Integer */;
          _crset = tmpMeta10;
          _crA = tmpMeta11;
          _aVars = tmpMeta12;
          _statevars = tmpMeta13;
          _jacobian = tmpMeta14;
          _sets = tmpMeta7;
          /* Pattern matching succeeded */
          _crstates = omc_List_map(threadData, _statevars, boxvar_BackendVariable_varCref);

          _simCodeAVars = omc_List_map3(threadData, _aVars, boxvar_SimCodeUtil_dlowvarToSimvar, mmc_mk_none(), _iVars, mmc_mk_none());

          _crA = omc_ComponentReference_subscriptCrefWithInt(threadData, _crA, ((modelica_integer) 1));

          _crA = ((listLength(_crset) > ((modelica_integer) 1))?omc_ComponentReference_subscriptCrefWithInt(threadData, _crA, ((modelica_integer) 1)):_crA);

          _nCandidates = listLength(_statevars);

          /* Pattern-matching tuple assignment */
          tmpMeta17 = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _jacobian, _iuniqueEqIndex, listAppend(_itempvars, _simCodeAVars), 0 /* false */, &tmp15, &tmpMeta16);
          if (optionNone(tmpMeta17)) goto goto_2;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 1));
          _jacobianMatrix = tmpMeta18;
          _uniqueEqIndex = tmp15;
          _tempvars = tmpMeta16;
          tmpMeta20 = mmc_mk_box8(3, &SimCode_StateSet_SES__STATESET__desc, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(_nCandidates), mmc_mk_integer(_rang), _crset, _crstates, _crA, _jacobianMatrix);
          tmpMeta19 = mmc_mk_cons(tmpMeta20, _iEquations);
          tmpMeta[0+0] = omc_SimCodeUtil_createStateSetsSets(threadData, _sets, _iVars, _iEqns, _comps, tmpMeta19, _uniqueEqIndex, _tempvars, ((modelica_integer) 1) + _iNumStateSets, &tmp1_c1, &tmpMeta[0+2], &tmp1_c3);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          _errorMessage = _OMC_LIT666;

          omc_Error_addInternalError(threadData, _errorMessage, _OMC_LIT667);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oEquations = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _oNumStateSets = tmp1_c3;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_oNumStateSets) { *out_oNumStateSets = _oNumStateSets; }
  return _oEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createStateSetsSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iVars, modelica_metatype _iEqns, modelica_metatype _comps, modelica_metatype _iEquations, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iNumStateSets, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oNumStateSets)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_integer _oNumStateSets;
  modelica_metatype _oEquations = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_iNumStateSets);
  _oEquations = omc_SimCodeUtil_createStateSetsSets(threadData, _iStateSets, _iVars, _iEqns, _comps, _iEquations, tmp1, _itempvars, tmp2, &_ouniqueEqIndex, out_otempvars, &_oNumStateSets);
  /* skip box _oEquations; list<SimCode.StateSet> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  if (out_oNumStateSets) { *out_oNumStateSets = mmc_mk_icon(_oNumStateSets); }
  return _oEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createStateSetsSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl)
{
  modelica_metatype _osyst = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _osyst has no default value.
  _outShared = _inShared;
  // _outTpl has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _isyst;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _stateSets = NULL;
      modelica_metatype _syst = NULL;
      modelica_metatype _equations = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_integer _numStateSets;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _comps = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _eqns has no default value.
      // _stateSets has no default value.
      // _syst has no default value.
      // _equations has no default value.
      // _uniqueEqIndex has no default value.
      // _numStateSets has no default value.
      // _tempvars has no default value.
      // _comps has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          if (!listEmpty(tmpMeta6)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _isyst;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,3) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          _syst = tmp4_1;
          _vars = tmpMeta7;
          _eqns = tmpMeta8;
          _comps = tmpMeta10;
          _stateSets = tmpMeta11;
          _equations = tmpMeta12;
          _uniqueEqIndex = tmp14  /* pattern as ty=Integer */;
          _tempvars = tmpMeta15;
          _numStateSets = tmp17  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _equations = omc_SimCodeUtil_createStateSetsSets(threadData, _stateSets, _vars, _eqns, _comps, _equations, _uniqueEqIndex, _tempvars, _numStateSets ,&_uniqueEqIndex ,&_tempvars ,&_numStateSets);
          tmpMeta18 = mmc_mk_box4(0, _equations, mmc_mk_integer(_uniqueEqIndex), _tempvars, mmc_mk_integer(_numStateSets));
          tmpMeta[0+0] = _syst;
          tmpMeta[0+1] = tmpMeta18;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _osyst = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _osyst;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createStateSets(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _iEquations, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_oEquations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_integer *out_numStateSets)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _oEquations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer _numStateSets;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _oEquations has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _numStateSets has no default value.
  if((stringEqual(omc_Flags_getConfigString(threadData, _OMC_LIT688), _OMC_LIT678)))
  {
    _outDAE = _inDAE;

    _oEquations = _iEquations;

    _ouniqueEqIndex = _iuniqueEqIndex;

    _otempvars = _itempvars;

    _numStateSets = ((modelica_integer) 0);
  }
  else
  {
    /* Pattern-matching tuple assignment */
    tmpMeta8 = mmc_mk_box4(0, _iEquations, mmc_mk_integer(_iuniqueEqIndex), _itempvars, mmc_mk_integer(((modelica_integer) 0)));
    tmpMeta9 = omc_BackendDAEUtil_mapEqSystemAndFold(threadData, _inDAE, boxvar_SimCodeUtil_createStateSetsSystem, tmpMeta8, &tmpMeta1);
    _outDAE = tmpMeta9;
    tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
    tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
    tmp4 = mmc_unbox_integer(tmpMeta3);
    tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
    tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
    tmp7 = mmc_unbox_integer(tmpMeta6);
    _oEquations = tmpMeta2;
    _ouniqueEqIndex = tmp4  /* pattern as ty=Integer */;
    _otempvars = tmpMeta5;
    _numStateSets = tmp7  /* pattern as ty=Integer */;
  }
  _return: OMC_LABEL_UNUSED
  if (out_oEquations) { *out_oEquations = _oEquations; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_numStateSets) { *out_numStateSets = _numStateSets; }
  return _outDAE;
}
modelica_metatype boxptr_SimCodeUtil_createStateSets(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _iEquations, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_oEquations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_numStateSets)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_integer _numStateSets;
  modelica_metatype _outDAE = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outDAE = omc_SimCodeUtil_createStateSets(threadData, _inDAE, _iEquations, tmp1, _itempvars, out_oEquations, &_ouniqueEqIndex, out_otempvars, &_numStateSets);
  /* skip box _outDAE; BackendDAE.BackendDAE */
  /* skip box _oEquations; list<SimCode.StateSet> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  if (out_numStateSets) { *out_numStateSets = mmc_mk_icon(_numStateSets); }
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_fillLocalHashTable(threadData_t *threadData, modelica_metatype _varListList, modelica_integer _numberOfElements)
{
  modelica_metatype _hashTable = NULL;
  modelica_integer _sizeHT;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _hashTable has no default value.
  // _sizeHT has no default value.
  _sizeHT = modelica_integer_max((modelica_integer)(((modelica_integer) 1013)),(modelica_integer)(omc_Util_nextPrime(threadData, (((modelica_integer) 2)) * (_numberOfElements))));

  _hashTable = omc_HashTableCrefSimVar_emptyHashTableSized(threadData, _sizeHT);

  {
    modelica_metatype _simVarList;
    for (tmpMeta1 = _varListList; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _simVarList = MMC_CAR(tmpMeta1);
      _hashTable = omc_List_fold(threadData, _simVarList, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _hashTable);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _hashTable;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_fillLocalHashTable(threadData_t *threadData, modelica_metatype _varListList, modelica_metatype _numberOfElements)
{
  modelica_integer tmp1;
  modelica_metatype _hashTable = NULL;
  tmp1 = mmc_unbox_integer(_numberOfElements);
  _hashTable = omc_SimCodeUtil_fillLocalHashTable(threadData, _varListList, tmp1);
  /* skip box _hashTable; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<tuple<DAE.ComponentRef, SimCodeVar.SimVar>>>>, #Integer, tuple<.HashTableCrefSimVar.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashTableCrefSimVar.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashTableCrefSimVar.FuncCrefStr<function>(DAE.ComponentRef cr) => String, .HashTableCrefSimVar.FuncExpStr<function>(SimCodeVar.SimVar exp) => String>> */
  return _hashTable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendOMSIFunction(threadData_t *threadData, modelica_metatype __omcQ_24in_5FomsiFunction_5F1, modelica_metatype _omsiFunction_2)
{
  modelica_metatype __omcQ_24mrfa_5F30 = NULL;
  modelica_metatype __omcQ_24mrfa_5F31 = NULL;
  modelica_metatype __omcQ_24mrfa_5F32 = NULL;
  modelica_metatype __omcQ_24mrfa_5F33 = NULL;
  modelica_metatype __omcQ_24mrfa_5F34 = NULL;
  modelica_metatype __omcQ_24mrfa_5F35 = NULL;
  modelica_metatype __omcQ_24mrfa_5F36 = NULL;
  modelica_metatype _omsiFunction_1 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta13;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // __omcQ_24mrfa_5F30 has no default value.
  // __omcQ_24mrfa_5F31 has no default value.
  // __omcQ_24mrfa_5F32 has no default value.
  // __omcQ_24mrfa_5F33 has no default value.
  // __omcQ_24mrfa_5F34 has no default value.
  // __omcQ_24mrfa_5F35 has no default value.
  // __omcQ_24mrfa_5F36 has no default value.
  _omsiFunction_1 = __omcQ_24in_5FomsiFunction_5F1;
  __omcQ_24mrfa_5F30 = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 2))));

  __omcQ_24mrfa_5F31 = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 3))));

  __omcQ_24mrfa_5F32 = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 4))));

  __omcQ_24mrfa_5F33 = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 5))));

  __omcQ_24mrfa_5F34 = mmc_mk_integer(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 6)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 6)))));

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 7)));
    {
      modelica_metatype _hashTable = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _hashTable has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,9,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          _hashTable = tmpMeta7;
          /* Pattern matching succeeded */
          _hashTable = omc_List_fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 3))), boxvar_HashTableCrefSimVar_addSimVarToHashTable, _hashTable);

          {
            modelica_metatype _simVar;
            for (tmpMeta8 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 4))); !listEmpty(tmpMeta8); tmpMeta8=MMC_CDR(tmpMeta8))
            {
              _simVar = MMC_CAR(tmpMeta8);
              _hashTable = omc_HashTableCrefSimVar_addSimVarToHashTable(threadData, _simVar, _hashTable);
            }
          }

          {
            modelica_metatype _simVar;
            for (tmpMeta10 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 5))); !listEmpty(tmpMeta10); tmpMeta10=MMC_CDR(tmpMeta10))
            {
              _simVar = MMC_CAR(tmpMeta10);
              _hashTable = omc_HashTableCrefSimVar_addSimVarToHashTable(threadData, _simVar, _hashTable);
            }
          }
          tmpMeta12 = mmc_mk_box2(12, &SimCodeFunction_Context_OMSI__CONTEXT__desc, mmc_mk_some(_hashTable));
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  __omcQ_24mrfa_5F35 = tmpMeta1;

  __omcQ_24mrfa_5F36 = mmc_mk_integer(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_1), 8)))) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFunction_2), 8)))));

  tmpMeta13 = mmc_mk_box8(3, &SimCode_OMSIFunction_OMSI__FUNCTION__desc, __omcQ_24mrfa_5F30, __omcQ_24mrfa_5F31, __omcQ_24mrfa_5F32, __omcQ_24mrfa_5F33, __omcQ_24mrfa_5F34, __omcQ_24mrfa_5F35, __omcQ_24mrfa_5F36);
  _omsiFunction_1 = tmpMeta13;
  _return: OMC_LABEL_UNUSED
  return _omsiFunction_1;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _syst, modelica_metatype _shared, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_outputVars, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _equations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outputVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _uniqueEqIndex;
  modelica_integer _eqnindx;
  modelica_metatype _vars = NULL;
  modelica_metatype _tmpOutputVars = NULL;
  modelica_metatype _tmpVars = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _comp = NULL;
  modelica_metatype _dblLstEqns = NULL;
  modelica_metatype _omsiFuncEquations = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _equations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outputVars = tmpMeta2;
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  // _eqnindx has no default value.
  // _vars has no default value.
  // _tmpOutputVars has no default value.
  // _tmpVars has no default value.
  // _eqn has no default value.
  // _comp has no default value.
  // _dblLstEqns has no default value.
  // _omsiFuncEquations has no default value.
  _dblLstEqns = omc_DoubleEnded_fromList(threadData, _equations);

  {
    modelica_metatype _eq;
    for (tmpMeta3 = _innerEquations; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _eq = MMC_CAR(tmpMeta3);
      _eqnindx = omc_BackendDAEUtil_getEqnAndVarsFromInnerEquation(threadData, _eq ,&_vars ,NULL);

      _tmpVars = omc_List_map1r(threadData, _vars, boxvar_BackendVariable_getVarAt, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))));

      _tmpVars = omc_BackendVariable_setVarsKind(threadData, _tmpVars, _OMC_LIT689);

      /* Pattern-matching assignment */
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      tmpMeta5 = mmc_mk_box2(0, tmpMeta4, omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 0)));
      tmpMeta6 = omc_List_fold(threadData, _tmpVars, boxvar_SimCodeUtil_traversingdlowvarToSimvarFold, tmpMeta5);
      tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
      _tmpOutputVars = tmpMeta7;

      _outputVars = omc_List_append__reverse(threadData, _tmpOutputVars, _outputVars);

      _eqn = omc_BackendEquation_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), _eqnindx);

      _comp = omc_SimCodeUtil_createTornSystemInnerEqns1(threadData, _eqn, _eqnindx, _vars);

      tmpMeta8 = mmc_mk_cons(_comp, MMC_REFSTRUCTLIT(mmc_nil));
      _omsiFuncEquations = omc_SimCodeUtil_generateEquationsForComponents(threadData, tmpMeta8, _syst, _shared, _uniqueEqIndex ,&_uniqueEqIndex);

      omc_DoubleEnded_push__list__back(threadData, _dblLstEqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiFuncEquations), 2))));
    }
  }

  _outputVars = listReverseInPlace(_outputVars);

  tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
  _equations = omc_DoubleEnded_toListAndClear(threadData, _dblLstEqns, tmpMeta10);
  _return: OMC_LABEL_UNUSED
  if (out_outputVars) { *out_outputVars = _outputVars; }
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _equations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_outputVars, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _equations = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _equations = omc_SimCodeUtil_generateInnerEqns(threadData, _innerEquations, _syst, _shared, tmp1, out_outputVars, &_uniqueEqIndex);
  /* skip box _equations; list<SimCode.SimEqSystem> */
  /* skip box _outputVars; list<SimCodeVar.SimVar> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _equations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateSingleEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _var, modelica_metatype _funcTree, modelica_metatype _timeInterval, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_inputVars, modelica_metatype *out_outputVars, modelica_metatype *out_innerVars, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _equations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _inputVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _outputVars = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _innerVars = NULL;
  modelica_metatype tmpMeta4;
  modelica_integer _uniqueEqIndex;
  modelica_boolean _debug;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _equations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _inputVars = tmpMeta2;
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _outputVars = tmpMeta3;
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _innerVars = tmpMeta4;
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  _debug = 0 /* false */;
  { /* match expression */
    modelica_metatype tmp7_1;
    tmp7_1 = _eqn;
    {
      modelica_metatype _lhs = NULL;
      modelica_metatype _rhs = NULL;
      modelica_metatype _resolvedExp = NULL;
      modelica_metatype _varExp = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      modelica_metatype _whenEquation = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _oelseWhen = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _tmpSimEqLst = NULL;
      modelica_metatype _newSimVar = NULL;
      modelica_metatype _solveEqns = NULL;
      modelica_metatype _asserts = NULL;
      modelica_metatype _solveCr = NULL;
      modelica_metatype _conditions = NULL;
      modelica_metatype _cr = NULL;
      modelica_string _str = NULL;
      modelica_boolean _initialCall;
      int tmp7;
      // _lhs has no default value.
      // _rhs has no default value.
      // _resolvedExp has no default value.
      // _varExp has no default value.
      // _source has no default value.
      // _eqAttr has no default value.
      // _whenEquation has no default value.
      // _cond has no default value.
      // _whenStmtLst has no default value.
      // _oelseWhen has no default value.
      // _eqs has no default value.
      // _tmpSimEqLst has no default value.
      // _newSimVar has no default value.
      // _solveEqns has no default value.
      // _asserts has no default value.
      // _solveCr has no default value.
      // _conditions has no default value.
      // _cr has no default value.
      // _str has no default value.
      // _initialCall has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp7_1))) {
        case 3: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,0,4) == 0) goto tmp6_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 5));
          _lhs = tmpMeta8;
          _rhs = tmpMeta9;
          _source = tmpMeta10;
          _eqAttr = tmpMeta11;
          /* Pattern matching succeeded */
          _cr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)));

          _varExp = omc_Expression_crefToExp(threadData, _cr);

          if(omc_BackendVariable_isStateVar(threadData, _var))
          {
            _varExp = omc_Expression_expDer(threadData, _varExp);

            _cr = omc_ComponentReference_crefPrefixDer(threadData, _cr);
          }

          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp14;
              int tmp15;
              tmp14 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp13_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp14 < 2; tmp14++) {
                switch (MMC_SWITCH_CAST(tmp14)) {
                case 0: {
                  modelica_metatype tmpMeta16;
                  modelica_integer tmp17;
                  modelica_metatype tmpMeta18;
                  modelica_metatype tmpMeta19;
                  modelica_metatype tmpMeta20;
                  modelica_metatype tmpMeta21;
                  modelica_metatype tmpMeta22;
                  modelica_metatype tmpMeta23;
                  modelica_metatype tmpMeta24;
                  /* Pattern matching succeeded */
                  _resolvedExp = omc_ExpressionSolve_solve2(threadData, _lhs, _rhs, _varExp, mmc_mk_some(_funcTree), mmc_mk_some(mmc_mk_integer(_uniqueEqIndex)), 1 /* true */, 1 /* true */ ,&_asserts ,&_solveEqns ,&_solveCr);

                  /* Pattern-matching tuple assignment */
                  tmpMeta18 = omc_List_mapFold(threadData, listReverse(_solveEqns), boxvar_SimCodeUtil_makeSolved, mmc_mk_integer(_uniqueEqIndex), &tmpMeta16);
                  _eqs = tmpMeta18;
                  tmp17 = mmc_unbox_integer(tmpMeta16);
                  _uniqueEqIndex = tmp17  /* pattern as ty=Integer */;

                  tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
                  _innerVars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, omc_List_map(threadData, listReverse(_solveCr), boxvar_Expression_crefExp), tmpMeta19);

                  _source = omc_ElementSource_addSymbolicTransformationSolve(threadData, 1 /* true */, _source, _cr, _lhs, _rhs, _resolvedExp, _asserts);

                  tmpMeta21 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex), _cr, _resolvedExp, _source, _eqAttr);
                  tmpMeta20 = mmc_mk_cons(tmpMeta21, MMC_REFSTRUCTLIT(mmc_nil));
                  _tmpSimEqLst = omc_SimCodeUtil_addAssertEqn(threadData, _asserts, tmpMeta20, ((modelica_integer) 1) + _uniqueEqIndex ,&_uniqueEqIndex);

                  _equations = listAppend(_eqs, _tmpSimEqLst);

                  _newSimVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _var, mmc_mk_none(), omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 0)), mmc_mk_none());

                  if(omc_BackendVariable_isStateVar(threadData, _var))
                  {
                    tmpMeta22 = mmc_mk_cons(omc_SimCodeUtil_derVarFromStateVar(threadData, _newSimVar, _timeInterval, mmc_mk_none()), _outputVars);
                    _outputVars = tmpMeta22;

                    tmpMeta23 = mmc_mk_cons(_newSimVar, _inputVars);
                    _inputVars = tmpMeta23;
                  }
                  else
                  {
                    tmpMeta24 = mmc_mk_cons(_newSimVar, _outputVars);
                    _outputVars = tmpMeta24;
                  }
                  goto tmp13_done;
                }
                case 1: {
                  modelica_metatype tmpMeta25;
                  modelica_metatype tmpMeta26;
                  modelica_metatype tmpMeta27;
                  modelica_metatype tmpMeta28;
                  /* Pattern matching succeeded */
                  tmpMeta25 = stringAppend(_OMC_LIT690,omc_BackendDump_equationString(threadData, _eqn));
                  tmpMeta26 = stringAppend(tmpMeta25,_OMC_LIT691);
                  tmpMeta27 = stringAppend(tmpMeta26,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
                  tmpMeta28 = stringAppend(tmpMeta27,_OMC_LIT692);
                  omc_Error_addInternalError(threadData, tmpMeta28, _OMC_LIT693);

                  goto goto_12;
                  goto tmp13_done;
                }
                }
                goto tmp13_end;
                tmp13_end: ;
              }
              goto goto_12;
              tmp13_done:
              (void)tmp14;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp13_done2;
              goto_12:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp14 < 2) {
                goto tmp13_top;
              }
              goto goto_5;
              tmp13_done2:;
            }
          }
          ;
          goto tmp6_done;
        }
        case 8: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,5,4) == 0) goto tmp6_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 4));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 5));
          _whenEquation = tmpMeta29;
          _source = tmpMeta30;
          _eqAttr = tmpMeta31;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta32 = _whenEquation;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 2));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 3));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 4));
          _cond = tmpMeta33;
          _whenStmtLst = tmpMeta34;
          _oelseWhen = tmpMeta35;

          if(isSome(_oelseWhen))
          {
            omc_Error_addInternalError(threadData, _OMC_LIT694, _OMC_LIT695);

            goto goto_5;
          }

          _conditions = omc_BackendDAEUtil_getConditionList(threadData, _cond ,&_initialCall);

          tmpMeta37 = mmc_mk_box8(18, &SimCode_SimEqSystem_SES__WHEN__desc, mmc_mk_integer(_uniqueEqIndex), _conditions, mmc_mk_boolean(_initialCall), _whenStmtLst, mmc_mk_none(), _source, _eqAttr);
          tmpMeta36 = mmc_mk_cons(tmpMeta37, MMC_REFSTRUCTLIT(mmc_nil));
          _tmpSimEqLst = tmpMeta36;

          _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;

          _newSimVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _var, mmc_mk_none(), omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 0)), mmc_mk_none());

          _equations = listAppend(_equations, _tmpSimEqLst);

          tmpMeta38 = mmc_mk_cons(_newSimVar, _outputVars);
          _outputVars = tmpMeta38;
          goto tmp6_done;
        }
        default:
        tmp6_default: OMC_LABEL_UNUSED; {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          
          /* Pattern matching succeeded */
          _str = omc_BackendDump_equationString(threadData, _eqn);

          tmpMeta39 = stringAppend(_OMC_LIT690,_str);
          tmpMeta40 = stringAppend(tmpMeta39,_OMC_LIT696);
          omc_Error_addInternalError(threadData, tmpMeta40, _OMC_LIT697);

          goto goto_5;
          goto tmp6_done;
        }
        }
        goto tmp6_end;
        tmp6_end: ;
      }
      goto goto_5;
      goto_5:;
      MMC_THROW_INTERNAL();
      goto tmp6_done;
      tmp6_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_inputVars) { *out_inputVars = _inputVars; }
  if (out_outputVars) { *out_outputVars = _outputVars; }
  if (out_innerVars) { *out_innerVars = _innerVars; }
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _equations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateSingleEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _var, modelica_metatype _funcTree, modelica_metatype _timeInterval, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_inputVars, modelica_metatype *out_outputVars, modelica_metatype *out_innerVars, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _equations = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _equations = omc_SimCodeUtil_generateSingleEquation(threadData, _eqn, _var, _funcTree, _timeInterval, tmp1, out_inputVars, out_outputVars, out_innerVars, &_uniqueEqIndex);
  /* skip box _equations; list<SimCode.SimEqSystem> */
  /* skip box _inputVars; list<SimCodeVar.SimVar> */
  /* skip box _outputVars; list<SimCodeVar.SimVar> */
  /* skip box _innerVars; list<SimCodeVar.SimVar> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _equations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateEquationsForComponents(threadData_t *threadData, modelica_metatype _components, modelica_metatype _constSyst, modelica_metatype _shared, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _omsiFuncEquations = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _equations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _inputVars = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _outputVars = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _innerVars = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype _hashTable = NULL;
  modelica_metatype _tmpEqns = NULL;
  modelica_metatype tmpMeta5;
  modelica_metatype _tmpInputVars = NULL;
  modelica_metatype tmpMeta6;
  modelica_metatype _tmpOutputVars = NULL;
  modelica_metatype tmpMeta7;
  modelica_metatype _tmpInnerVars = NULL;
  modelica_metatype tmpMeta8;
  modelica_metatype _tempVars = NULL;
  modelica_integer _nAlgebraicSystems;
  modelica_integer _index;
  modelica_integer _nAllVars;
  modelica_boolean _debug;
  modelica_metatype _clockIndex = NULL;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta81;
  modelica_metatype tmpMeta82;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _omsiFuncEquations has no default value.
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _equations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _inputVars = tmpMeta2;
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _outputVars = tmpMeta3;
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _innerVars = tmpMeta4;
  // _hashTable has no default value.
  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpEqns = tmpMeta5;
  tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpInputVars = tmpMeta6;
  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpOutputVars = tmpMeta7;
  tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
  _tmpInnerVars = tmpMeta8;
  // _tempVars has no default value.
  _nAlgebraicSystems = ((modelica_integer) 0);
  // _index has no default value.
  _nAllVars = ((modelica_integer) 0);
  _debug = 0 /* false */;
  // _clockIndex has no default value.
  _clockIndex = omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 9))));

  {
    modelica_metatype _component;
    for (tmpMeta9 = _components; !listEmpty(tmpMeta9); tmpMeta9=MMC_CDR(tmpMeta9))
    {
      _component = MMC_CAR(tmpMeta9);
      tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmpEqns = tmpMeta10;

      tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmpInputVars = tmpMeta11;

      tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmpOutputVars = tmpMeta12;

      tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmpInnerVars = tmpMeta13;

      { /* match expression */
        modelica_metatype tmp16_1;
        tmp16_1 = _component;
        {
          modelica_metatype _eqn = NULL;
          modelica_metatype _var = NULL;
          modelica_metatype _jacobian = NULL;
          modelica_metatype _innerEquations = NULL;
          modelica_metatype _tearingVars = NULL;
          modelica_metatype _residualEqns = NULL;
          modelica_metatype _tvars = NULL;
          modelica_metatype _varlst = NULL;
          modelica_metatype _loopIterationVars = NULL;
          modelica_metatype _loopSolvedVars = NULL;
          modelica_metatype _reqns = NULL;
          modelica_metatype _eqnlst = NULL;
          modelica_metatype _algSystem = NULL;
          modelica_metatype _resEqs = NULL;
          modelica_metatype _simequations = NULL;
          modelica_metatype _eqs = NULL;
          modelica_metatype _omsiFunction = NULL;
          modelica_boolean _linear;
          modelica_boolean _mixedSystem;
          modelica_metatype _derivativeMatrix = NULL;
          modelica_integer _algEqIndex;
          modelica_metatype _eqns = NULL;
          modelica_metatype _variables = NULL;
          volatile mmc_switch_type tmp16;
          int tmp17;
          // _eqn has no default value.
          // _var has no default value.
          // _jacobian has no default value.
          // _innerEquations has no default value.
          // _tearingVars has no default value.
          // _residualEqns has no default value.
          // _tvars has no default value.
          // _varlst has no default value.
          // _loopIterationVars has no default value.
          // _loopSolvedVars has no default value.
          // _reqns has no default value.
          // _eqnlst has no default value.
          // _algSystem has no default value.
          // _resEqs has no default value.
          // _simequations has no default value.
          // _eqs has no default value.
          // _omsiFunction has no default value.
          // _linear has no default value.
          // _mixedSystem has no default value.
          // _derivativeMatrix has no default value.
          // _algEqIndex has no default value.
          // _eqns has no default value.
          // _variables has no default value.
          tmp16 = 0;
          for (; tmp16 < 8; tmp16++) {
            switch (MMC_SWITCH_CAST(tmp16)) {
            case 0: {
              modelica_metatype tmpMeta18;
              modelica_metatype tmpMeta19;
              modelica_metatype tmpMeta20;
              modelica_metatype tmpMeta21;
              modelica_metatype tmpMeta22;
              modelica_metatype tmpMeta23;
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,0,2) == 0) goto tmp15_end;
              
              /* Pattern matching succeeded */
              /* Pattern-matching tuple assignment */
              tmpMeta21 = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _component, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))), &tmpMeta18, NULL);
              if (listEmpty(tmpMeta21)) goto goto_14;
              tmpMeta22 = MMC_CAR(tmpMeta21);
              tmpMeta23 = MMC_CDR(tmpMeta21);
              if (!listEmpty(tmpMeta23)) goto goto_14;
              _eqn = tmpMeta22;
              if (listEmpty(tmpMeta18)) goto goto_14;
              tmpMeta19 = MMC_CAR(tmpMeta18);
              tmpMeta20 = MMC_CDR(tmpMeta18);
              if (!listEmpty(tmpMeta20)) goto goto_14;
              _var = tmpMeta19;

              _tmpEqns = omc_SimCodeUtil_generateSingleEquation(threadData, _eqn, _var, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _uniqueEqIndex ,&_tmpInputVars ,&_tmpOutputVars ,&_tmpInnerVars ,&_uniqueEqIndex);
              goto tmp15_done;
            }
            case 1: {
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,5,2) == 0) goto tmp15_end;
              
              /* Pattern matching succeeded */
              _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _component, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))) ,&_varlst ,NULL);

              _tmpEqns = omc_SimCodeUtil_generateSingleEquation(threadData, listHead(_eqnlst), listHead(_varlst), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 21))), _uniqueEqIndex ,&_tmpInputVars ,&_tmpOutputVars ,&_tmpInnerVars ,&_uniqueEqIndex);
              goto tmp15_done;
            }
            case 2: {
              modelica_metatype tmpMeta24;
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,4,2) == 0) goto tmp15_end;
              
              /* Pattern matching succeeded */
              _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _component, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))) ,&_varlst ,NULL);

              _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

              tmpMeta24 = MMC_REFSTRUCTLIT(mmc_nil);
              _tmpEqns = omc_SimCodeUtil_createSingleComplexEqnCode(threadData, listHead(_eqnlst), _varlst, _uniqueEqIndex, tmpMeta24, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 17))), 1 /* true */, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), _clockIndex ,&_uniqueEqIndex ,NULL);
              goto tmp15_done;
            }
            case 3: {
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,3,2) == 0) goto tmp15_end;
              
              /* Pattern matching succeeded */
              _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _component, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))) ,&_varlst ,NULL);

              _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

              _tmpEqns = omc_SimCodeUtil_createSingleAlgorithmCode(threadData, _eqnlst, _varlst, 0 /* false */, _uniqueEqIndex, _clockIndex ,&_uniqueEqIndex);
              goto tmp15_done;
            }
            case 4: {
              modelica_metatype tmpMeta25;
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,2,2) == 0) goto tmp15_end;
              
              /* Pattern matching succeeded */
              _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _component, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))) ,&_varlst ,NULL);

              _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

              tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
              _tmpEqns = omc_SimCodeUtil_createSingleArrayEqnCode(threadData, 1 /* true */, _eqnlst, _varlst, _uniqueEqIndex, tmpMeta25, _shared ,NULL ,&_uniqueEqIndex ,NULL);
              goto tmp15_done;
            }
            case 5: {
              modelica_metatype tmpMeta26;
              modelica_metatype tmpMeta27;
              modelica_metatype tmpMeta28;
              modelica_metatype tmpMeta29;
              modelica_metatype tmpMeta30;
              modelica_metatype tmpMeta31;
              modelica_integer tmp32;
              modelica_metatype tmpMeta33;
              modelica_integer tmp34;
              modelica_metatype tmpMeta35;
              modelica_metatype tmpMeta36;
              modelica_metatype tmpMeta37;
              modelica_metatype tmpMeta38;
              modelica_metatype tmpMeta39;
              modelica_metatype tmpMeta40;
              modelica_metatype tmpMeta41;
              modelica_integer tmp42;
              modelica_metatype tmpMeta43;
              modelica_metatype tmpMeta44;
              modelica_metatype tmpMeta45;
              modelica_metatype tmpMeta46;
              modelica_metatype tmpMeta47;
              modelica_metatype tmpMeta48;
              modelica_metatype tmpMeta49;
              modelica_metatype tmpMeta50;
              modelica_metatype tmpMeta51;
              modelica_metatype tmpMeta52;
              modelica_metatype tmpMeta53;
              modelica_metatype tmpMeta54;
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,7,4) == 0) goto tmp15_end;
              tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 2));
              tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
              tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 3));
              tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 4));
              tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 5));
              tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 4));
              tmp32 = mmc_unbox_integer(tmpMeta31);
              tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 5));
              tmp34 = mmc_unbox_integer(tmpMeta33);
              _tearingVars = tmpMeta27;
              _residualEqns = tmpMeta28;
              _innerEquations = tmpMeta29;
              _jacobian = tmpMeta30;
              _linear = tmp32  /* pattern as ty=Boolean */;
              _mixedSystem = tmp34  /* pattern as ty=Boolean */;
              /* Pattern matching succeeded */
              if(((!omc_SymbolicJacobian_isJacobianGeneric(threadData, _jacobian)) && _linear))
              {
                tmpMeta35 = MMC_REFSTRUCTLIT(mmc_nil);
                omc_Error_addMessage(threadData, _OMC_LIT699, tmpMeta35);

                goto goto_14;
              }

              _algEqIndex = _uniqueEqIndex;

              _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;

              _tvars = omc_List_map1r(threadData, _tearingVars, boxvar_BackendVariable_getVarAt, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))));

              _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

              _tvars = omc_BackendVariable_setVarsKind(threadData, _tvars, _OMC_LIT700);

              /* Pattern-matching assignment */
              tmpMeta36 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta37 = mmc_mk_box2(0, tmpMeta36, omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 0)));
              tmpMeta38 = omc_List_fold(threadData, _tvars, boxvar_SimCodeUtil_traversingdlowvarToSimvarFold, tmpMeta37);
              tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 1));
              _loopIterationVars = tmpMeta39;

              _loopIterationVars = listReverse(_loopIterationVars);

              _simequations = omc_SimCodeUtil_generateInnerEqns(threadData, _innerEquations, _constSyst, _shared, _uniqueEqIndex ,&_loopSolvedVars ,&_uniqueEqIndex);

              _reqns = omc_BackendEquation_getList(threadData, _residualEqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))));

              _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

              /* Pattern-matching tuple assignment */
              tmpMeta44 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
              tmpMeta45 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta46 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta44, tmpMeta45, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), &tmpMeta40, &tmpMeta43);
              _resEqs = tmpMeta46;
              tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 1));
              tmp42 = mmc_unbox_integer(tmpMeta41);
              _uniqueEqIndex = tmp42  /* pattern as ty=Integer */;
              _tempVars = tmpMeta43;

              _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

              _eqs = listAppend(_simequations, _resEqs);

              _loopIterationVars = omc_SimCodeUtil_rewriteIndex(threadData, _loopIterationVars, ((modelica_integer) 0) ,&_index);

              _loopSolvedVars = omc_SimCodeUtil_rewriteIndex(threadData, _loopSolvedVars, _index ,&_index);

              _nAllVars = listLength(_loopIterationVars) + listLength(_loopSolvedVars) + listLength(_tempVars);

              tmpMeta47 = mmc_mk_cons(_loopIterationVars, mmc_mk_cons(_loopSolvedVars, mmc_mk_cons(_tempVars, MMC_REFSTRUCTLIT(mmc_nil))));
              _hashTable = omc_SimCodeUtil_fillLocalHashTable(threadData, tmpMeta47, _nAllVars);

              if(_debug)
              {
                fputs(MMC_STRINGDATA(_OMC_LIT701),stdout);

                omc_SimCodeUtil_dumpVarLst(threadData, _loopIterationVars, _OMC_LIT702);

                omc_SimCodeUtil_dumpVarLst(threadData, _loopSolvedVars, _OMC_LIT703);
              }

              _tmpOutputVars = listAppend(_loopIterationVars, _loopSolvedVars);

              tmpMeta48 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta49 = mmc_mk_box2(12, &SimCodeFunction_Context_OMSI__CONTEXT__desc, mmc_mk_some(_hashTable));
              tmpMeta50 = mmc_mk_box8(3, &SimCode_OMSIFunction_OMSI__FUNCTION__desc, _eqs, tmpMeta48, _tmpOutputVars, _tempVars, mmc_mk_integer(_nAllVars), tmpMeta49, mmc_mk_integer(((modelica_integer) 0)));
              _omsiFunction = tmpMeta50;

              _derivativeMatrix = omc_SimCodeUtil_createDerivativeMatrix(threadData, _jacobian, _uniqueEqIndex ,&_uniqueEqIndex);

              tmpMeta51 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta52 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta53 = mmc_mk_box12(22, &SimCode_SimEqSystem_SES__ALGEBRAIC__SYSTEM__desc, mmc_mk_integer(_algEqIndex), mmc_mk_integer(_nAlgebraicSystems), mmc_mk_integer(listLength(_tvars)), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(1 /* true */), mmc_mk_boolean(_linear), _omsiFunction, _derivativeMatrix, tmpMeta51, tmpMeta52, _OMC_LIT535);
              _algSystem = tmpMeta53;

              _nAlgebraicSystems = ((modelica_integer) 1) + _nAlgebraicSystems;

              tmpMeta54 = mmc_mk_cons(_algSystem, MMC_REFSTRUCTLIT(mmc_nil));
              _tmpEqns = tmpMeta54;
              goto tmp15_done;
            }
            case 6: {
              modelica_metatype tmpMeta55;
              modelica_metatype tmpMeta56;
              modelica_metatype tmpMeta57;
              modelica_metatype tmpMeta58;
              modelica_integer tmp59;
              modelica_metatype tmpMeta60;
              modelica_metatype tmpMeta61;
              modelica_metatype tmpMeta62;
              modelica_metatype tmpMeta63;
              modelica_metatype tmpMeta64;
              modelica_metatype tmpMeta65;
              modelica_integer tmp66;
              modelica_metatype tmpMeta67;
              modelica_metatype tmpMeta68;
              modelica_metatype tmpMeta69;
              modelica_metatype tmpMeta70;
              modelica_metatype tmpMeta71;
              modelica_metatype tmpMeta72;
              modelica_metatype tmpMeta73;
              modelica_metatype tmpMeta74;
              modelica_metatype tmpMeta75;
              modelica_metatype tmpMeta76;
              modelica_metatype tmpMeta77;
              modelica_metatype tmpMeta78;
              if (mmc__uniontype__metarecord__typedef__equal(tmp16_1,1,5) == 0) goto tmp15_end;
              tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 2));
              tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 3));
              tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 4));
              tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp16_1), 6));
              tmp59 = mmc_unbox_integer(tmpMeta58);
              _eqns = tmpMeta55;
              _variables = tmpMeta56;
              _jacobian = tmpMeta57;
              _mixedSystem = tmp59  /* pattern as ty=Boolean */;
              /* Pattern matching succeeded */
              _algEqIndex = _uniqueEqIndex;

              _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;

              _tvars = omc_List_map1r(threadData, _variables, boxvar_BackendVariable_getVarAt, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 2))));

              _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

              /* Pattern-matching assignment */
              tmpMeta60 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta61 = mmc_mk_box2(0, tmpMeta60, omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 0)));
              tmpMeta62 = omc_List_fold(threadData, _tvars, boxvar_SimCodeUtil_traversingdlowvarToSimvarFold, tmpMeta61);
              tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 1));
              _loopSolvedVars = tmpMeta63;

              _loopSolvedVars = listReverse(_loopSolvedVars);

              _reqns = omc_BackendEquation_getList(threadData, _eqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 3))));

              _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

              /* Pattern-matching tuple assignment */
              tmpMeta68 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
              tmpMeta69 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta70 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta68, tmpMeta69, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), &tmpMeta64, &tmpMeta67);
              _resEqs = tmpMeta70;
              tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 1));
              tmp66 = mmc_unbox_integer(tmpMeta65);
              _uniqueEqIndex = tmp66  /* pattern as ty=Integer */;
              _tempVars = tmpMeta67;

              _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

              _loopSolvedVars = omc_SimCodeUtil_rewriteIndex(threadData, _loopSolvedVars, ((modelica_integer) 0) ,&_index);

              _nAllVars = listLength(_loopSolvedVars) + listLength(_tempVars);

              tmpMeta71 = mmc_mk_cons(_loopSolvedVars, mmc_mk_cons(_tempVars, MMC_REFSTRUCTLIT(mmc_nil)));
              _hashTable = omc_SimCodeUtil_fillLocalHashTable(threadData, tmpMeta71, _nAllVars);

              tmpMeta72 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta73 = mmc_mk_box2(12, &SimCodeFunction_Context_OMSI__CONTEXT__desc, mmc_mk_some(_hashTable));
              tmpMeta74 = mmc_mk_box8(3, &SimCode_OMSIFunction_OMSI__FUNCTION__desc, _resEqs, tmpMeta72, _loopSolvedVars, _tempVars, mmc_mk_integer(_nAllVars), tmpMeta73, mmc_mk_integer(((modelica_integer) 0)));
              _omsiFunction = tmpMeta74;

              _derivativeMatrix = omc_SimCodeUtil_createDerivativeMatrix(threadData, _jacobian, _uniqueEqIndex ,&_uniqueEqIndex);

              tmpMeta75 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta76 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta77 = mmc_mk_box12(22, &SimCode_SimEqSystem_SES__ALGEBRAIC__SYSTEM__desc, mmc_mk_integer(_algEqIndex), mmc_mk_integer(_nAlgebraicSystems), mmc_mk_integer(listLength(_tvars)), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), _omsiFunction, _derivativeMatrix, tmpMeta75, tmpMeta76, _OMC_LIT535);
              _algSystem = tmpMeta77;

              _nAlgebraicSystems = ((modelica_integer) 1) + _nAlgebraicSystems;

              tmpMeta78 = mmc_mk_cons(_algSystem, MMC_REFSTRUCTLIT(mmc_nil));
              _tmpEqns = tmpMeta78;

              if(_debug)
              {
                omc_SimCodeUtil_dumpOMSIFunc(threadData, _omsiFunction, _OMC_LIT704);
              }
              goto tmp15_done;
            }
            case 7: {
              modelica_metatype tmpMeta79;
              modelica_metatype tmpMeta80;
              
              /* Pattern matching succeeded */
              tmpMeta79 = stringAppend(_OMC_LIT705,omc_BackendDump_printComponent(threadData, _component, mmc_mk_none()));
              tmpMeta80 = stringAppend(tmpMeta79,_OMC_LIT706);
              omc_Error_addInternalError(threadData, tmpMeta80, _OMC_LIT707);

              goto goto_14;
              goto tmp15_done;
            }
            }
            goto tmp15_end;
            tmp15_end: ;
          }
          goto goto_14;
          goto_14:;
          MMC_THROW_INTERNAL();
          goto tmp15_done;
          tmp15_done:;
        }
      }
      ;

      _equations = listAppend(_tmpEqns, _equations);

      _inputVars = listAppend(_tmpInputVars, _inputVars);

      _outputVars = listAppend(_tmpOutputVars, _outputVars);

      _innerVars = listAppend(_tmpInnerVars, _innerVars);
    }
  }

  _inputVars = omc_SimCodeUtil_rewriteIndex(threadData, _inputVars, ((modelica_integer) 0) ,&_index);

  _innerVars = omc_SimCodeUtil_rewriteIndex(threadData, _innerVars, _index ,&_index);

  _outputVars = omc_SimCodeUtil_rewriteIndex(threadData, _outputVars, _index ,&_index);

  tmpMeta82 = mmc_mk_box8(3, &SimCode_OMSIFunction_OMSI__FUNCTION__desc, listReverse(_equations), _inputVars, _outputVars, _innerVars, mmc_mk_integer(_nAllVars), _OMC_LIT708, mmc_mk_integer(_nAlgebraicSystems));
  _omsiFuncEquations = tmpMeta82;

  if(_debug)
  {
    fputs(MMC_STRINGDATA(_OMC_LIT701),stdout);

    omc_SimCodeUtil_dumpVarLst(threadData, _inputVars, _OMC_LIT709);

    omc_SimCodeUtil_dumpVarLst(threadData, _innerVars, _OMC_LIT710);

    omc_SimCodeUtil_dumpVarLst(threadData, _outputVars, _OMC_LIT711);
  }
  _return: OMC_LABEL_UNUSED
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _omsiFuncEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateEquationsForComponents(threadData_t *threadData, modelica_metatype _components, modelica_metatype _constSyst, modelica_metatype _shared, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _omsiFuncEquations = NULL;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _omsiFuncEquations = omc_SimCodeUtil_generateEquationsForComponents(threadData, _components, _constSyst, _shared, tmp1, &_uniqueEqIndex);
  /* skip box _omsiFuncEquations; SimCode.OMSIFunction */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _omsiFuncEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createAllEquationOMSI(threadData_t *threadData, modelica_metatype _constSysts, modelica_metatype _shared, modelica_metatype _inZeroCrossings, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _omsiAllEquations = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _components = NULL;
  modelica_metatype _newAllEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _omsiAllEquations = _OMC_LIT712;
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  // _components has no default value.
  // _newAllEquations has no default value.
  tmpMeta2 = mmc_mk_box2(12, &SimCodeFunction_Context_OMSI__CONTEXT__desc, mmc_mk_some(omc_HashTableCrefSimVar_emptyHashTableSized(threadData, ((modelica_integer) 1013))));
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(9));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_omsiAllEquations), 9*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[7] = tmpMeta2;
  _omsiAllEquations = tmpMeta1;

  {
    modelica_metatype _constSyst;
    for (tmpMeta3 = _constSysts; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _constSyst = MMC_CAR(tmpMeta3);
      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp6;
          int tmp7;
          tmp6 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp5_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp6 < 2; tmp6++) {
            switch (MMC_SWITCH_CAST(tmp6)) {
            case 0: {
              modelica_metatype tmpMeta8;
              modelica_metatype tmpMeta9;
              /* Pattern matching succeeded */
              /* Pattern-matching assignment */
              tmpMeta8 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_constSyst), 7)));
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,1,3) == 0) goto goto_4;
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
              _components = tmpMeta9;
              goto tmp5_done;
            }
            case 1: {
              /* Pattern matching succeeded */
              omc_Error_addInternalError(threadData, _OMC_LIT713, _OMC_LIT714);

              goto goto_4;
              goto tmp5_done;
            }
            }
            goto tmp5_end;
            tmp5_end: ;
          }
          goto goto_4;
          tmp5_done:
          (void)tmp6;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp5_done2;
          goto_4:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp6 < 2) {
            goto tmp5_top;
          }
          MMC_THROW_INTERNAL();
          tmp5_done2:;
        }
      }
      ;

      _newAllEquations = omc_SimCodeUtil_generateEquationsForComponents(threadData, _components, _constSyst, _shared, _uniqueEqIndex ,&_uniqueEqIndex);

      _omsiAllEquations = omc_SimCodeUtil_appendOMSIFunction(threadData, _omsiAllEquations, _newAllEquations);
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _omsiAllEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createAllEquationOMSI(threadData_t *threadData, modelica_metatype _constSysts, modelica_metatype _shared, modelica_metatype _inZeroCrossings, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _omsiAllEquations = NULL;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _omsiAllEquations = omc_SimCodeUtil_createAllEquationOMSI(threadData, _constSysts, _shared, _inZeroCrossings, tmp1, &_uniqueEqIndex);
  /* skip box _omsiAllEquations; SimCode.OMSIFunction */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _omsiAllEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystemInnerEqns1(threadData_t *threadData, modelica_metatype _eqn, modelica_integer _eqnindx, modelica_metatype _varindx)
{
  modelica_metatype _ocomp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ocomp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _eqn;
    tmp4_2 = _varindx;
    {
      modelica_integer _v;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      tmp4 = 0;
      for (; tmp4 < 9; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_2);
          tmpMeta7 = MMC_CDR(tmp4_2);
          tmp8 = mmc_unbox_integer(tmpMeta6);
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          _v = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta9 = mmc_mk_box3(3, &BackendDAE_StrongComponent_SINGLEEQUATION__desc, mmc_mk_integer(_eqnindx), mmc_mk_integer(_v));
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_2);
          tmpMeta11 = MMC_CDR(tmp4_2);
          tmp12 = mmc_unbox_integer(tmpMeta10);
          if (!listEmpty(tmpMeta11)) goto tmp3_end;
          _v = tmp12  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_box3(3, &BackendDAE_StrongComponent_SINGLEEQUATION__desc, mmc_mk_integer(_eqnindx), mmc_mk_integer(_v));
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta14 = MMC_CAR(tmp4_2);
          tmpMeta15 = MMC_CDR(tmp4_2);
          tmp16 = mmc_unbox_integer(tmpMeta14);
          if (!listEmpty(tmpMeta15)) goto tmp3_end;
          _v = tmp16  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta17 = mmc_mk_box3(3, &BackendDAE_StrongComponent_SINGLEEQUATION__desc, mmc_mk_integer(_eqnindx), mmc_mk_integer(_v));
          tmpMeta1 = tmpMeta17;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta18 = mmc_mk_box3(5, &BackendDAE_StrongComponent_SINGLEARRAY__desc, mmc_mk_integer(_eqnindx), _varindx);
          tmpMeta1 = tmpMeta18;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta19 = mmc_mk_box3(9, &BackendDAE_StrongComponent_SINGLEIFEQUATION__desc, mmc_mk_integer(_eqnindx), _varindx);
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta20 = mmc_mk_box3(6, &BackendDAE_StrongComponent_SINGLEALGORITHM__desc, mmc_mk_integer(_eqnindx), _varindx);
          tmpMeta1 = tmpMeta20;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta21 = mmc_mk_box3(7, &BackendDAE_StrongComponent_SINGLECOMPLEXEQUATION__desc, mmc_mk_integer(_eqnindx), _varindx);
          tmpMeta1 = tmpMeta21;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta22 = mmc_mk_box3(8, &BackendDAE_StrongComponent_SINGLEWHENEQUATION__desc, mmc_mk_integer(_eqnindx), _varindx);
          tmpMeta1 = tmpMeta22;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT715),stdout);

          tmpMeta23 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          omc_BackendDump_printEquationList(threadData, tmpMeta23);

          tmpMeta24 = stringAppend(_OMC_LIT716,intString(_eqnindx));
          tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT717);
          tmpMeta26 = stringAppend(tmpMeta25,stringDelimitList(omc_List_map(threadData, _varindx, boxvar_intString), _OMC_LIT243));
          tmpMeta27 = stringAppend(tmpMeta26,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta27),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _ocomp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _ocomp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystemInnerEqns1(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _eqnindx, modelica_metatype _varindx)
{
  modelica_integer tmp1;
  modelica_metatype _ocomp = NULL;
  tmp1 = mmc_unbox_integer(_eqnindx);
  _ocomp = omc_SimCodeUtil_createTornSystemInnerEqns1(threadData, _eqn, tmp1, _varindx);
  /* skip box _ocomp; BackendDAE.StrongComponent */
  return _ocomp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystemInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_boolean _skipDiscInAlgorithm, modelica_boolean _genDiscrete, modelica_metatype _isyst, modelica_metatype _ishared, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isimequations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_integer *out_nVars, modelica_boolean *out_homotopySupport)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer _nVars;
  modelica_boolean _homotopySupport;
  modelica_metatype _eqns = NULL;
  modelica_integer _eqnindx;
  modelica_metatype _vars = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _comp = NULL;
  modelica_metatype _simequations = NULL;
  modelica_metatype _equations = NULL;
  modelica_metatype _cons = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  _ouniqueEqIndex = _iuniqueEqIndex;
  _otempvars = _itempvars;
  _nVars = ((modelica_integer) 0);
  _homotopySupport = 0 /* false */;
  // _eqns has no default value.
  // _eqnindx has no default value.
  // _vars has no default value.
  // _eqn has no default value.
  // _comp has no default value.
  // _simequations has no default value.
  // _equations has no default value.
  // _cons has no default value.
  if(listEmpty(_innerEquations))
  {
    _equations_ = _isimequations;

    goto _return;
  }

  /* Pattern-matching assignment */
  tmpMeta1 = _isyst;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  _eqns = tmpMeta2;

  _equations = omc_DoubleEnded_fromList(threadData, _isimequations);

  {
    modelica_metatype _eq;
    for (tmpMeta3 = _innerEquations; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _eq = MMC_CAR(tmpMeta3);
      _eqnindx = omc_BackendDAEUtil_getEqnAndVarsFromInnerEquation(threadData, _eq ,&_vars ,&_cons);

      _nVars = _nVars + listLength(_vars);

      _eqn = omc_BackendEquation_get(threadData, _eqns, _eqnindx);

      if((!_homotopySupport))
      {
        /* Pattern-matching tuple assignment, wild first pattern */
        omc_BackendEquation_traverseExpsOfEquation(threadData, _eqn, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta4);
        tmp5 = mmc_unbox_integer(tmpMeta4);
        _homotopySupport = tmp5  /* pattern as ty=Boolean */;
      }

      _comp = omc_SimCodeUtil_createTornSystemInnerEqns1(threadData, _eqn, _eqnindx, _vars);

      _simequations = omc_SimCodeUtil_createEquationsWork(threadData, _genDiscrete, 0 /* false */, _genDiscrete, _skipDiscInAlgorithm, _isyst, _ishared, _comp, _ouniqueEqIndex, _otempvars, _cons ,NULL ,&_ouniqueEqIndex ,&_otempvars);

      omc_DoubleEnded_push__list__back(threadData, _equations, _simequations);
    }
  }

  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _equations_ = omc_DoubleEnded_toListAndClear(threadData, _equations, tmpMeta7);
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_nVars) { *out_nVars = _nVars; }
  if (out_homotopySupport) { *out_homotopySupport = _homotopySupport; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystemInnerEqns(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _genDiscrete, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isimequations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_nVars, modelica_metatype *out_homotopySupport)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer _ouniqueEqIndex;
  modelica_integer _nVars;
  modelica_boolean _homotopySupport;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp2 = mmc_unbox_integer(_genDiscrete);
  tmp3 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createTornSystemInnerEqns(threadData, _innerEquations, tmp1, tmp2, _isyst, _ishared, tmp3, _itempvars, _isimequations, &_ouniqueEqIndex, out_otempvars, &_nVars, &_homotopySupport);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  if (out_nVars) { *out_nVars = mmc_mk_icon(_nVars); }
  if (out_homotopySupport) { *out_homotopySupport = mmc_mk_icon(_homotopySupport); }
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveInnerEquations1(threadData_t *threadData, modelica_metatype _iExps1, modelica_metatype _iExps2, modelica_metatype _iVars, modelica_metatype _inVars, modelica_metatype _ishared, modelica_metatype _inRepl)
{
  modelica_metatype _outRepl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outRepl has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _iExps1;
    tmp4_2 = _iExps2;
    tmp4_3 = _iVars;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _varexp = NULL;
      modelica_metatype _expr = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _dcr = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _explst1 = NULL;
      modelica_metatype _explst2 = NULL;
      modelica_metatype _funcs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _varexp has no default value.
      // _expr has no default value.
      // _cr has no default value.
      // _dcr has no default value.
      // _repl has no default value.
      // _var has no default value.
      // _rest has no default value.
      // _explst1 has no default value.
      // _explst2 has no default value.
      // _funcs has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inRepl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmp4_2);
          tmpMeta9 = MMC_CDR(tmp4_2);
          if (listEmpty(tmp4_3)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_3);
          tmpMeta11 = MMC_CDR(tmp4_3);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _e1 = tmpMeta6;
          _explst1 = tmpMeta7;
          _e2 = tmpMeta8;
          _explst2 = tmpMeta9;
          _var = tmpMeta10;
          _cr = tmpMeta12;
          _rest = tmpMeta11;
          /* Pattern matching succeeded */
          _varexp = omc_Expression_crefExp(threadData, _cr);

          _varexp = (omc_BackendVariable_isStateVar(threadData, _var)?omc_Expression_expDer(threadData, _varexp):_varexp);

          /* Pattern-matching assignment */
          tmpMeta13 = _ishared;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 12));
          _funcs = tmpMeta14;

          /* Pattern-matching tuple assignment */
          tmpMeta18 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _varexp, mmc_mk_some(_funcs), mmc_mk_none(), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _ishared), &tmpMeta15, &tmpMeta16, &tmpMeta17);
          _expr = tmpMeta18;
          if (!listEmpty(tmpMeta15)) goto goto_2;
          if (!listEmpty(tmpMeta16)) goto goto_2;
          if (!listEmpty(tmpMeta17)) goto goto_2;

          _dcr = (omc_BackendVariable_isStateVar(threadData, _var)?omc_ComponentReference_crefPrefixDer(threadData, _cr):_cr);

          _repl = omc_BackendVarTransform_addReplacement(threadData, _inRepl, _dcr, _expr, mmc_mk_some(boxvar_BackendVarTransform_skipPreOperator));

          _repl = (omc_BackendVariable_isStateVar(threadData, _var)?omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _expr, _repl):_repl);
          /* Tail recursive call */
          _iExps1 = _explst1;
          _iExps2 = _explst2;
          _iVars = _rest;
          _inRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outRepl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outRepl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveInnerEquations(threadData_t *threadData, modelica_metatype _innerEquations, modelica_metatype _inEqns, modelica_metatype _inVars, modelica_metatype _ishared, modelica_metatype _inRepl)
{
  modelica_metatype _outRepl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outRepl has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _innerEquations;
    {
      modelica_metatype _rest = NULL;
      modelica_integer _v;
      modelica_integer _e;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _varexp = NULL;
      modelica_metatype _expr = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _dcr = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _varlst = NULL;
      modelica_metatype _ds = NULL;
      modelica_metatype _vlst = NULL;
      modelica_metatype _explst1 = NULL;
      modelica_metatype _explst2 = NULL;
      modelica_metatype _subslst = NULL;
      modelica_metatype _funcs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _v has no default value.
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _varexp has no default value.
      // _expr has no default value.
      // _cr has no default value.
      // _dcr has no default value.
      // _repl has no default value.
      // _var has no default value.
      // _varlst has no default value.
      // _ds has no default value.
      // _vlst has no default value.
      // _explst1 has no default value.
      // _explst2 has no default value.
      // _subslst has no default value.
      // _funcs has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inRepl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          if (listEmpty(tmpMeta10)) goto tmp3_end;
          tmpMeta11 = MMC_CAR(tmpMeta10);
          tmpMeta12 = MMC_CDR(tmpMeta10);
          tmp13 = mmc_unbox_integer(tmpMeta11);
          if (!listEmpty(tmpMeta12)) goto tmp3_end;
          _e = tmp9  /* pattern as ty=Integer */;
          _v = tmp13  /* pattern as ty=Integer */;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta14 = omc_BackendEquation_get(threadData, _inEqns, _e);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,0,4) == 0) goto goto_2;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          _e1 = tmpMeta15;
          _e2 = tmpMeta16;

          /* Pattern-matching assignment */
          tmpMeta17 = omc_BackendVariable_getVarAt(threadData, _inVars, _v);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          _var = tmpMeta17;
          _cr = tmpMeta18;

          _varexp = omc_Expression_crefExp(threadData, _cr);

          _varexp = (omc_BackendVariable_isStateVar(threadData, _var)?omc_Expression_expDer(threadData, _varexp):_varexp);

          /* Pattern-matching assignment */
          tmpMeta19 = _ishared;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 12));
          _funcs = tmpMeta20;

          /* Pattern-matching tuple assignment */
          tmpMeta24 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _varexp, mmc_mk_some(_funcs), mmc_mk_none(), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _ishared), &tmpMeta21, &tmpMeta22, &tmpMeta23);
          _expr = tmpMeta24;
          if (!listEmpty(tmpMeta21)) goto goto_2;
          if (!listEmpty(tmpMeta22)) goto goto_2;
          if (!listEmpty(tmpMeta23)) goto goto_2;

          _dcr = (omc_BackendVariable_isStateVar(threadData, _var)?omc_ComponentReference_crefPrefixDer(threadData, _cr):_cr);

          _repl = omc_BackendVarTransform_addReplacement(threadData, _inRepl, _dcr, _expr, mmc_mk_some(boxvar_BackendVarTransform_skipPreOperator));

          _repl = (omc_BackendVariable_isStateVar(threadData, _var)?omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _expr, _repl):_repl);
          /* Tail recursive call */
          _innerEquations = _rest;
          _inRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_integer tmp28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta25 = MMC_CAR(tmp4_1);
          tmpMeta26 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,0,2) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          tmp28 = mmc_unbox_integer(tmpMeta27);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 3));
          _e = tmp28  /* pattern as ty=Integer */;
          _vlst = tmpMeta29;
          _rest = tmpMeta26;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta30 = omc_BackendEquation_get(threadData, _inEqns, _e);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,1,6) == 0) goto goto_2;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 3));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 4));
          _ds = tmpMeta31;
          _e1 = tmpMeta32;
          _e2 = tmpMeta33;

          _varlst = omc_List_map1r(threadData, _vlst, boxvar_BackendVariable_getVarAt, _inVars);

          _subslst = omc_Expression_dimensionSizesSubscripts(threadData, _ds);

          _subslst = omc_Expression_rangesToSubscripts(threadData, _subslst);

          _explst1 = omc_List_map1r(threadData, _subslst, boxvar_Expression_applyExpSubscripts, _e1);

          _explst1 = omc_ExpressionSimplify_simplifyList(threadData, _explst1);

          _explst2 = omc_List_map1r(threadData, _subslst, boxvar_Expression_applyExpSubscripts, _e2);

          _explst2 = omc_ExpressionSimplify_simplifyList(threadData, _explst2);

          _repl = omc_SimCodeUtil_solveInnerEquations1(threadData, _explst1, _explst2, _varlst, _inVars, _ishared, _inRepl);
          /* Tail recursive call */
          _innerEquations = _rest;
          _inRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_integer tmp41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta34 = MMC_CAR(tmp4_1);
          tmpMeta35 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,1,3) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 2));
          tmp37 = mmc_unbox_integer(tmpMeta36);
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 3));
          if (listEmpty(tmpMeta38)) goto tmp3_end;
          tmpMeta39 = MMC_CAR(tmpMeta38);
          tmpMeta40 = MMC_CDR(tmpMeta38);
          tmp41 = mmc_unbox_integer(tmpMeta39);
          if (!listEmpty(tmpMeta40)) goto tmp3_end;
          
          _e = tmp37  /* pattern as ty=Integer */;
          _v = tmp41  /* pattern as ty=Integer */;
          _rest = tmpMeta35;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta42 = omc_BackendEquation_get(threadData, _inEqns, _e);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta42,0,4) == 0) goto goto_2;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 3));
          _e1 = tmpMeta43;
          _e2 = tmpMeta44;

          /* Pattern-matching assignment */
          tmpMeta45 = omc_BackendVariable_getVarAt(threadData, _inVars, _v);
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 2));
          _var = tmpMeta45;
          _cr = tmpMeta46;

          _varexp = omc_Expression_crefExp(threadData, _cr);

          _varexp = (omc_BackendVariable_isStateVar(threadData, _var)?omc_Expression_expDer(threadData, _varexp):_varexp);

          /* Pattern-matching assignment */
          tmpMeta47 = _ishared;
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta47), 12));
          _funcs = tmpMeta48;

          /* Pattern-matching tuple assignment */
          tmpMeta52 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _varexp, mmc_mk_some(_funcs), mmc_mk_none(), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _ishared), &tmpMeta49, &tmpMeta50, &tmpMeta51);
          _expr = tmpMeta52;
          if (!listEmpty(tmpMeta49)) goto goto_2;
          if (!listEmpty(tmpMeta50)) goto goto_2;
          if (!listEmpty(tmpMeta51)) goto goto_2;

          _dcr = (omc_BackendVariable_isStateVar(threadData, _var)?omc_ComponentReference_crefPrefixDer(threadData, _cr):_cr);

          _repl = omc_BackendVarTransform_addReplacement(threadData, _inRepl, _dcr, _expr, mmc_mk_some(boxvar_BackendVarTransform_skipPreOperator));

          _repl = (omc_BackendVariable_isStateVar(threadData, _var)?omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _expr, _repl):_repl);
          /* Tail recursive call */
          _innerEquations = _rest;
          _inRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_integer tmp56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta53 = MMC_CAR(tmp4_1);
          tmpMeta54 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta53,1,3) == 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta53), 2));
          tmp56 = mmc_unbox_integer(tmpMeta55);
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta53), 3));
          
          _e = tmp56  /* pattern as ty=Integer */;
          _vlst = tmpMeta57;
          _rest = tmpMeta54;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta58 = omc_BackendEquation_get(threadData, _inEqns, _e);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,1,6) == 0) goto goto_2;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 3));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 4));
          _ds = tmpMeta59;
          _e1 = tmpMeta60;
          _e2 = tmpMeta61;

          _varlst = omc_List_map1r(threadData, _vlst, boxvar_BackendVariable_getVarAt, _inVars);

          _subslst = omc_Expression_dimensionSizesSubscripts(threadData, _ds);

          _subslst = omc_Expression_rangesToSubscripts(threadData, _subslst);

          _explst1 = omc_List_map1r(threadData, _subslst, boxvar_Expression_applyExpSubscripts, _e1);

          _explst1 = omc_ExpressionSimplify_simplifyList(threadData, _explst1);

          _explst2 = omc_List_map1r(threadData, _subslst, boxvar_Expression_applyExpSubscripts, _e2);

          _explst2 = omc_ExpressionSimplify_simplifyList(threadData, _explst2);

          _repl = omc_SimCodeUtil_solveInnerEquations1(threadData, _explst1, _explst2, _varlst, _inVars, _ishared, _inRepl);
          /* Tail recursive call */
          _innerEquations = _rest;
          _inRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outRepl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outRepl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTornSystem(threadData_t *threadData, modelica_boolean _linear, modelica_boolean _skipDiscInAlgorithm, modelica_boolean _genDiscrete, modelica_metatype _strictTearingSet, modelica_metatype _casualTearingSet, modelica_metatype _isyst, modelica_metatype _ishared, modelica_integer _iuniqueEqIndex, modelica_boolean _mixedSystem, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _linear;
    tmp4_2 = _isyst;
    tmp4_3 = _ishared;
    {
      modelica_metatype _tvars = NULL;
      modelica_metatype _reqns = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _tempvars2 = NULL;
      modelica_metatype _simVars = NULL;
      modelica_metatype _simequations = NULL;
      modelica_metatype _resEqs = NULL;
      modelica_metatype _eqs = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_integer _nInnerVars;
      modelica_metatype _tcrs = NULL;
      modelica_metatype _jacobianMatrix = NULL;
      modelica_metatype _tearingVars = NULL;
      modelica_metatype _residualEqns = NULL;
      modelica_boolean _homotopySupport;
      modelica_metatype _innerEquations = NULL;
      modelica_metatype _inJacobian = NULL;
      modelica_metatype _lSystem = NULL;
      modelica_metatype _nlSystem = NULL;
      modelica_metatype _alternativeTearingL = NULL;
      modelica_metatype _alternativeTearingNl = NULL;
      modelica_boolean _partOfJac;
      modelica_metatype _clockIndex = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _tvars has no default value.
      // _reqns has no default value.
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _eqns has no default value.
      // _tempvars has no default value.
      // _tempvars2 has no default value.
      // _simVars has no default value.
      // _simequations has no default value.
      // _resEqs has no default value.
      // _eqs has no default value.
      // _uniqueEqIndex has no default value.
      // _nInnerVars has no default value.
      // _tcrs has no default value.
      // _jacobianMatrix has no default value.
      // _tearingVars has no default value.
      // _residualEqns has no default value.
      // _homotopySupport has no default value.
      // _innerEquations has no default value.
      // _inJacobian has no default value.
      // _lSystem has no default value.
      // _nlSystem has no default value.
      // _alternativeTearingL has no default value.
      // _alternativeTearingNl has no default value.
      // _partOfJac has no default value.
      // _clockIndex has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _vars = tmpMeta6;
          _eqns = tmpMeta7;
          _globalKnownVars = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = _strictTearingSet;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 5));
          _tearingVars = tmpMeta10;
          _residualEqns = tmpMeta11;
          _innerEquations = tmpMeta12;
          _inJacobian = tmpMeta13;

          if((!omc_SymbolicJacobian_isJacobianGeneric(threadData, _inJacobian)))
          {
            tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
            omc_Error_addMessage(threadData, _OMC_LIT699, tmpMeta14);

            goto goto_2;
          }

          _tvars = omc_List_map1r(threadData, _tearingVars, boxvar_BackendVariable_getVarAt, _vars);

          _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

          /* Pattern-matching assignment */
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta16 = mmc_mk_box2(0, tmpMeta15, _globalKnownVars);
          tmpMeta17 = omc_List_fold(threadData, _tvars, boxvar_SimCodeUtil_traversingdlowvarToSimvarFold, tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 1));
          _simVars = tmpMeta18;

          _simVars = listReverse(_simVars);

          _reqns = omc_BackendEquation_getList(threadData, _residualEqns, _eqns);

          _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          _simequations = omc_SimCodeUtil_createTornSystemInnerEqns(threadData, _innerEquations, _skipDiscInAlgorithm, _genDiscrete, _isyst, _ishared, _iuniqueEqIndex, _itempvars, tmpMeta19 ,&_uniqueEqIndex ,&_tempvars ,&_nInnerVars ,NULL);

          /* Pattern-matching tuple assignment */
          tmpMeta24 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta25 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta24, _tempvars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ishared), 12))), &tmpMeta20, &tmpMeta23);
          _resEqs = tmpMeta25;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 1));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          _uniqueEqIndex = tmp22  /* pattern as ty=Integer */;
          _tempvars = tmpMeta23;

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          _eqs = listAppend(_simequations, _resEqs);

          _jacobianMatrix = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, _uniqueEqIndex, _tempvars, 0 /* false */ ,&_uniqueEqIndex ,&_tempvars);

          _partOfJac = omc_BackendDAEUtil_isJacobianDAE(threadData, _ishared);

          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta28 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta29 = mmc_mk_box13(3, &SimCode_LinearSystem_LINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _simVars, tmpMeta26, tmpMeta27, _eqs, _jacobianMatrix, tmpMeta28, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_tvars) + _nInnerVars + listLength(_tempvars) - listLength(_itempvars)), mmc_mk_boolean(_partOfJac));
          _lSystem = tmpMeta29;

          _tempvars2 = _tempvars;

          if(isSome(_casualTearingSet))
          {
            /* Pattern-matching assignment */
            tmpMeta30 = _casualTearingSet;
            if (optionNone(tmpMeta30)) goto goto_2;
            tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 1));
            tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 2));
            tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 3));
            tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 4));
            tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 5));
            _tearingVars = tmpMeta32;
            _residualEqns = tmpMeta33;
            _innerEquations = tmpMeta34;
            _inJacobian = tmpMeta35;

            _tvars = omc_List_map1r(threadData, _tearingVars, boxvar_BackendVariable_getVarAt, _vars);

            _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

            /* Pattern-matching assignment */
            tmpMeta36 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta37 = mmc_mk_box2(0, tmpMeta36, _globalKnownVars);
            tmpMeta38 = omc_List_fold(threadData, _tvars, boxvar_SimCodeUtil_traversingdlowvarToSimvarFold, tmpMeta37);
            tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 1));
            _simVars = tmpMeta39;

            _simVars = listReverse(_simVars);

            _reqns = omc_BackendEquation_getList(threadData, _residualEqns, _eqns);

            _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

            tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
            _simequations = omc_SimCodeUtil_createTornSystemInnerEqns(threadData, _innerEquations, _skipDiscInAlgorithm, _genDiscrete, _isyst, _ishared, ((modelica_integer) 1) + _uniqueEqIndex, _tempvars, tmpMeta40 ,&_uniqueEqIndex ,&_tempvars2 ,&_nInnerVars ,NULL);

            /* Pattern-matching tuple assignment */
            tmpMeta45 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
            tmpMeta46 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta45, _tempvars2, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ishared), 12))), &tmpMeta41, &tmpMeta44);
            _resEqs = tmpMeta46;
            tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 1));
            tmp43 = mmc_unbox_integer(tmpMeta42);
            _uniqueEqIndex = tmp43  /* pattern as ty=Integer */;
            _tempvars2 = tmpMeta44;

            _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

            _eqs = listAppend(_simequations, _resEqs);

            _jacobianMatrix = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, _uniqueEqIndex, _tempvars2, 0 /* false */ ,&_uniqueEqIndex ,&_tempvars2);

            tmpMeta47 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta48 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta49 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta50 = mmc_mk_box13(3, &SimCode_LinearSystem_LINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _simVars, tmpMeta47, tmpMeta48, _eqs, _jacobianMatrix, tmpMeta49, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_tvars) + _nInnerVars + listLength(_tempvars2) - listLength(_tempvars)), mmc_mk_boolean(_partOfJac));
            _alternativeTearingL = mmc_mk_some(tmpMeta50);
          }
          else
          {
            _alternativeTearingL = mmc_mk_none();
          }
          tmpMeta52 = mmc_mk_box4(15, &SimCode_SimEqSystem_SES__LINEAR__desc, _lSystem, _alternativeTearingL, _OMC_LIT535);
          tmpMeta51 = mmc_mk_cons(tmpMeta52, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta51;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars2;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_integer tmp63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_integer tmp68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_integer tmp79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_integer tmp84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _vars = tmpMeta53;
          _eqns = tmpMeta54;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta55 = _strictTearingSet;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 3));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 4));
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 5));
          _tearingVars = tmpMeta56;
          _residualEqns = tmpMeta57;
          _innerEquations = tmpMeta58;
          _inJacobian = tmpMeta59;

          _tvars = omc_List_map1r(threadData, _tearingVars, boxvar_BackendVariable_getVarAt, _vars);

          _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

          _reqns = omc_BackendEquation_getList(threadData, _residualEqns, _eqns);

          _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

          _tcrs = omc_List_map(threadData, _tvars, boxvar_BackendVariable_varCref);

          tmpMeta60 = MMC_REFSTRUCTLIT(mmc_nil);
          _simequations = omc_SimCodeUtil_createTornSystemInnerEqns(threadData, _innerEquations, _skipDiscInAlgorithm, _genDiscrete, _isyst, _ishared, _iuniqueEqIndex, _itempvars, tmpMeta60 ,&_uniqueEqIndex ,&_tempvars ,&_nInnerVars ,&_homotopySupport);

          /* Pattern-matching tuple assignment */
          tmpMeta65 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta66 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta65, _tempvars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ishared), 12))), &tmpMeta61, &tmpMeta64);
          _resEqs = tmpMeta66;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta61), 1));
          tmp63 = mmc_unbox_integer(tmpMeta62);
          _uniqueEqIndex = tmp63  /* pattern as ty=Integer */;
          _tempvars = tmpMeta64;

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          _eqs = listAppend(_simequations, _resEqs);

          _jacobianMatrix = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, _uniqueEqIndex, _tempvars, 1 /* true */ ,&_uniqueEqIndex ,&_tempvars);

          if((!_homotopySupport))
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            omc_BackendEquation_traverseExpsOfEquationList(threadData, _reqns, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta67);
            tmp68 = mmc_unbox_integer(tmpMeta67);
            _homotopySupport = tmp68  /* pattern as ty=Boolean */;
          }

          _clockIndex = omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_isyst), 9))));

          tmpMeta69 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _eqs, _tcrs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_tvars) + _nInnerVars + listLength(_tempvars) - listLength(_itempvars)), _jacobianMatrix, mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(1 /* true */), _clockIndex);
          _nlSystem = tmpMeta69;

          _tempvars2 = _tempvars;

          if(isSome(_casualTearingSet))
          {
            /* Pattern-matching assignment */
            tmpMeta70 = _casualTearingSet;
            if (optionNone(tmpMeta70)) goto goto_2;
            tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 1));
            tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 2));
            tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 3));
            tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 4));
            tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 5));
            _tearingVars = tmpMeta72;
            _residualEqns = tmpMeta73;
            _innerEquations = tmpMeta74;
            _inJacobian = tmpMeta75;

            _tvars = omc_List_map1r(threadData, _tearingVars, boxvar_BackendVariable_getVarAt, _vars);

            _tvars = omc_List_map(threadData, _tvars, boxvar_BackendVariable_transformXToXd);

            _reqns = omc_BackendEquation_getList(threadData, _residualEqns, _eqns);

            _reqns = omc_BackendEquation_replaceDerOpInEquationList(threadData, _reqns);

            _tcrs = omc_List_map(threadData, _tvars, boxvar_BackendVariable_varCref);

            tmpMeta76 = MMC_REFSTRUCTLIT(mmc_nil);
            _simequations = omc_SimCodeUtil_createTornSystemInnerEqns(threadData, _innerEquations, _skipDiscInAlgorithm, _genDiscrete, _isyst, _ishared, ((modelica_integer) 1) + _uniqueEqIndex, _tempvars, tmpMeta76 ,&_uniqueEqIndex ,&_tempvars2 ,&_nInnerVars ,&_homotopySupport);

            /* Pattern-matching tuple assignment */
            tmpMeta81 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
            tmpMeta82 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _reqns, tmpMeta81, _tempvars2, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_ishared), 12))), &tmpMeta77, &tmpMeta80);
            _resEqs = tmpMeta82;
            tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta77), 1));
            tmp79 = mmc_unbox_integer(tmpMeta78);
            _uniqueEqIndex = tmp79  /* pattern as ty=Integer */;
            _tempvars2 = tmpMeta80;

            _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

            _eqs = listAppend(_simequations, _resEqs);

            _jacobianMatrix = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, _uniqueEqIndex, _tempvars2, 0 /* false */ ,&_uniqueEqIndex ,&_tempvars2);

            if((!_homotopySupport))
            {
              /* Pattern-matching tuple assignment, wild first pattern */
              omc_BackendEquation_traverseExpsOfEquationList(threadData, _reqns, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta83);
              tmp84 = mmc_unbox_integer(tmpMeta83);
              _homotopySupport = tmp84  /* pattern as ty=Boolean */;
            }

            tmpMeta85 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _eqs, _tcrs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(listLength(_tvars) + _nInnerVars + listLength(_tempvars2) - listLength(_tempvars)), _jacobianMatrix, mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(1 /* true */), _clockIndex);
            _alternativeTearingNl = mmc_mk_some(tmpMeta85);
          }
          else
          {
            _alternativeTearingNl = mmc_mk_none();
          }
          tmpMeta87 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, _nlSystem, _alternativeTearingNl, _OMC_LIT535);
          tmpMeta86 = mmc_mk_cons(tmpMeta87, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta86;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTornSystem(threadData_t *threadData, modelica_metatype _linear, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _genDiscrete, modelica_metatype _strictTearingSet, modelica_metatype _casualTearingSet, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _iuniqueEqIndex, modelica_metatype _mixedSystem, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_linear);
  tmp2 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp3 = mmc_unbox_integer(_genDiscrete);
  tmp4 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp5 = mmc_unbox_integer(_mixedSystem);
  _equations_ = omc_SimCodeUtil_createTornSystem(threadData, tmp1, tmp2, tmp3, _strictTearingSet, _casualTearingSet, _isyst, _ishared, tmp4, tmp5, _itempvars, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_generateSolvedEquation(threadData_t *threadData, modelica_metatype _var, modelica_real _val, modelica_metatype _source, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _eq = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _name = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eq has no default value.
  // _ouniqueEqIndex has no default value.
  // _name has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _var;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _name = tmpMeta2;

  tmpMeta3 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, mmc_mk_real(_val));
  tmpMeta4 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _name, tmpMeta3, _source, _OMC_LIT535);
  _eq = tmpMeta4;

  _ouniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _eq;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_generateSolvedEquation(threadData_t *threadData, modelica_metatype _var, modelica_metatype _val, modelica_metatype _source, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_real tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _eq = NULL;
  tmp1 = mmc_unbox_real(_val);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _eq = omc_SimCodeUtil_generateSolvedEquation(threadData, _var, tmp1, _source, tmp2, &_ouniqueEqIndex);
  /* skip box _eq; SimCode.SimEqSystem */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _eq;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_checkLinearSystem(threadData_t *threadData, modelica_integer _info, modelica_metatype _vars, modelica_metatype _jac, modelica_metatype _rhs)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* matchcontinue expression */
    volatile modelica_integer tmp3_1;
    tmp3_1 = _info;
    {
      modelica_string _infoStr = NULL;
      modelica_string _syst = NULL;
      modelica_string _varnames = NULL;
      modelica_string _varname = NULL;
      modelica_string _rhsStr = NULL;
      modelica_string _jacStr = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _infoStr has no default value.
      // _syst has no default value.
      // _varnames has no default value.
      // _varname has no default value.
      // _rhsStr has no default value.
      // _jacStr has no default value.
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 3; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          if (0 != tmp3_1) goto tmp2_end;
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        case 1: {
          modelica_boolean tmp5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp5 = (_info > ((modelica_integer) 0));
          if (1 /* true */ != tmp5) goto goto_1;

          _varname = omc_ComponentReferenceBasics_printComponentRefStr(threadData, listGet(_vars, _info));

          _infoStr = intString(_info);

          _varnames = stringDelimitList(omc_List_map(threadData, _vars, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT718);

          _rhsStr = stringDelimitList(omc_List_map(threadData, _rhs, boxvar_realString), _OMC_LIT718);

          _jacStr = stringDelimitList(omc_List_map1(threadData, omc_List_mapList(threadData, _jac, boxvar_realString), boxvar_stringDelimitList, _OMC_LIT377), _OMC_LIT718);

          tmpMeta6 = mmc_mk_cons(_OMC_LIT719, mmc_mk_cons(_jacStr, mmc_mk_cons(_OMC_LIT720, mmc_mk_cons(_varnames, mmc_mk_cons(_OMC_LIT721, mmc_mk_cons(_rhsStr, mmc_mk_cons(_OMC_LIT722, MMC_REFSTRUCTLIT(mmc_nil))))))));
          _syst = stringAppendList(tmpMeta6);

          tmpMeta7 = mmc_mk_cons(_syst, mmc_mk_cons(_infoStr, mmc_mk_cons(_varname, MMC_REFSTRUCTLIT(mmc_nil))));
          omc_Error_addMessage(threadData, _OMC_LIT724, tmpMeta7);
          goto goto_1;
          goto tmp2_done;
        }
        case 2: {
          modelica_boolean tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp8 = (_info < ((modelica_integer) 0));
          if (1 /* true */ != tmp8) goto goto_1;

          _varnames = stringDelimitList(omc_List_map(threadData, _vars, boxvar_ComponentReferenceBasics_printComponentRefStr), _OMC_LIT718);

          _rhsStr = stringDelimitList(omc_List_map(threadData, _rhs, boxvar_realString), _OMC_LIT725);

          _jacStr = stringDelimitList(omc_List_map1(threadData, omc_List_mapList(threadData, _jac, boxvar_realString), boxvar_stringDelimitList, _OMC_LIT377), _OMC_LIT725);

          tmpMeta9 = mmc_mk_cons(_OMC_LIT359, mmc_mk_cons(_jacStr, mmc_mk_cons(_OMC_LIT726, mmc_mk_cons(_varnames, mmc_mk_cons(_OMC_LIT727, mmc_mk_cons(_rhsStr, mmc_mk_cons(_OMC_LIT360, MMC_REFSTRUCTLIT(mmc_nil))))))));
          _syst = stringAppendList(tmpMeta9);

          tmpMeta10 = mmc_mk_cons(_OMC_LIT730, mmc_mk_cons(_syst, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addMessage(threadData, _OMC_LIT729, tmpMeta10);
          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 3) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}
PROTECTED_FUNCTION_STATIC void boxptr_SimCodeUtil_checkLinearSystem(threadData_t *threadData, modelica_metatype _info, modelica_metatype _vars, modelica_metatype _jac, modelica_metatype _rhs)
{
  modelica_integer tmp1;
  tmp1 = mmc_unbox_integer(_info);
  omc_SimCodeUtil_checkLinearSystem(threadData, tmp1, _vars, _jac, _rhs);
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createOdeSystem2(threadData_t *threadData, modelica_boolean _mixedEvent, modelica_metatype _inVars, modelica_metatype _inKnVars, modelica_metatype _inEquationArray, modelica_metatype _inJacobian, modelica_metatype _inJacobianType, modelica_metatype _inFuncs, modelica_metatype _inAllVars, modelica_integer _iuniqueEqIndex, modelica_metatype _iei, modelica_boolean _mixedSystem, modelica_boolean _partOfJac, modelica_metatype _itempvars, modelica_metatype _clockIndex, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inJacobian;
    tmp4_2 = _inJacobianType;
    {
      modelica_integer _uniqueEqIndex;
      modelica_metatype _eqn_lst = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _resEqs = NULL;
      modelica_metatype _simVars = NULL;
      modelica_metatype _beqs = NULL;
      modelica_metatype _jac = NULL;
      modelica_metatype _simJac = NULL;
      modelica_integer _linInfo;
      modelica_metatype _jacVals = NULL;
      modelica_metatype _rhsVals = NULL;
      modelica_metatype _solvedVals = NULL;
      modelica_metatype _sources = NULL;
      modelica_metatype _names = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_string _str = NULL;
      modelica_metatype _jacobianMatrix = NULL;
      modelica_boolean _homotopySupport;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _uniqueEqIndex has no default value.
      // _eqn_lst has no default value.
      // _crefs has no default value.
      // _resEqs has no default value.
      // _simVars has no default value.
      // _beqs has no default value.
      // _jac has no default value.
      // _simJac has no default value.
      // _linInfo has no default value.
      // _jacVals has no default value.
      // _rhsVals has no default value.
      // _solvedVals has no default value.
      // _sources has no default value.
      // _names has no default value.
      // _tempvars has no default value.
      // _str has no default value.
      // _jacobianMatrix has no default value.
      // _homotopySupport has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,0,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          _jac = tmpMeta7;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Debug_trace(threadData, _OMC_LIT731);
          }

          /* Pattern-matching assignment */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = mmc_mk_box2(0, tmpMeta8, _inKnVars);
          tmpMeta10 = omc_BackendVariable_traverseBackendDAEVars(threadData, _inVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          _simVars = tmpMeta11;

          _simVars = listReverse(_simVars);

          _beqs = omc_BackendDAEUtil_getEqnSysRhs(threadData, _inEquationArray, _inVars, mmc_mk_some(_inFuncs) ,&_sources);

          _beqs = listReverse(_beqs);

          _rhsVals = omc_ValuesUtil_valueReals(threadData, omc_List_map(threadData, _beqs, boxvar_Ceval_cevalSimple));

          _jacVals = omc_SymbolicJacobian_evaluateConstantJacobian(threadData, listLength(_simVars), _jac);

          _solvedVals = omc_System_dgesv(threadData, _jacVals, _rhsVals ,&_linInfo);

          {
            modelica_metatype __omcQ_24tmpVar69;
            modelica_metatype* tmp13;
            modelica_metatype tmpMeta14;
            modelica_metatype __omcQ_24tmpVar68;
            modelica_integer tmp15;
            modelica_metatype _v_loopVar = 0;
            modelica_metatype _v;
            _v_loopVar = _simVars;
            tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar69 = tmpMeta14; /* defaultValue */
            tmp13 = &__omcQ_24tmpVar69;
            while(1) {
              tmp15 = 1;
              if (!listEmpty(_v_loopVar)) {
                _v = MMC_CAR(_v_loopVar);
                _v_loopVar = MMC_CDR(_v_loopVar);
                tmp15--;
              }
              if (tmp15 == 0) {
                __omcQ_24tmpVar68 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2)));
                *tmp13 = mmc_mk_cons(__omcQ_24tmpVar68,0);
                tmp13 = &MMC_CDR(*tmp13);
              } else if (tmp15 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp13 = mmc_mk_nil();
            tmpMeta12 = __omcQ_24tmpVar69;
          }
          _names = tmpMeta12;

          omc_SimCodeUtil_checkLinearSystem(threadData, _linInfo, _names, _jacVals, _rhsVals);

          tmpMeta16 = mmc_mk_box5(11, &DAE_SymbolicOperation_LINEAR__SOLVED__desc, _names, _jacVals, _rhsVals, _solvedVals);
          _sources = omc_List_map1(threadData, _sources, boxvar_ElementSource_addSymbolicTransformation, tmpMeta16);

          /* Pattern-matching tuple assignment */
          tmpMeta19 = omc_List_thread3MapFold(threadData, _simVars, _solvedVals, _sources, boxvar_SimCodeUtil_generateSolvedEquation, mmc_mk_integer(_iuniqueEqIndex), &tmpMeta17);
          _equations_ = tmpMeta19;
          tmp18 = mmc_unbox_integer(tmpMeta17);
          _uniqueEqIndex = tmp18  /* pattern as ty=Integer */;
          tmpMeta[0+0] = _equations_;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,0) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (optionNone(tmpMeta20)) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 1));
          _jac = tmpMeta21;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Debug_trace(threadData, _OMC_LIT732);
          }

          /* Pattern-matching assignment */
          tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta23 = mmc_mk_box2(0, tmpMeta22, _inKnVars);
          tmpMeta24 = omc_BackendVariable_traverseBackendDAEVars(threadData, _inVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
          _simVars = tmpMeta25;

          _simVars = listReverse(_simVars);

          _beqs = omc_BackendDAEUtil_getEqnSysRhs(threadData, _inEquationArray, _inVars, mmc_mk_some(_inFuncs) ,&_sources);

          _beqs = listReverse(_beqs);

          _simJac = omc_List_map1(threadData, _jac, boxvar_SimCodeUtil_jacToSimjac, _inVars);

          if((stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))
          {
            _simJac = omc_List_sort(threadData, _simJac, boxvar_SimCodeUtil_simJacCSRToCSC);
          }
          tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta28 = mmc_mk_box13(3, &SimCode_LinearSystem_LINEARSYSTEM__desc, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_boolean(_mixedEvent), mmc_mk_boolean(0 /* false */), _simVars, _beqs, _simJac, tmpMeta27, mmc_mk_none(), _sources, mmc_mk_integer(((modelica_integer) 0)), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 5))), mmc_mk_boolean(_partOfJac));
          tmpMeta29 = mmc_mk_box4(15, &SimCode_SimEqSystem_SES__LINEAR__desc, tmpMeta28, mmc_mk_none(), _OMC_LIT535);
          tmpMeta26 = mmc_mk_cons(tmpMeta29, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta26;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Debug_trace(threadData, _OMC_LIT733);
          }

          _eqn_lst = omc_BackendEquation_equationList(threadData, _inEquationArray);

          _crefs = omc_BackendVariable_getAllCrefFromVariables(threadData, _inVars);

          /* Pattern-matching tuple assignment */
          tmpMeta34 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta35 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _eqn_lst, tmpMeta34, _itempvars, _inFuncs, &tmpMeta30, &tmpMeta33);
          _resEqs = tmpMeta35;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 1));
          tmp32 = mmc_unbox_integer(tmpMeta31);
          _uniqueEqIndex = tmp32  /* pattern as ty=Integer */;
          _tempvars = tmpMeta33;

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          _jacobianMatrix = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _inJacobian, _uniqueEqIndex, _tempvars, 1 /* true */ ,&_uniqueEqIndex ,&_tempvars);

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_BackendEquation_traverseExpsOfEquationList(threadData, _eqn_lst, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta36);
          tmp37 = mmc_unbox_integer(tmpMeta36);
          _homotopySupport = tmp37  /* pattern as ty=Boolean */;
          tmpMeta39 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _resEqs, _crefs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 5)))) + listLength(_tempvars) - listLength(_itempvars)), _jacobianMatrix, mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(0 /* false */), _clockIndex);
          tmpMeta40 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta39, mmc_mk_none(), _OMC_LIT535);
          tmpMeta38 = mmc_mk_cons(tmpMeta40, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta38;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_integer tmp48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Debug_trace(threadData, _OMC_LIT734);
          }

          _eqn_lst = omc_BackendEquation_equationList(threadData, _inEquationArray);

          _crefs = omc_BackendVariable_getAllCrefFromVariables(threadData, _inVars);

          /* Pattern-matching tuple assignment */
          tmpMeta45 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta46 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _eqn_lst, tmpMeta45, _itempvars, _inFuncs, &tmpMeta41, &tmpMeta44);
          _resEqs = tmpMeta46;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 1));
          tmp43 = mmc_unbox_integer(tmpMeta42);
          _uniqueEqIndex = tmp43  /* pattern as ty=Integer */;
          _tempvars = tmpMeta44;

          _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_BackendEquation_traverseExpsOfEquationList(threadData, _eqn_lst, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta47);
          tmp48 = mmc_unbox_integer(tmpMeta47);
          _homotopySupport = tmp48  /* pattern as ty=Boolean */;
          tmpMeta50 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _resEqs, _crefs, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVars), 5)))) + listLength(_tempvars) - listLength(_itempvars)), mmc_mk_none(), mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(_mixedSystem), mmc_mk_boolean(0 /* false */), _clockIndex);
          tmpMeta51 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta50, mmc_mk_none(), _OMC_LIT535);
          tmpMeta49 = mmc_mk_cons(tmpMeta51, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta49;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta52;
          
          /* Pattern matching succeeded */
          _str = omc_BackendDump_jacobianTypeStr(threadData, _inJacobianType);

          tmpMeta52 = stringAppend(_OMC_LIT735,_str);
          _str = tmpMeta52;

          omc_Error_addInternalError(threadData, _str, _OMC_LIT736);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createOdeSystem2(threadData_t *threadData, modelica_metatype _mixedEvent, modelica_metatype _inVars, modelica_metatype _inKnVars, modelica_metatype _inEquationArray, modelica_metatype _inJacobian, modelica_metatype _inJacobianType, modelica_metatype _inFuncs, modelica_metatype _inAllVars, modelica_metatype _iuniqueEqIndex, modelica_metatype _iei, modelica_metatype _mixedSystem, modelica_metatype _partOfJac, modelica_metatype _itempvars, modelica_metatype _clockIndex, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_mixedEvent);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp3 = mmc_unbox_integer(_mixedSystem);
  tmp4 = mmc_unbox_integer(_partOfJac);
  _equations_ = omc_SimCodeUtil_createOdeSystem2(threadData, tmp1, _inVars, _inKnVars, _inEquationArray, _inJacobian, _inJacobianType, _inFuncs, _inAllVars, tmp2, _iei, tmp3, tmp4, _itempvars, _clockIndex, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createOdeSystem(threadData_t *threadData, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _inComp, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _isccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _iBackendMapping, modelica_metatype *out_noDiscequations_, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oBackendMapping)
{
  modelica_metatype _equations_ = NULL;
  modelica_metatype _noDiscequations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _oeqSccMapping = NULL;
  modelica_metatype _oBackendMapping = NULL;
  modelica_integer tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[6] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _noDiscequations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _oeqSccMapping has no default value.
  // _oBackendMapping has no default value.
  
  
  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _isyst;
    tmp4_2 = _ishared;
    tmp4_3 = _inComp;
    {
      modelica_metatype _eqn_lst = NULL;
      modelica_metatype _var_lst = NULL;
      modelica_metatype _var_lst_1 = NULL;
      modelica_metatype _vars_1 = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _eqns_1 = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _jac_tp = NULL;
      modelica_metatype _funcs = NULL;
      modelica_metatype _eqIdcs = NULL;
      modelica_metatype _comp = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_integer _uniqueEqIndexMapping;
      modelica_string _msg = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_boolean _b;
      modelica_metatype _tmpEqSccMapping = NULL;
      modelica_metatype _ei = NULL;
      modelica_metatype _jacobian = NULL;
      modelica_metatype _tmpBackendMapping = NULL;
      modelica_boolean _mixedSystem;
      modelica_metatype _strictTearingSet = NULL;
      modelica_metatype _casualTearingSet = NULL;
      modelica_boolean _partOfJac;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn_lst has no default value.
      // _var_lst has no default value.
      // _var_lst_1 has no default value.
      // _vars_1 has no default value.
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _eqns_1 has no default value.
      // _eqns has no default value.
      // _jac_tp has no default value.
      // _funcs has no default value.
      // _eqIdcs has no default value.
      // _comp has no default value.
      // _uniqueEqIndex has no default value.
      // _uniqueEqIndexMapping has no default value.
      // _msg has no default value.
      // _tempvars has no default value.
      // _b has no default value.
      // _tmpEqSccMapping has no default value.
      // _ei has no default value.
      // _jacobian has no default value.
      // _tmpBackendMapping has no default value.
      // _mixedSystem has no default value.
      // _strictTearingSet has no default value.
      // _casualTearingSet has no default value.
      // _partOfJac has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 4));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 5));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 6));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 12));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 17));
          
          _comp = tmp4_3;
          _eqIdcs = tmpMeta6;
          _jacobian = tmpMeta7;
          _jac_tp = tmpMeta8;
          _mixedSystem = tmp10  /* pattern as ty=Boolean */;
          _vars = tmpMeta11;
          _eqns = tmpMeta12;
          _globalKnownVars = tmpMeta13;
          _funcs = tmpMeta14;
          _ei = tmpMeta15;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT227))
          {
            omc_Debug_trace(threadData, _OMC_LIT737);
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT741))
          {
            tmpMeta16 = stringAppend(_OMC_LIT738,intString(_iuniqueEqIndex));
            omc_BackendDump_dumpBipartiteGraphStrongComponent1(threadData, _inComp, omc_BackendEquation_equationList(threadData, _eqns), omc_BackendVariable_varList(threadData, _vars), mmc_mk_some(omc_BackendDAEUtil_getFunctions(threadData, _ishared)), tmpMeta16);
          }

          _eqn_lst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_var_lst ,NULL);

          _eqn_lst = omc_BackendEquation_replaceDerOpInEquationList(threadData, _eqn_lst);

          _var_lst_1 = omc_List_map(threadData, _var_lst, boxvar_BackendVariable_transformXToXd);

          _vars_1 = omc_BackendVariable_listVar1(threadData, _var_lst_1);

          _eqns_1 = omc_BackendEquation_listEquation(threadData, _eqn_lst);

          _partOfJac = omc_BackendDAEUtil_isJacobianDAE(threadData, _ishared);

          _equations_ = omc_SimCodeUtil_createOdeSystem2(threadData, 0 /* false */, _vars_1, _globalKnownVars, _eqns_1, _jacobian, _jac_tp, _funcs, _vars, _iuniqueEqIndex, _ei, _mixedSystem, _partOfJac, _itempvars, omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_isyst), 9)))) ,&_uniqueEqIndex ,&_tempvars);

          _uniqueEqIndexMapping = ((modelica_integer) -1) + _uniqueEqIndex;

          _tmpEqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndexMapping, ((modelica_integer) -1) + _uniqueEqIndex, _isccIndex, _ieqSccMapping);

          _tmpBackendMapping = omc_SimCodeUtil_setEqMapping(threadData, omc_List_intRange2(threadData, _uniqueEqIndexMapping, ((modelica_integer) -1) + _uniqueEqIndex), _eqIdcs, _iBackendMapping);
          tmpMeta[0+0] = _equations_;
          tmpMeta[0+1] = _equations_;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          tmpMeta[0+4] = _tmpEqSccMapping;
          tmpMeta[0+5] = _tmpBackendMapping;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_integer tmp20;
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,7,4) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 3));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 4));
          tmp20 = mmc_unbox_integer(tmpMeta19);
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 5));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _strictTearingSet = tmpMeta17;
          _casualTearingSet = tmpMeta18;
          _b = tmp20  /* pattern as ty=Boolean */;
          _mixedSystem = tmp22  /* pattern as ty=Boolean */;
          _vars = tmpMeta23;
          _eqns = tmpMeta24;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT741))
          {
            tmpMeta25 = stringAppend(_OMC_LIT742,intString(_iuniqueEqIndex));
            omc_BackendDump_dumpBipartiteGraphStrongComponent1(threadData, _inComp, omc_BackendEquation_equationList(threadData, _eqns), omc_BackendVariable_varList(threadData, _vars), mmc_mk_some(omc_BackendDAEUtil_getFunctions(threadData, _ishared)), tmpMeta25);
          }

          _equations_ = omc_SimCodeUtil_createTornSystem(threadData, _b, _skipDiscInAlgorithm, _genDiscrete, _strictTearingSet, _casualTearingSet, _isyst, _ishared, _iuniqueEqIndex, _mixedSystem, _itempvars ,&_uniqueEqIndex ,&_tempvars);

          _tmpEqSccMapping = omc_SimCodeUtil_appendSccIdx(threadData, ((modelica_integer) -1) + _uniqueEqIndex, _isccIndex, _ieqSccMapping);

          _tmpBackendMapping = _iBackendMapping;
          tmpMeta[0+0] = _equations_;
          tmpMeta[0+1] = _equations_;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          tmpMeta[0+4] = _tmpEqSccMapping;
          tmpMeta[0+5] = _tmpBackendMapping;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta26;
          
          /* Pattern matching succeeded */
          tmpMeta26 = stringAppend(_OMC_LIT743,omc_BackendDump_strongComponentString(threadData, _inComp));
          _msg = tmpMeta26;

          omc_Error_addInternalError(threadData, _msg, _OMC_LIT744);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _noDiscequations_ = tmpMeta[0+1];
  _ouniqueEqIndex = tmp1_c2;
  _otempvars = tmpMeta[0+3];
  _oeqSccMapping = tmpMeta[0+4];
  _oBackendMapping = tmpMeta[0+5];
  _return: OMC_LABEL_UNUSED
  if (out_noDiscequations_) { *out_noDiscequations_ = _noDiscequations_; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_oeqSccMapping) { *out_oeqSccMapping = _oeqSccMapping; }
  if (out_oBackendMapping) { *out_oBackendMapping = _oBackendMapping; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createOdeSystem(threadData_t *threadData, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _isyst, modelica_metatype _ishared, modelica_metatype _inComp, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _isccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _iBackendMapping, modelica_metatype *out_noDiscequations_, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oBackendMapping)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_genDiscrete);
  tmp2 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp3 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp4 = mmc_unbox_integer(_isccIndex);
  _equations_ = omc_SimCodeUtil_createOdeSystem(threadData, tmp1, tmp2, _isyst, _ishared, _inComp, tmp3, _itempvars, tmp4, _ieqSccMapping, _iBackendMapping, out_noDiscequations_, &_ouniqueEqIndex, out_otempvars, out_oeqSccMapping, out_oBackendMapping);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  /* skip box _noDiscequations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  /* skip box _oeqSccMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _oBackendMapping; SimCode.BackendMapping */
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolvedIfBranch(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _ifbranch, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _result = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _result has no default value.
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  // _lst has no default value.
  /* Pattern-matching tuple assignment */
  tmpMeta3 = omc_List_mapFold(threadData, _ifbranch, boxvar_SimCodeUtil_makeSolved, mmc_mk_integer(_uniqueEqIndex), &tmpMeta1);
  _lst = tmpMeta3;
  tmp2 = mmc_unbox_integer(tmpMeta1);
  _uniqueEqIndex = tmp2  /* pattern as ty=Integer */;

  tmpMeta4 = mmc_mk_box2(0, _cond, _lst);
  _result = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _result;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolvedIfBranch(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _ifbranch, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _result = NULL;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _result = omc_SimCodeUtil_makeSolvedIfBranch(threadData, _cond, _ifbranch, tmp1, &_uniqueEqIndex);
  /* skip box _result; tuple<DAE.Exp, list<SimCode.SimEqSystem>> */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _result;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSolved(threadData_t *threadData, modelica_metatype _eq, modelica_integer __omcQ_24in_5FuniqueEqIndex, modelica_integer *out_uniqueEqIndex)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqn has no default value.
  _uniqueEqIndex = __omcQ_24in_5FuniqueEqIndex;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _ifbranches = NULL;
      modelica_metatype _elsebranch = NULL;
      modelica_metatype _stmts = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ifbranches has no default value.
      // _elsebranch has no default value.
      // _stmts has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta6 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 5))));
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta9 = omc_List_threadMapFold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), boxvar_SimCodeUtil_makeSolvedIfBranch, mmc_mk_integer(_uniqueEqIndex), &tmpMeta7);
          _ifbranches = tmpMeta9;
          tmp8 = mmc_unbox_integer(tmpMeta7);
          _uniqueEqIndex = tmp8  /* pattern as ty=Integer */;

          /* Pattern-matching tuple assignment */
          tmpMeta12 = omc_List_mapFold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), boxvar_SimCodeUtil_makeSolved, mmc_mk_integer(_uniqueEqIndex), &tmpMeta10);
          _elsebranch = tmpMeta12;
          tmp11 = mmc_unbox_integer(tmpMeta10);
          _uniqueEqIndex = tmp11  /* pattern as ty=Integer */;
          tmpMeta13 = mmc_mk_box6(12, &SimCode_SimEqSystem_SES__IFEQUATION__desc, mmc_mk_integer(_uniqueEqIndex), _ifbranches, _elsebranch, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 6))));
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          
          _stmts = tmpMeta15;
          /* Pattern matching succeeded */
          tmpMeta16 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_uniqueEqIndex), _stmts, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 6))));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT745, _OMC_LIT746);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outSimEqn = tmpMeta1;

  _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;
  _return: OMC_LABEL_UNUSED
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = _uniqueEqIndex; }
  return _outSimEqn;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSolved(threadData_t *threadData, modelica_metatype _eq, modelica_metatype __omcQ_24in_5FuniqueEqIndex, modelica_metatype *out_uniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _uniqueEqIndex;
  modelica_metatype _outSimEqn = NULL;
  tmp1 = mmc_unbox_integer(__omcQ_24in_5FuniqueEqIndex);
  _outSimEqn = omc_SimCodeUtil_makeSolved(threadData, _eq, tmp1, &_uniqueEqIndex);
  /* skip box _outSimEqn; SimCode.SimEqSystem */
  if (out_uniqueEqIndex) { *out_uniqueEqIndex = mmc_mk_icon(_uniqueEqIndex); }
  return _outSimEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _eqn = NULL;
  modelica_integer tmp2_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSimEqn = tmpMeta1;
  _ouniqueEqIndex = _iuniqueEqIndex;
  // _eqn has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp5_1;
    tmp5_1 = _inTpl;
    {
      modelica_metatype _left = NULL;
      modelica_metatype _right = NULL;
      modelica_metatype _elems = NULL;
      volatile mmc_switch_type tmp5;
      int tmp6;
      // _left has no default value.
      // _right has no default value.
      // _elems has no default value.
      tmp5 = 0;
      for (; tmp5 < 2; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,16,3) == 0) goto tmp4_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,6,2) == 0) goto tmp4_end;
          
          _left = tmpMeta7;
          _right = tmpMeta8;
          /* Pattern matching succeeded */
          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp11;
              int tmp12;
              tmp11 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp10_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp11 < 2; tmp11++) {
                switch (MMC_SWITCH_CAST(tmp11)) {
                case 0: {
                  modelica_metatype tmpMeta13;
                  modelica_metatype tmpMeta14;
                  modelica_metatype tmpMeta15;
                  modelica_metatype tmpMeta16;
                  modelica_metatype tmpMeta17;
                  /* Pattern matching succeeded */
                  /* Pattern-matching assignment */
                  tmpMeta13 = omc_Static_crefVectorize(threadData, 1 /* true */, _right, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_right), 3))), mmc_mk_none(), omc_Types_arrayElementType(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_right), 3)))));
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,16,3) == 0) goto goto_9;
                  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 4));
                  _elems = tmpMeta14;

                  {
                    modelica_metatype _tpl;
                    for (tmpMeta15 = omc_List_zip(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_left), 4))), _elems); !listEmpty(tmpMeta15); tmpMeta15=MMC_CDR(tmpMeta15))
                    {
                      _tpl = MMC_CAR(tmpMeta15);
                      _eqn = omc_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData, _tpl, _source, _eqAttr, _ouniqueEqIndex ,&_ouniqueEqIndex);

                      tmpMeta16 = mmc_mk_cons(_eqn, _outSimEqn);
                      _outSimEqn = tmpMeta16;
                    }
                  }

                  _outSimEqn = listReverse(_outSimEqn);
                  goto tmp10_done;
                }
                case 1: {
                  modelica_metatype tmpMeta18;
                  modelica_metatype tmpMeta19;
                  /* Pattern matching succeeded */
                  tmpMeta18 = stringAppend(_OMC_LIT747,omc_ExpressionBasics_printExpStr(threadData, _right));
                  tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT748);
                  omc_Error_terminate(threadData, tmpMeta19, _OMC_LIT749);
                  goto tmp10_done;
                }
                }
                goto tmp10_end;
                tmp10_end: ;
              }
              goto goto_9;
              tmp10_done:
              (void)tmp11;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp10_done2;
              goto_9:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp11 < 2) {
                goto tmp10_top;
              }
              goto goto_3;
              tmp10_done2:;
            }
          }
          ;
          tmpMeta[0+0] = _outSimEqn;
          tmp2_c1 = _ouniqueEqIndex;
          goto tmp4_done;
        }
        case 1: {
          modelica_metatype tmpMeta20;
          
          /* Pattern matching succeeded */
          _eqn = omc_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData, _inTpl, _source, _eqAttr, _ouniqueEqIndex ,&_ouniqueEqIndex);
          tmpMeta20 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta20;
          tmp2_c1 = _ouniqueEqIndex;
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  _outSimEqn = tmpMeta[0+0];
  _ouniqueEqIndex = tmp2_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outSimEqn;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outSimEqn = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outSimEqn = omc_SimCodeUtil_makeSES__SIMPLE__ASSIGNwithArray(threadData, _inTpl, _source, _eqAttr, tmp1, &_ouniqueEqIndex);
  /* skip box _outSimEqn; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outSimEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _e = NULL;
  modelica_metatype _cr = NULL;
  modelica_string _msg = NULL;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqn has no default value.
  // _ouniqueEqIndex has no default value.
  // _e has no default value.
  // _cr has no default value.
  // _msg has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inTpl;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _cr = tmpMeta7;
          _e = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _e;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,8,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,5,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,6,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _cr = tmpMeta12;
          _e = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = omc_Expression_negate(threadData, _e);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          
          /* Pattern matching succeeded */
          tmpMeta14 = stringAppend(_OMC_LIT750,omc_ExpressionBasics_printExpStr(threadData, omc_Util_tuple21(threadData, _inTpl)));
          tmpMeta15 = stringAppend(tmpMeta14,_OMC_LIT224);
          tmpMeta16 = stringAppend(tmpMeta15,omc_ExpressionBasics_printExpStr(threadData, omc_Util_tuple22(threadData, _inTpl)));
          tmpMeta17 = stringAppend(tmpMeta16,_OMC_LIT48);
          _msg = tmpMeta17;

          omc_Error_addCompilerWarning(threadData, _msg);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _cr = tmpMeta[0+0];
  _e = tmpMeta[0+1];

  tmpMeta18 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _cr, _e, _source, _eqAttr);
  _outSimEqn = tmpMeta18;

  _ouniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _outSimEqn;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outSimEqn = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outSimEqn = omc_SimCodeUtil_makeSES__SIMPLE__ASSIGN(threadData, _inTpl, _source, _eqAttr, tmp1, &_ouniqueEqIndex);
  /* skip box _outSimEqn; SimCode.SimEqSystem */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _outSimEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__RESIDUAL1(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype *out_idx_tpl)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_metatype _idx_tpl = NULL;
  modelica_metatype _e1 = NULL;
  modelica_metatype _e2 = NULL;
  modelica_metatype _e = NULL;
  modelica_integer _eq_idx;
  modelica_integer _res_idx;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_integer tmp6;
  modelica_metatype tmpMeta7;
  modelica_integer tmp8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqn has no default value.
  _idx_tpl = __omcQ_24in_5Fidx_5Ftpl;
  // _e1 has no default value.
  // _e2 has no default value.
  // _e has no default value.
  // _eq_idx has no default value.
  // _res_idx has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _e1 = tmpMeta2;
  _e2 = tmpMeta3;

  /* Pattern-matching assignment */
  tmpMeta4 = _idx_tpl;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmp6 = mmc_unbox_integer(tmpMeta5);
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmp8 = mmc_unbox_integer(tmpMeta7);
  _eq_idx = tmp6  /* pattern as ty=Integer */;
  _res_idx = tmp8  /* pattern as ty=Integer */;

  _e = omc_Expression_createResidualExp(threadData, _e1, _e2);

  tmpMeta9 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx), _e, _source, _eqAttr);
  _outSimEqn = tmpMeta9;

  tmpMeta10 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(((modelica_integer) 1) + _res_idx));
  _idx_tpl = tmpMeta10;
  _return: OMC_LABEL_UNUSED
  if (out_idx_tpl) { *out_idx_tpl = _idx_tpl; }
  return _outSimEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_makeSES__RESIDUAL(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype *out_idx_tpl)
{
  modelica_metatype _outSimEqn = NULL;
  modelica_metatype _idx_tpl = NULL;
  modelica_integer _eq_idx;
  modelica_integer _res_idx;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimEqn has no default value.
  _idx_tpl = __omcQ_24in_5Fidx_5Ftpl;
  // _eq_idx has no default value.
  // _res_idx has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _idx_tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _eq_idx = tmp3  /* pattern as ty=Integer */;
  _res_idx = tmp5  /* pattern as ty=Integer */;

  tmpMeta6 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx), _inExp, _source, _eqAttr);
  _outSimEqn = tmpMeta6;

  tmpMeta7 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(((modelica_integer) 1) + _res_idx));
  _idx_tpl = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  if (out_idx_tpl) { *out_idx_tpl = _idx_tpl; }
  return _outSimEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefs(threadData_t *threadData, modelica_metatype _inCrefs, modelica_integer _iuniqueEqIndex, modelica_metatype _inCrefsAcc, modelica_metatype _iRepl, modelica_metatype *out_oRepl)
{
  modelica_metatype _outCrefs = NULL;
  modelica_metatype _oRepl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outCrefs has no default value.
  // _oRepl has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inCrefs;
    {
      modelica_metatype _cref = NULL;
      modelica_metatype _crtmp = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _tp = NULL;
      modelica_string _ident = NULL;
      modelica_metatype _repl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cref has no default value.
      // _crtmp has no default value.
      // _rest has no default value.
      // _tp has no default value.
      // _ident has no default value.
      // _repl has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = listReverse(_inCrefsAcc);
          tmpMeta[0+1] = _iRepl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          _cref = tmpMeta6;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _ident = omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cref);

          _tp = omc_Types_arrayElementType(threadData, omc_ComponentReference_crefLastType(threadData, _cref));

          tmpMeta8 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT566);
          tmpMeta10 = stringAppend(tmpMeta9,intString(_iuniqueEqIndex));
          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          _crtmp = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta10, _tp, tmpMeta11);

          tmpMeta12 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _crtmp, _tp);
          _repl = omc_BackendVarTransform_addReplacement(threadData, _iRepl, _cref, tmpMeta12, mmc_mk_some(boxvar_BackendVarTransform_skipPreOperator));
          tmpMeta13 = mmc_mk_cons(_crtmp, _inCrefsAcc);
          /* Tail recursive call */
          _inCrefs = _rest;
          _inCrefsAcc = tmpMeta13;
          _iRepl = _repl;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outCrefs = tmpMeta[0+0];
  _oRepl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oRepl) { *out_oRepl = _oRepl; }
  return _outCrefs;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createTmpCrefs(threadData_t *threadData, modelica_metatype _inCrefs, modelica_metatype _iuniqueEqIndex, modelica_metatype _inCrefsAcc, modelica_metatype _iRepl, modelica_metatype *out_oRepl)
{
  modelica_integer tmp1;
  modelica_metatype _outCrefs = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _outCrefs = omc_SimCodeUtil_createTmpCrefs(threadData, _inCrefs, tmp1, _inCrefsAcc, _iRepl, out_oRepl);
  /* skip box _outCrefs; list<DAE.ComponentRef> */
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  return _outCrefs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dimsToAllIndexes2(threadData_t *threadData, modelica_integer _i, modelica_metatype _iIndex, modelica_metatype _iAllIndex)
{
  modelica_metatype _oAllIndex = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oAllIndex has no default value.
  _oAllIndex = omc_List_map1(threadData, _iIndex, boxvar_List_consr, mmc_mk_integer(_i));

  _oAllIndex = listAppend(_iAllIndex, _oAllIndex);
  _return: OMC_LABEL_UNUSED
  return _oAllIndex;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_dimsToAllIndexes2(threadData_t *threadData, modelica_metatype _i, modelica_metatype _iIndex, modelica_metatype _iAllIndex)
{
  modelica_integer tmp1;
  modelica_metatype _oAllIndex = NULL;
  tmp1 = mmc_unbox_integer(_i);
  _oAllIndex = omc_SimCodeUtil_dimsToAllIndexes2(threadData, tmp1, _iIndex, _iAllIndex);
  /* skip box _oAllIndex; list<list<#Integer>> */
  return _oAllIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_dimsToAllIndexes1(threadData_t *threadData, modelica_metatype _inDims)
{
  modelica_metatype _oAllIndex = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oAllIndex has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inDims;
    {
      modelica_metatype _dims = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _indxes = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dims has no default value.
      // _rest has no default value.
      // _indxes has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          _dims = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_map(threadData, _dims, boxvar_List_create);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmp4_1);
          tmpMeta9 = MMC_CDR(tmp4_1);
          _dims = tmpMeta8;
          _rest = tmpMeta9;
          /* Pattern matching succeeded */
          _indxes = omc_SimCodeUtil_dimsToAllIndexes1(threadData, _rest);
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_List_fold1(threadData, _dims, boxvar_SimCodeUtil_dimsToAllIndexes2, _indxes, tmpMeta10);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oAllIndex = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oAllIndex;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_dimsToAllIndexes(threadData_t *threadData, modelica_metatype _inDims)
{
  modelica_metatype _outIndexes = NULL;
  modelica_metatype _ilst = NULL;
  modelica_metatype _lstlst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outIndexes has no default value.
  // _ilst has no default value.
  // _lstlst has no default value.
  _ilst = omc_Expression_dimensionsSizes(threadData, _inDims);

  _lstlst = omc_List_map(threadData, _ilst, boxvar_List_intRange);

  _outIndexes = omc_SimCodeUtil_dimsToAllIndexes1(threadData, _lstlst);
  _return: OMC_LABEL_UNUSED
  return _outIndexes;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_fixNonlinearResidualIndices(threadData_t *threadData, modelica_metatype _inSysts)
{
  modelica_metatype _outSysts = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _index;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSysts = tmpMeta1;
  _index = ((modelica_integer) 0);
  {
    modelica_metatype _syst;
    for (tmpMeta2 = _inSysts; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _syst = MMC_CAR(tmpMeta2);
      { /* match expression */
        modelica_metatype tmp6_1;
        tmp6_1 = _syst;
        {
          volatile mmc_switch_type tmp6;
          int tmp7;
          tmp6 = 0;
          for (; tmp6 < 2; tmp6++) {
            switch (MMC_SWITCH_CAST(tmp6)) {
            case 0: {
              modelica_metatype tmpMeta8;
              if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,0,5) == 0) goto tmp5_end;
              
              /* Pattern matching succeeded */
              tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(7));
              memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_syst), 7*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[3] = mmc_mk_integer(_index);
              _syst = tmpMeta8;

              _index = ((modelica_integer) 1) + _index;
              tmpMeta3 = _syst;
              goto tmp5_done;
            }
            case 1: {
              
              /* Pattern matching succeeded */
              tmpMeta3 = _syst;
              goto tmp5_done;
            }
            }
            goto tmp5_end;
            tmp5_end: ;
          }
          goto goto_4;
          goto_4:;
          MMC_THROW_INTERNAL();
          goto tmp5_done;
          tmp5_done:;
        }
      }
      _syst = tmpMeta3;

      tmpMeta9 = mmc_mk_cons(_syst, _outSysts);
      _outSysts = tmpMeta9;
    }
  }

  _outSysts = listReverse(_outSysts);
  _return: OMC_LABEL_UNUSED
  return _outSysts;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createNonlinearResidualEquations(threadData_t *threadData, modelica_metatype _eqs, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype __omcQ_24in_5Ftempvars, modelica_metatype _funcTree, modelica_metatype *out_idx_tpl, modelica_metatype *out_tempvars)
{
  modelica_metatype _eqSystems = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _idx_tpl = NULL;
  modelica_metatype _tempvars = NULL;
  modelica_integer _eq_idx;
  modelica_integer _res_idx;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqSystems = tmpMeta1;
  _idx_tpl = __omcQ_24in_5Fidx_5Ftpl;
  _tempvars = __omcQ_24in_5Ftempvars;
  // _eq_idx has no default value.
  // _res_idx has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta74;
          /* Pattern matching succeeded */
          {
            modelica_metatype _eq;
            for (tmpMeta6 = listReverse(_eqs); !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
            {
              _eq = MMC_CAR(tmpMeta6);
              /* Pattern-matching assignment */
              tmpMeta7 = _idx_tpl;
              tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
              tmp9 = mmc_unbox_integer(tmpMeta8);
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
              tmp11 = mmc_unbox_integer(tmpMeta10);
              _eq_idx = tmp9  /* pattern as ty=Integer */;
              _res_idx = tmp11  /* pattern as ty=Integer */;

              { /* match expression */
                modelica_metatype tmp15_1;
                tmp15_1 = _eq;
                {
                  modelica_metatype _res_exp = NULL;
                  modelica_metatype _e1 = NULL;
                  modelica_metatype _e2 = NULL;
                  modelica_metatype _e = NULL;
                  modelica_metatype _lhse = NULL;
                  modelica_metatype _explst = NULL;
                  modelica_metatype _explst1 = NULL;
                  modelica_metatype _eqSystlst = NULL;
                  modelica_metatype _ds = NULL;
                  modelica_metatype _left = NULL;
                  modelica_metatype _algStatements = NULL;
                  modelica_metatype _source = NULL;
                  modelica_metatype _exptl = NULL;
                  modelica_metatype _crefs = NULL;
                  modelica_metatype _crefstmp = NULL;
                  modelica_metatype _repl = NULL;
                  modelica_metatype _ty = NULL;
                  modelica_metatype _crefExpand = NULL;
                  modelica_metatype _eqAttr = NULL;
                  modelica_metatype _ifEq = NULL;
                  modelica_metatype _resEqs = NULL;
                  volatile mmc_switch_type tmp15;
                  int tmp16;
                  // _res_exp has no default value.
                  // _e1 has no default value.
                  // _e2 has no default value.
                  // _e has no default value.
                  // _lhse has no default value.
                  // _explst has no default value.
                  // _explst1 has no default value.
                  // _eqSystlst has no default value.
                  // _ds has no default value.
                  // _left has no default value.
                  // _algStatements has no default value.
                  // _source has no default value.
                  // _exptl has no default value.
                  // _crefs has no default value.
                  // _crefstmp has no default value.
                  // _repl has no default value.
                  // _ty has no default value.
                  // _crefExpand has no default value.
                  // _eqAttr has no default value.
                  // _ifEq has no default value.
                  // _resEqs has no default value.
                  tmp15 = 0;
                  for (; tmp15 < 7; tmp15++) {
                    switch (MMC_SWITCH_CAST(tmp15)) {
                    case 0: {
                      modelica_metatype tmpMeta17;
                      modelica_metatype tmpMeta18;
                      modelica_metatype tmpMeta19;
                      modelica_metatype tmpMeta20;
                      modelica_metatype tmpMeta21;
                      modelica_metatype tmpMeta22;
                      modelica_metatype tmpMeta23;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,0,4) == 0) goto tmp14_end;
                      tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 2));
                      tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 4));
                      tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 5));
                      _e1 = tmpMeta17;
                      _e2 = tmpMeta18;
                      _source = tmpMeta19;
                      _eqAttr = tmpMeta20;
                      /* Pattern matching succeeded */
                      _res_exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

                      _res_exp = omc_Expression_replaceDerOpInExp(threadData, _res_exp);

                      tmpMeta21 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(((modelica_integer) 1) + _res_idx));
                      _idx_tpl = tmpMeta21;
                      tmpMeta23 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx), _res_exp, _source, _eqAttr);
                      tmpMeta22 = mmc_mk_cons(tmpMeta23, _eqSystems);
                      tmpMeta12 = tmpMeta22;
                      goto tmp14_done;
                    }
                    case 1: {
                      modelica_metatype tmpMeta24;
                      modelica_metatype tmpMeta25;
                      modelica_metatype tmpMeta26;
                      modelica_metatype tmpMeta27;
                      modelica_metatype tmpMeta28;
                      modelica_metatype tmpMeta29;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,3,3) == 0) goto tmp14_end;
                      tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 2));
                      tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 4));
                      _e = tmpMeta24;
                      _source = tmpMeta25;
                      _eqAttr = tmpMeta26;
                      /* Pattern matching succeeded */
                      _res_exp = omc_ExpressionSimplify_simplify(threadData, _e, NULL);

                      _res_exp = omc_Expression_replaceDerOpInExp(threadData, _res_exp);

                      tmpMeta27 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(((modelica_integer) 1) + _res_idx));
                      _idx_tpl = tmpMeta27;
                      tmpMeta29 = mmc_mk_box6(3, &SimCode_SimEqSystem_SES__RESIDUAL__desc, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx), _res_exp, _source, _eqAttr);
                      tmpMeta28 = mmc_mk_cons(tmpMeta29, _eqSystems);
                      tmpMeta12 = tmpMeta28;
                      goto tmp14_done;
                    }
                    case 2: {
                      modelica_metatype tmpMeta30;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,7,5) == 0) goto tmp14_end;
                      
                      _ifEq = tmp15_1;
                      /* Pattern matching succeeded */
                      _resEqs = omc_BackendEquation_equationToScalarResidualForm(threadData, _ifEq, _funcTree);

                      tmpMeta30 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) -1) + _eq_idx), mmc_mk_integer(_res_idx));
                      _eqSystlst = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _resEqs, tmpMeta30, _tempvars, _funcTree ,&_idx_tpl ,&_tempvars);
                      tmpMeta12 = _eqSystlst;
                      goto tmp14_done;
                    }
                    case 3: {
                      modelica_metatype tmpMeta31;
                      modelica_metatype tmpMeta32;
                      modelica_metatype tmpMeta33;
                      modelica_metatype tmpMeta34;
                      modelica_metatype tmpMeta35;
                      modelica_metatype tmpMeta36;
                      modelica_metatype tmpMeta37;
                      modelica_metatype tmpMeta38;
                      modelica_metatype tmpMeta39;
                      modelica_metatype tmpMeta40;
                      modelica_integer tmp41;
                      modelica_metatype tmpMeta42;
                      modelica_integer tmp43;
                      modelica_metatype tmpMeta44;
                      modelica_metatype tmpMeta45;
                      modelica_metatype tmpMeta46;
                      modelica_metatype tmpMeta47;
                      modelica_metatype tmpMeta48;
                      modelica_metatype tmpMeta49;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,1,6) == 0) goto tmp14_end;
                      tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 2));
                      tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 4));
                      tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 5));
                      tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 6));
                      
                      _ds = tmpMeta31;
                      _e1 = tmpMeta32;
                      _e2 = tmpMeta33;
                      _source = tmpMeta34;
                      _eqAttr = tmpMeta35;
                      /* Pattern matching succeeded */
                      _ty = omc_Expression_typeof(threadData, _e1);

                      tmpMeta36 = stringAppend(_OMC_LIT560,intString(_eq_idx));
                      tmpMeta37 = MMC_REFSTRUCTLIT(mmc_nil);
                      _left = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta36, _ty, tmpMeta37);

                      tmpMeta38 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _left, _ty);
                      _lhse = tmpMeta38;

                      _res_exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

                      _res_exp = omc_Expression_replaceDerOpInExp(threadData, _res_exp);

                      _crefstmp = omc_ComponentReference_expandCref(threadData, _left, 0 /* false */);

                      _explst1 = omc_List_map(threadData, _crefstmp, boxvar_Expression_crefExp);

                      /* Pattern-matching tuple assignment */
                      tmpMeta44 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
                      tmpMeta45 = MMC_REFSTRUCTLIT(mmc_nil);
                      tmpMeta46 = omc_List_map2Fold(threadData, _explst1, boxvar_SimCodeUtil_makeSES__RESIDUAL, _source, _eqAttr, tmpMeta44, tmpMeta45, &tmpMeta39);
                      _eqSystlst = tmpMeta46;
                      tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 1));
                      tmp41 = mmc_unbox_integer(tmpMeta40);
                      tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
                      tmp43 = mmc_unbox_integer(tmpMeta42);
                      _eq_idx = tmp41  /* pattern as ty=Integer */;
                      _res_idx = tmp43  /* pattern as ty=Integer */;

                      tmpMeta48 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_eq_idx), _lhse, _res_exp, _source, _eqAttr);
                      tmpMeta47 = mmc_mk_cons(tmpMeta48, _eqSystlst);
                      _eqSystlst = tmpMeta47;

                      _tempvars = omc_SimCodeUtil_createArrayTempVar(threadData, _left, _ds, _explst1, _tempvars);

                      tmpMeta49 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(_res_idx));
                      _idx_tpl = tmpMeta49;
                      tmpMeta12 = listAppend(_eqSystlst, _eqSystems);
                      goto tmp14_done;
                    }
                    case 4: {
                      modelica_metatype tmpMeta50;
                      modelica_metatype tmpMeta51;
                      modelica_metatype tmpMeta52;
                      modelica_metatype tmpMeta53;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,6,5) == 0) goto tmp14_end;
                      tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 4));
                      tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 5));
                      tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 6));
                      _e1 = tmpMeta50;
                      _e2 = tmpMeta51;
                      _source = tmpMeta52;
                      _eqAttr = tmpMeta53;
                      /* Pattern matching succeeded */
                      _e1 = omc_ExpressionSimplify_simplify(threadData, _e1, NULL);

                      _e1 = omc_Expression_replaceDerOpInExp(threadData, _e1);

                      _e2 = omc_ExpressionSimplify_simplify(threadData, _e2, NULL);

                      _e2 = omc_Expression_replaceDerOpInExp(threadData, _e2);

                      _eqSystlst = omc_SimCodeUtil_createNonlinearResidualEquationsComplex(threadData, _e1, _e2, _source, _eqAttr, _idx_tpl, _tempvars ,&_idx_tpl ,&_tempvars);
                      tmpMeta12 = listAppend(_eqSystlst, _eqSystems);
                      goto tmp14_done;
                    }
                    case 5: {
                      modelica_metatype tmpMeta54;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,5,4) == 0) goto tmp14_end;
                      tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      
                      /* Pattern matching succeeded */
                      omc_Error_addSourceMessage(threadData, _OMC_LIT752, _OMC_LIT756, omc_BackendEquation_equationInfo(threadData, _eq));
                      goto goto_13;
                      goto tmp14_done;
                    }
                    case 6: {
                      modelica_metatype tmpMeta55;
                      modelica_metatype tmpMeta56;
                      modelica_metatype tmpMeta57;
                      modelica_metatype tmpMeta58;
                      modelica_metatype tmpMeta59;
                      modelica_metatype tmpMeta60;
                      modelica_metatype tmpMeta61;
                      modelica_metatype tmpMeta62;
                      modelica_metatype tmpMeta63;
                      modelica_metatype tmpMeta64;
                      modelica_integer tmp65;
                      modelica_metatype tmpMeta66;
                      modelica_integer tmp67;
                      modelica_metatype tmpMeta68;
                      modelica_metatype tmpMeta69;
                      modelica_metatype tmpMeta70;
                      modelica_metatype tmpMeta71;
                      modelica_metatype tmpMeta72;
                      modelica_metatype tmpMeta73;
                      if (mmc__uniontype__metarecord__typedef__equal(tmp15_1,4,5) == 0) goto tmp14_end;
                      tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 3));
                      tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
                      tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 4));
                      tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 5));
                      tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp15_1), 6));
                      _algStatements = tmpMeta56;
                      _source = tmpMeta57;
                      _crefExpand = tmpMeta58;
                      _eqAttr = tmpMeta59;
                      /* Pattern matching succeeded */
                      tmpMeta60 = mmc_mk_box2(3, &DAE_Algorithm_ALGORITHM__STMTS__desc, _algStatements);
                      _crefs = omc_CheckModel_checkAndGetAlgorithmOutputs(threadData, tmpMeta60, _source, _crefExpand);

                      tmpMeta61 = MMC_REFSTRUCTLIT(mmc_nil);
                      _crefstmp = omc_SimCodeUtil_createTmpCrefs(threadData, _crefs, _eq_idx, tmpMeta61, omc_BackendVarTransform_emptyReplacements(threadData) ,&_repl);

                      _explst = omc_List_map(threadData, _crefs, boxvar_Expression_crefExp);

                      _explst = omc_List_map(threadData, _explst, boxvar_Expression_replaceDerOpInExp);

                      tmpMeta62 = MMC_REFSTRUCTLIT(mmc_nil);
                      _algStatements = omc_BackendVarTransform_replaceStatementLst(threadData, _algStatements, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreOperator), tmpMeta62, 0 /* false */, NULL);

                      _explst1 = omc_List_map(threadData, _crefstmp, boxvar_Expression_crefExp);

                      _explst1 = omc_List_map(threadData, _explst1, boxvar_Expression_replaceDerOpInExp);

                      _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, _explst1, _tempvars);

                      _exptl = omc_List_zip(threadData, _explst, _explst1);

                      /* Pattern-matching tuple assignment */
                      tmpMeta68 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
                      tmpMeta69 = MMC_REFSTRUCTLIT(mmc_nil);
                      tmpMeta70 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta68, tmpMeta69, &tmpMeta63);
                      _eqSystlst = tmpMeta70;
                      tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 1));
                      tmp65 = mmc_unbox_integer(tmpMeta64);
                      tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
                      tmp67 = mmc_unbox_integer(tmpMeta66);
                      _eq_idx = tmp65  /* pattern as ty=Integer */;
                      _res_idx = tmp67  /* pattern as ty=Integer */;

                      tmpMeta72 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), _algStatements, _eqAttr);
                      tmpMeta71 = mmc_mk_cons(tmpMeta72, _eqSystlst);
                      _eqSystlst = tmpMeta71;

                      tmpMeta73 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(_res_idx));
                      _idx_tpl = tmpMeta73;
                      tmpMeta12 = listAppend(_eqSystlst, _eqSystems);
                      goto tmp14_done;
                    }
                    }
                    goto tmp14_end;
                    tmp14_end: ;
                  }
                  goto goto_13;
                  goto_13:;
                  goto goto_2;
                  goto tmp14_done;
                  tmp14_done:;
                }
              }
              _eqSystems = tmpMeta12;
            }
          }
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT208, _OMC_LIT758);

          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_idx_tpl) { *out_idx_tpl = _idx_tpl; }
  if (out_tempvars) { *out_tempvars = _tempvars; }
  return _eqSystems;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTempVars(threadData_t *threadData, modelica_metatype _varLst, modelica_metatype _inCrefPrefix, modelica_metatype _itempvars)
{
  modelica_metatype _otempvars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _otempvars has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _varLst;
    {
      modelica_metatype _rest = NULL;
      modelica_metatype _ttmpvars = NULL;
      modelica_string _name = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _arraycref = NULL;
      modelica_metatype _numArrayElement = NULL;
      modelica_metatype _crlst = NULL;
      modelica_metatype _var = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _ttmpvars has no default value.
      // _name has no default value.
      // _ty has no default value.
      // _cr has no default value.
      // _arraycref has no default value.
      // _numArrayElement has no default value.
      // _crlst has no default value.
      // _var has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,9,4) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,1) == 0) goto tmp3_end;
          
          _name = tmpMeta8;
          _ty = tmpMeta9;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReference_crefPrependIdent(threadData, _inCrefPrefix, _name, tmpMeta11, _ty);
          /* Tail recursive call */
          _varLst = _rest;
          _inCrefPrefix = _cr;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 4));
          
          _name = tmpMeta14;
          _ty = tmpMeta15;
          _rest = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReference_crefPrependIdent(threadData, _inCrefPrefix, _name, tmpMeta16, _ty);

          /* Pattern-matching assignment */
          tmpMeta17 = omc_ComponentReference_expandCref(threadData, _cr, 1 /* true */);
          if (listEmpty(tmpMeta17)) goto goto_2;
          tmpMeta18 = MMC_CAR(tmpMeta17);
          tmpMeta19 = MMC_CDR(tmpMeta17);
          _cr = tmpMeta18;
          _crlst = tmpMeta19;

          _arraycref = omc_ComponentReference_crefStripSubs(threadData, _cr);

          _numArrayElement = omc_List_map(threadData, omc_ComponentReferenceBasics_crefDims(threadData, _cr), boxvar_ExpressionBasics_dimensionString);

          _ty = omc_ComponentReference_crefTypeFull(threadData, _cr);

          if(omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData)))
          {
            tmpMeta20 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_some(_arraycref), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta20;
          }
          else
          {
            tmpMeta21 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_some(_arraycref), _OMC_LIT88, _OMC_LIT92, _OMC_LIT626, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta21;
          }

          tmpMeta22 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
          _ttmpvars = tmpMeta22;

          {
            modelica_metatype _cr;
            for (tmpMeta23 = _crlst; !listEmpty(tmpMeta23); tmpMeta23=MMC_CDR(tmpMeta23))
            {
              _cr = MMC_CAR(tmpMeta23);
              _ty = omc_ComponentReference_crefTypeFull(threadData, _cr);

              if(omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData)))
              {
                tmpMeta24 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
                _var = tmpMeta24;
              }
              else
              {
                tmpMeta25 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_none(), _OMC_LIT88, _OMC_LIT92, _OMC_LIT626, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
                _var = tmpMeta25;
              }

              tmpMeta26 = mmc_mk_cons(_var, _ttmpvars);
              _ttmpvars = tmpMeta26;
            }
          }

          _ttmpvars = listReverseInPlace(_ttmpvars);

          _ttmpvars = listAppend(_itempvars, _ttmpvars);
          /* Tail recursive call */
          _varLst = _rest;
          _itempvars = _ttmpvars;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _otempvars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _otempvars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTempVarsforCrefs(threadData_t *threadData, modelica_metatype _inTmpCrefsLst, modelica_metatype _itempvars)
{
  modelica_metatype _otempvars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _otempvars has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inTmpCrefsLst;
    {
      modelica_metatype _rest = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _arrayCref = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _numArrayElement = NULL;
      modelica_metatype _inst_dims = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _expl has no default value.
      // _ty has no default value.
      // _cr has no default value.
      // _var has no default value.
      // _arrayCref has no default value.
      // _tempvars has no default value.
      // _numArrayElement has no default value.
      // _inst_dims has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,16,3) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          _expl = tmpMeta8;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, _expl, _itempvars);
          /* Tail recursive call */
          _inTmpCrefsLst = _rest;
          _itempvars = _tempvars;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,19,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          _expl = tmpMeta11;
          _rest = tmpMeta10;
          /* Pattern matching succeeded */
          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, _expl, _itempvars);
          /* Tail recursive call */
          _inTmpCrefsLst = _rest;
          _itempvars = _tempvars;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          _cr = tmpMeta14;
          _ty = tmpMeta15;
          _rest = tmpMeta13;
          /* Pattern matching succeeded */
          _arrayCref = omc_ComponentReference_getArrayCref(threadData, _cr);

          _inst_dims = omc_ComponentReferenceBasics_crefDims(threadData, _cr);

          _numArrayElement = omc_List_map(threadData, _inst_dims, boxvar_ExpressionBasics_dimensionString);

          if(omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData)))
          {
            tmpMeta16 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), _arrayCref, _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta16;
          }
          else
          {
            tmpMeta17 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), _arrayCref, _OMC_LIT88, _OMC_LIT92, _OMC_LIT626, mmc_mk_none(), mmc_mk_none(), _numArrayElement, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta17;
          }
          tmpMeta18 = mmc_mk_cons(_var, _itempvars);
          /* Tail recursive call */
          _inTmpCrefsLst = _rest;
          _itempvars = tmpMeta18;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _otempvars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _otempvars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createArrayTempVar(threadData_t *threadData, modelica_metatype _name, modelica_metatype _dims, modelica_metatype _inTmpCrefsLst, modelica_metatype _itempvars)
{
  modelica_metatype _otempvars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _otempvars has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inTmpCrefsLst;
    {
      modelica_metatype _rest = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _var = NULL;
      modelica_metatype _slst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _tempvars has no default value.
      // _ty has no default value.
      // _cr has no default value.
      // _var has no default value.
      // _slst has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          _cr = tmpMeta8;
          _ty = tmpMeta9;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _slst = omc_List_map(threadData, _dims, boxvar_intString);

          if(omc_FMI_isFMIVersion20(threadData, omc_FMI_getFMIVersionString(threadData)))
          {
            tmpMeta10 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_some(_name), _OMC_LIT88, _OMC_LIT92, _OMC_LIT94, mmc_mk_none(), mmc_mk_none(), _slst, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta10;
          }
          else
          {
            tmpMeta11 = mmc_mk_box(32, 3, &SimCodeVar_SimVar_SIMVAR__desc, _cr, _OMC_LIT87, _OMC_LIT31, _OMC_LIT31, _OMC_LIT31, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_boolean(0 /* false */), _ty, mmc_mk_boolean(0 /* false */), mmc_mk_some(_name), _OMC_LIT88, _OMC_LIT92, _OMC_LIT626, mmc_mk_none(), mmc_mk_none(), _slst, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(1 /* true */), _OMC_LIT212, mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_boolean(0 /* false */), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_some(_cr), mmc_mk_boolean(0 /* false */));
            _var = tmpMeta11;
          }

          tmpMeta12 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, _rest, tmpMeta12);
          tmpMeta1 = omc_List_append__reverse(threadData, _tempvars, _itempvars);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _otempvars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _otempvars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inCrefPrefix, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype _callCrefs, modelica_metatype __omcQ_24in_5FlhsExpLstRes, modelica_metatype __omcQ_24in_5FrhsExpLstRes, modelica_metatype __omcQ_24in_5FlhsExpLstAss, modelica_metatype __omcQ_24in_5FrhsExpLstAss, modelica_metatype *out_outCrefExp, modelica_metatype *out_lhsExpLstRes, modelica_metatype *out_rhsExpLstRes, modelica_metatype *out_lhsExpLstAss, modelica_metatype *out_rhsExpLstAss)
{
  modelica_metatype _eqCrefs = NULL;
  modelica_metatype _outCrefExp = NULL;
  modelica_metatype _lhsExpLstRes = NULL;
  modelica_metatype _rhsExpLstRes = NULL;
  modelica_metatype _lhsExpLstAss = NULL;
  modelica_metatype _rhsExpLstAss = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqCrefs = __omcQ_24in_5FeqCrefs;
  // _outCrefExp has no default value.
  _lhsExpLstRes = __omcQ_24in_5FlhsExpLstRes;
  _rhsExpLstRes = __omcQ_24in_5FrhsExpLstRes;
  _lhsExpLstAss = __omcQ_24in_5FlhsExpLstAss;
  _rhsExpLstAss = __omcQ_24in_5FrhsExpLstAss;
  { /* match expression */
    modelica_metatype tmp8_1;
    tmp8_1 = _inExp;
    {
      modelica_string _name = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _c1 = NULL;
      modelica_metatype _crlist = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _tmp_exp = NULL;
      modelica_metatype _tmp_lhsExpLstRes = NULL;
      modelica_metatype tmpMeta3;
      modelica_metatype _tmp_rhsExpLstRes = NULL;
      modelica_metatype tmpMeta4;
      modelica_metatype _tmp_lhsExpLstAss = NULL;
      modelica_metatype tmpMeta5;
      modelica_metatype _tmp_rhsExpLstAss = NULL;
      modelica_metatype tmpMeta6;
      modelica_boolean _isEqCref;
      modelica_boolean _createTmpVar;
      volatile mmc_switch_type tmp8;
      int tmp9;
      // _name has no default value.
      // _ty has no default value.
      // _cr has no default value.
      // _c1 has no default value.
      // _crlist has no default value.
      // _e has no default value.
      // _exp has no default value.
      // _tmp_exp has no default value.
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmp_lhsExpLstRes = tmpMeta3;
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmp_rhsExpLstRes = tmpMeta4;
      tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmp_lhsExpLstAss = tmpMeta5;
      tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
      _tmp_rhsExpLstAss = tmpMeta6;
      // _isEqCref has no default value.
      _createTmpVar = 0 /* false */;
      tmp8 = 0;
      for (; tmp8 < 4; tmp8++) {
        switch (MMC_SWITCH_CAST(tmp8)) {
        case 0: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp8_1,6,2) == 0) goto tmp7_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,0) == 0) goto tmp7_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inExp;
          goto tmp7_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp8_1,6,2) == 0) goto tmp7_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 2));
          
          _cr = tmpMeta11;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isArrayType(threadData, omc_ComponentReference_crefTypeFull(threadData, _cr))) goto tmp7_end;
          _crlist = omc_ComponentReference_expandCref(threadData, _cr, 1 /* true */);

          {
            modelica_metatype _c;
            for (tmpMeta12 = _crlist; !listEmpty(tmpMeta12); tmpMeta12=MMC_CDR(tmpMeta12))
            {
              _c = MMC_CAR(tmpMeta12);
              _name = omc_ComponentReference_crefModelicaStr(threadData, _c);

              _ty = omc_ComponentReference_crefTypeFull(threadData, _c);

              _c1 = omc_ComponentReference_crefPrependIdent(threadData, _inCrefPrefix, _name, omc_ComponentReferenceBasics_crefSubs(threadData, _c), _ty);

              _tmp_exp = omc_Expression_makeCrefExp(threadData, _c1, _ty);

              _exp = omc_Expression_makeCrefExp(threadData, _c, _ty);

              _isEqCref = omc_List_isMemberOnTrue(threadData, _c, _eqCrefs, boxvar_ComponentReferenceBasics_crefEqual);

              if(_isEqCref)
              {
                tmpMeta13 = mmc_mk_cons(_exp, _tmp_lhsExpLstAss);
                _tmp_lhsExpLstAss = tmpMeta13;

                tmpMeta14 = mmc_mk_cons(_tmp_exp, _tmp_rhsExpLstAss);
                _tmp_rhsExpLstAss = tmpMeta14;

                _eqCrefs = omc_List_deleteMemberOnTrue(threadData, _c, _eqCrefs, boxvar_ComponentReferenceBasics_crefEqual, NULL);
              }
              else
              {
                tmpMeta15 = mmc_mk_cons(_tmp_exp, _tmp_lhsExpLstRes);
                _tmp_lhsExpLstRes = tmpMeta15;

                tmpMeta16 = mmc_mk_cons(_exp, _tmp_rhsExpLstRes);
                _tmp_rhsExpLstRes = tmpMeta16;
              }

              _createTmpVar = (_createTmpVar || (!_isEqCref));
            }
          }

          if(_createTmpVar)
          {
            _name = omc_ComponentReference_crefModelicaStr(threadData, _cr);

            _ty = omc_ComponentReference_crefTypeFull(threadData, _cr);

            _cr = omc_ComponentReference_crefPrependIdent(threadData, _inCrefPrefix, _name, omc_ComponentReferenceBasics_crefSubs(threadData, _cr), _ty);

            _e = omc_Expression_makeCrefExp(threadData, _cr, _ty);

            _lhsExpLstAss = listAppend(_tmp_lhsExpLstAss, _lhsExpLstAss);

            _rhsExpLstAss = listAppend(_tmp_rhsExpLstAss, _rhsExpLstAss);

            _lhsExpLstRes = listAppend(_tmp_lhsExpLstRes, _lhsExpLstRes);

            _rhsExpLstRes = listAppend(_tmp_rhsExpLstRes, _rhsExpLstRes);
          }
          else
          {
            _e = _inExp;
          }
          tmpMeta1 = _e;
          goto tmp7_done;
        }
        case 2: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp8_1,6,2) == 0) goto tmp7_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 2));
          
          _cr = tmpMeta18;
          /* Pattern matching succeeded */
          if(((!omc_List_isMemberOnTrue(threadData, _cr, _eqCrefs, boxvar_ComponentReferenceBasics_crefEqual)) || omc_List_isMemberOnTrue(threadData, _cr, _callCrefs, boxvar_ComponentReferenceBasics_crefEqual)))
          {
            _name = omc_ComponentReference_crefModelicaStr(threadData, _cr);

            _ty = omc_ComponentReference_crefTypeFull(threadData, _cr);

            _cr = omc_ComponentReference_crefPrependIdent(threadData, _inCrefPrefix, _name, omc_ComponentReferenceBasics_crefSubs(threadData, _cr), _ty);

            _e = omc_Expression_makeCrefExp(threadData, _cr, _ty);

            tmpMeta19 = mmc_mk_cons(_e, _lhsExpLstRes);
            _lhsExpLstRes = tmpMeta19;

            tmpMeta20 = mmc_mk_cons(_inExp, _rhsExpLstRes);
            _rhsExpLstRes = tmpMeta20;
          }
          else
          {
            _e = _inExp;

            _eqCrefs = omc_List_deleteMemberOnTrue(threadData, _cr, _eqCrefs, boxvar_ComponentReferenceBasics_crefEqual, NULL);
          }
          tmpMeta1 = _e;
          goto tmp7_done;
        }
        case 3: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          
          /* Pattern matching succeeded */
          tmpMeta21 = stringAppend(_OMC_LIT759,omc_ExpressionBasics_printExpStr(threadData, _inExp));
          tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT48);
          fputs(MMC_STRINGDATA(tmpMeta22),stdout);
          goto goto_2;
          goto tmp7_done;
        }
        }
        goto tmp7_end;
        tmp7_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp7_done;
      tmp7_done:;
    }
  }
  _outCrefExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_outCrefExp) { *out_outCrefExp = _outCrefExp; }
  if (out_lhsExpLstRes) { *out_lhsExpLstRes = _lhsExpLstRes; }
  if (out_rhsExpLstRes) { *out_rhsExpLstRes = _rhsExpLstRes; }
  if (out_lhsExpLstAss) { *out_lhsExpLstAss = _lhsExpLstAss; }
  if (out_rhsExpLstAss) { *out_rhsExpLstAss = _rhsExpLstAss; }
  return _eqCrefs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys(threadData_t *threadData, modelica_metatype _inExpLst, modelica_metatype _crPrefix, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype _callCrefs, modelica_metatype __omcQ_24in_5FlhsExpLstRes, modelica_metatype __omcQ_24in_5FrhsExpLstRes, modelica_metatype __omcQ_24in_5FlhsExpLstAss, modelica_metatype __omcQ_24in_5FrhsExpLstAss, modelica_metatype *out_outExpList, modelica_metatype *out_lhsExpLstRes, modelica_metatype *out_rhsExpLstRes, modelica_metatype *out_lhsExpLstAss, modelica_metatype *out_rhsExpLstAss)
{
  modelica_metatype _eqCrefs = NULL;
  modelica_metatype _outExpList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _lhsExpLstRes = NULL;
  modelica_metatype _rhsExpLstRes = NULL;
  modelica_metatype _lhsExpLstAss = NULL;
  modelica_metatype _rhsExpLstAss = NULL;
  modelica_metatype _newExp = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqCrefs = __omcQ_24in_5FeqCrefs;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outExpList = tmpMeta1;
  _lhsExpLstRes = __omcQ_24in_5FlhsExpLstRes;
  _rhsExpLstRes = __omcQ_24in_5FrhsExpLstRes;
  _lhsExpLstAss = __omcQ_24in_5FlhsExpLstAss;
  _rhsExpLstAss = __omcQ_24in_5FrhsExpLstAss;
  // _newExp has no default value.
  {
    modelica_metatype _e;
    for (tmpMeta2 = _inExpLst; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _e = MMC_CAR(tmpMeta2);
      _eqCrefs = omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys__work(threadData, _e, _crPrefix, _eqCrefs, _callCrefs, _lhsExpLstRes, _rhsExpLstRes, _lhsExpLstAss, _rhsExpLstAss ,&_newExp ,&_lhsExpLstRes ,&_rhsExpLstRes ,&_lhsExpLstAss ,&_rhsExpLstAss);

      tmpMeta3 = mmc_mk_cons(_newExp, _outExpList);
      _outExpList = tmpMeta3;
    }
  }

  _outExpList = listReverseInPlace(_outExpList);
  _return: OMC_LABEL_UNUSED
  if (out_outExpList) { *out_outExpList = _outExpList; }
  if (out_lhsExpLstRes) { *out_lhsExpLstRes = _lhsExpLstRes; }
  if (out_rhsExpLstRes) { *out_rhsExpLstRes = _rhsExpLstRes; }
  if (out_lhsExpLstAss) { *out_lhsExpLstAss = _lhsExpLstAss; }
  if (out_rhsExpLstAss) { *out_rhsExpLstAss = _rhsExpLstAss; }
  return _eqCrefs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_eqCrefs)
{
  modelica_metatype _equations_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _eqCrefs = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  _eqCrefs = __omcQ_24in_5FeqCrefs;
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inExp;
    tmp4_2 = _inExp1;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _callCrefs = NULL;
      modelica_metatype _stms = NULL;
      modelica_metatype _tp = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _callExps = NULL;
      modelica_metatype _crexplst = NULL;
      modelica_metatype _lhsExpLstRes = NULL;
      modelica_metatype _rhsExpLstRes = NULL;
      modelica_metatype _lhsExpLstAss = NULL;
      modelica_metatype _rhsExpLstAss = NULL;
      modelica_metatype _simeqn_complex = NULL;
      modelica_metatype _eqSystlst = NULL;
      modelica_metatype _eqSystlst_simpAss = NULL;
      modelica_metatype _exptl = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _path = NULL;
      modelica_string _ident = NULL;
      modelica_metatype _tempvars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _callCrefs has no default value.
      // _stms has no default value.
      // _tp has no default value.
      // _expl has no default value.
      // _callExps has no default value.
      // _crexplst has no default value.
      // _lhsExpLstRes has no default value.
      // _rhsExpLstRes has no default value.
      // _lhsExpLstAss has no default value.
      // _rhsExpLstAss has no default value.
      // _simeqn_complex has no default value.
      // _eqSystlst has no default value.
      // _eqSystlst_simpAss has no default value.
      // _exptl has no default value.
      // _uniqueEqIndex has no default value.
      // _path has no default value.
      // _ident has no default value.
      // _tempvars has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,13,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _expl = tmpMeta6;
          _path = tmpMeta7;
          _callExps = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          omc_Expression_traverseExpList(threadData, _callExps, boxvar_Expression_traversingComponentRefFinder, tmpMeta9 ,&_callCrefs);

          _tp = omc_Expression_typeof(threadData, _inExp);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta10 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta11 = stringAppend(tmpMeta10,intString(_iuniqueEqIndex));
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta11, _tp, tmpMeta12);

          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
          _eqCrefs = omc_SimCodeUtil_createTmpCrefExpsForComplexEqnSys(threadData, _expl, _cr, _eqCrefs, _callCrefs, tmpMeta13, tmpMeta14, tmpMeta15, tmpMeta16 ,&_crexplst ,&_lhsExpLstRes ,&_rhsExpLstRes ,&_lhsExpLstAss ,&_rhsExpLstAss);

          tmpMeta17 = mmc_mk_box5(4, &DAE_Statement_STMT__TUPLE__ASSIGN__desc, _tp, _crexplst, _inExp1, _source);
          _stms = tmpMeta17;

          tmpMeta18 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta19 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), tmpMeta18, _eqAttr);
          _simeqn_complex = tmpMeta19;

          _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

          _exptl = omc_List_zip(threadData, _lhsExpLstAss, _rhsExpLstAss);

          /* Pattern-matching tuple assignment */
          tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta23 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__SIMPLE__ASSIGN, _source, _eqAttr, mmc_mk_integer(_uniqueEqIndex), tmpMeta22, &tmpMeta20);
          _eqSystlst_simpAss = tmpMeta23;
          tmp21 = mmc_unbox_integer(tmpMeta20);
          _uniqueEqIndex = tmp21  /* pattern as ty=Integer */;

          _exptl = omc_List_zip(threadData, _rhsExpLstRes, _lhsExpLstRes);

          /* Pattern-matching tuple assignment */
          tmpMeta27 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
          tmpMeta28 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta29 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta27, tmpMeta28, &tmpMeta24);
          _eqSystlst = tmpMeta29;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          _uniqueEqIndex = tmp26  /* pattern as ty=Integer */;

          tmpMeta30 = mmc_mk_cons(_simeqn_complex, listAppend(_eqSystlst_simpAss, _eqSystlst));
          _eqSystlst = tmpMeta30;

          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, listReverse(_rhsExpLstAss), _itempvars);

          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, listReverse(_lhsExpLstRes), _tempvars);
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_eqCrefs) { *out_eqCrefs = _eqCrefs; }
  return _equations_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype __omcQ_24in_5FeqCrefs, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_eqCrefs)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations_ = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations_ = omc_SimCodeUtil_createNonlinearResidualEquationsSingleComplex(threadData, _inExp, _inExp1, _source, _eqAttr, tmp1, _itempvars, __omcQ_24in_5FeqCrefs, &_ouniqueEqIndex, out_otempvars, out_eqCrefs);
  /* skip box _equations_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  /* skip box _eqCrefs; list<DAE.ComponentRef> */
  return _equations_;
}

static modelica_metatype closure26_Expression_expandExpression(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandExpression(thData, inExp, expandRecord);
}static modelica_metatype closure27_Expression_expandExpression(threadData_t *thData, modelica_metatype closure, modelica_metatype inExp)
{
  modelica_metatype expandRecord = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_expandExpression(thData, inExp, expandRecord);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createNonlinearResidualEquationsComplex(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inExp1, modelica_metatype _source, modelica_metatype _eqAttr, modelica_metatype __omcQ_24in_5Fidx_5Ftpl, modelica_metatype __omcQ_24in_5Ftempvars, modelica_metatype *out_idx_tpl, modelica_metatype *out_tempvars)
{
  modelica_metatype _equations_ = NULL;
  modelica_metatype _idx_tpl = NULL;
  modelica_metatype _tempvars = NULL;
  modelica_integer _eq_idx;
  modelica_integer _res_idx;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations_ has no default value.
  _idx_tpl = __omcQ_24in_5Fidx_5Ftpl;
  _tempvars = __omcQ_24in_5Ftempvars;
  // _eq_idx has no default value.
  // _res_idx has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _idx_tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _eq_idx = tmp3  /* pattern as ty=Integer */;
  _res_idx = tmp5  /* pattern as ty=Integer */;

  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp9_1;volatile modelica_metatype tmp9_2;
    tmp9_1 = _inExp;
    tmp9_2 = _inExp1;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _crtmp = NULL;
      modelica_metatype _crlst = NULL;
      modelica_metatype _crlstlst = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _e1_1 = NULL;
      modelica_metatype _e2_1 = NULL;
      modelica_metatype _etmp = NULL;
      modelica_metatype _stms = NULL;
      modelica_metatype _tp = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _crexplst = NULL;
      modelica_metatype _varLst = NULL;
      modelica_metatype _e1lst = NULL;
      modelica_metatype _e2lst = NULL;
      modelica_metatype _simeqn_complex = NULL;
      modelica_metatype _eqSystlst = NULL;
      modelica_metatype _exptl = NULL;
      modelica_metatype _path = NULL;
      modelica_metatype _rpath = NULL;
      modelica_string _ident = NULL;
      modelica_string _s = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      volatile mmc_switch_type tmp9;
      int tmp10;
      // _cr has no default value.
      // _crtmp has no default value.
      // _crlst has no default value.
      // _crlstlst has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _e1_1 has no default value.
      // _e2_1 has no default value.
      // _etmp has no default value.
      // _stms has no default value.
      // _tp has no default value.
      // _expl has no default value.
      // _crexplst has no default value.
      // _varLst has no default value.
      // _e1lst has no default value.
      // _e2lst has no default value.
      // _simeqn_complex has no default value.
      // _eqSystlst has no default value.
      // _exptl has no default value.
      // _path has no default value.
      // _rpath has no default value.
      // _ident has no default value.
      // _s has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      tmp9 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp8_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp9 < 10; tmp9++) {
        switch (MMC_SWITCH_CAST(tmp9)) {
        case 0: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_1,20,2) == 0) goto tmp8_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 3));
          
          _e1 = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = omc_SimCodeUtil_createNonlinearResidualEquationsComplex(threadData, _e1, _inExp1, _source, _eqAttr, _idx_tpl, _tempvars, &tmpMeta[0+1], &tmpMeta[0+2]);
          goto tmp8_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_2,20,2) == 0) goto tmp8_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 3));
          
          _e2 = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = omc_SimCodeUtil_createNonlinearResidualEquationsComplex(threadData, _inExp, _e2, _source, _eqAttr, _idx_tpl, _tempvars, &tmpMeta[0+1], &tmpMeta[0+2]);
          goto tmp8_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_1,6,2) == 0) goto tmp8_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 2));
          
          _cr = tmpMeta13;
          /* Pattern matching succeeded */
          _e2_1 = omc_Expression_extendArrExp(threadData, _inExp1, 0 /* false */, NULL);

          /* Pattern-matching assignment */
          tmpMeta14 = omc_Expression_typeof(threadData, _inExp);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,9,4) == 0) goto goto_7;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,3,1) == 0) goto goto_7;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          _tp = tmpMeta14;
          _path = tmpMeta16;
          _varLst = tmpMeta17;

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta18 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta19 = stringAppend(tmpMeta18,intString(_eq_idx));
          tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
          _crtmp = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta19, _tp, tmpMeta20);

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _crtmp, _tempvars);

          _e1lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr);

          _e2lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _crtmp);

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta26 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta28 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta26, tmpMeta27, &tmpMeta21);
          _eqSystlst = tmpMeta28;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          _eq_idx = tmp23  /* pattern as ty=Integer */;
          _res_idx = tmp25  /* pattern as ty=Integer */;

          _etmp = omc_Expression_crefExp(threadData, _crtmp);

          tmpMeta29 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _etmp, _e2_1, _source);
          _stms = tmpMeta29;

          tmpMeta31 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta32 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta31, _eqAttr);
          tmpMeta30 = mmc_mk_cons(tmpMeta32, _eqSystlst);
          _eqSystlst = tmpMeta30;
          tmpMeta33 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta33;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 3: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_integer tmp44;
          modelica_metatype tmpMeta45;
          modelica_integer tmp46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_2,6,2) == 0) goto tmp8_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 2));
          
          _cr = tmpMeta34;
          /* Pattern matching succeeded */
          _e1_1 = omc_Expression_extendArrExp(threadData, _inExp, 0 /* false */, NULL);

          /* Pattern-matching assignment */
          tmpMeta35 = omc_Expression_typeof(threadData, _inExp1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,9,4) == 0) goto goto_7;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta36,3,1) == 0) goto goto_7;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 2));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 3));
          _tp = tmpMeta35;
          _path = tmpMeta37;
          _varLst = tmpMeta38;

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta39 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta40 = stringAppend(tmpMeta39,intString(_eq_idx));
          tmpMeta41 = MMC_REFSTRUCTLIT(mmc_nil);
          _crtmp = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta40, _tp, tmpMeta41);

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _crtmp, _tempvars);

          _e1lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr);

          _e2lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _crtmp);

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta47 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta48 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta49 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta47, tmpMeta48, &tmpMeta42);
          _eqSystlst = tmpMeta49;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 1));
          tmp44 = mmc_unbox_integer(tmpMeta43);
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          tmp46 = mmc_unbox_integer(tmpMeta45);
          _eq_idx = tmp44  /* pattern as ty=Integer */;
          _res_idx = tmp46  /* pattern as ty=Integer */;

          _etmp = omc_Expression_crefExp(threadData, _crtmp);

          tmpMeta50 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _etmp, _e1_1, _source);
          _stms = tmpMeta50;

          tmpMeta52 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta53 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta52, _eqAttr);
          tmpMeta51 = mmc_mk_cons(tmpMeta53, _eqSystlst);
          _eqSystlst = tmpMeta51;
          tmpMeta54 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta54;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 4: {
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_boolean tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_integer tmp72;
          modelica_metatype tmpMeta73;
          modelica_integer tmp74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_1,13,3) == 0) goto tmp8_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 2));
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 3));
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 4));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,9,4) == 0) goto tmp8_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta59,3,1) == 0) goto tmp8_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta59), 2));
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 3));
          
          _path = tmpMeta55;
          _e2lst = tmpMeta56;
          _tp = tmpMeta58;
          _rpath = tmpMeta60;
          _varLst = tmpMeta61;
          tmp9 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp62 = omc_AbsynUtil_pathEqual(threadData, _path, _rpath);
          if (1 /* true */ != tmp62) goto goto_7;

          _e2_1 = omc_Expression_extendArrExp(threadData, _inExp1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta63 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta64 = stringAppend(tmpMeta63,intString(_eq_idx));
          tmpMeta65 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta64, _tp, tmpMeta65);

          _e1_1 = omc_Expression_crefToExp(threadData, _cr);

          tmpMeta66 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e1_1, _e2_1, _source);
          _stms = tmpMeta66;

          tmpMeta67 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta68 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta67, _eqAttr);
          _simeqn_complex = tmpMeta68;

          _eq_idx = ((modelica_integer) 1) + _eq_idx;

          _e1lst = omc_Expression_expandExpression(threadData, _e1_1, 1 /* true */);

          tmpMeta69 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _e2lst = omc_List_mapFlat(threadData, _e2lst, (modelica_fnptr) mmc_mk_box2(0,closure26_Expression_expandExpression,tmpMeta69));

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta75 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta76 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta77 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta75, tmpMeta76, &tmpMeta70);
          _eqSystlst = tmpMeta77;
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 1));
          tmp72 = mmc_unbox_integer(tmpMeta71);
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 2));
          tmp74 = mmc_unbox_integer(tmpMeta73);
          _eq_idx = tmp72  /* pattern as ty=Integer */;
          _res_idx = tmp74  /* pattern as ty=Integer */;

          tmpMeta78 = mmc_mk_cons(_simeqn_complex, _eqSystlst);
          _eqSystlst = tmpMeta78;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr, _tempvars);
          tmpMeta79 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta79;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 5: {
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_integer tmp93;
          modelica_metatype tmpMeta94;
          modelica_integer tmp95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_1,14,4) == 0) goto tmp8_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 2));
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 3));
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 5));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta82,9,4) == 0) goto tmp8_end;
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta82), 3));
          
          _path = tmpMeta80;
          _e2lst = tmpMeta81;
          _tp = tmpMeta82;
          _varLst = tmpMeta83;
          /* Pattern matching succeeded */
          _e2_1 = omc_Expression_extendArrExp(threadData, _inExp1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta84 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta85 = stringAppend(tmpMeta84,intString(_eq_idx));
          tmpMeta86 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta85, _tp, tmpMeta86);

          _e1_1 = omc_Expression_crefToExp(threadData, _cr);

          tmpMeta87 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e1_1, _e2_1, _source);
          _stms = tmpMeta87;

          tmpMeta88 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta89 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta88, _eqAttr);
          _simeqn_complex = tmpMeta89;

          _eq_idx = ((modelica_integer) 1) + _eq_idx;

          _e1lst = omc_Expression_expandExpression(threadData, _e1_1, 1 /* true */);

          tmpMeta90 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
          _e2lst = omc_List_mapFlat(threadData, _e2lst, (modelica_fnptr) mmc_mk_box2(0,closure27_Expression_expandExpression,tmpMeta90));

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta96 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta97 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta98 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta96, tmpMeta97, &tmpMeta91);
          _eqSystlst = tmpMeta98;
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 1));
          tmp93 = mmc_unbox_integer(tmpMeta92);
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 2));
          tmp95 = mmc_unbox_integer(tmpMeta94);
          _eq_idx = tmp93  /* pattern as ty=Integer */;
          _res_idx = tmp95  /* pattern as ty=Integer */;

          tmpMeta99 = mmc_mk_cons(_simeqn_complex, _eqSystlst);
          _eqSystlst = tmpMeta99;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr, _tempvars);
          tmpMeta100 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta100;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 6: {
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_boolean tmp108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_integer tmp117;
          modelica_metatype tmpMeta118;
          modelica_integer tmp119;
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_2,13,3) == 0) goto tmp8_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 2));
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 3));
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 4));
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta103), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta104,9,4) == 0) goto tmp8_end;
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta105,3,1) == 0) goto tmp8_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta105), 2));
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 3));
          
          _path = tmpMeta101;
          _e2lst = tmpMeta102;
          _tp = tmpMeta104;
          _rpath = tmpMeta106;
          _varLst = tmpMeta107;
          tmp9 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp108 = omc_AbsynUtil_pathEqual(threadData, _path, _rpath);
          if (1 /* true */ != tmp108) goto goto_7;

          _e1_1 = omc_Expression_extendArrExp(threadData, _inExp1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta109 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta110 = stringAppend(tmpMeta109,intString(_eq_idx));
          tmpMeta111 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta110, _tp, tmpMeta111);

          _e2_1 = omc_Expression_crefExp(threadData, _cr);

          tmpMeta112 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e2_1, _e1_1, _source);
          _stms = tmpMeta112;

          tmpMeta113 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta114 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta113, _eqAttr);
          _simeqn_complex = tmpMeta114;

          _eq_idx = ((modelica_integer) 1) + _eq_idx;

          _e1lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr);

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta120 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta121 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta122 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta120, tmpMeta121, &tmpMeta115);
          _eqSystlst = tmpMeta122;
          tmpMeta116 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta115), 1));
          tmp117 = mmc_unbox_integer(tmpMeta116);
          tmpMeta118 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta115), 2));
          tmp119 = mmc_unbox_integer(tmpMeta118);
          _eq_idx = tmp117  /* pattern as ty=Integer */;
          _res_idx = tmp119  /* pattern as ty=Integer */;

          tmpMeta123 = mmc_mk_cons(_simeqn_complex, _eqSystlst);
          _eqSystlst = tmpMeta123;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr, _tempvars);
          tmpMeta124 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta124;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 7: {
          modelica_metatype tmpMeta125;
          modelica_metatype tmpMeta126;
          modelica_metatype tmpMeta127;
          modelica_metatype tmpMeta128;
          modelica_metatype tmpMeta129;
          modelica_metatype tmpMeta130;
          modelica_metatype tmpMeta131;
          modelica_metatype tmpMeta132;
          modelica_metatype tmpMeta133;
          modelica_metatype tmpMeta134;
          modelica_metatype tmpMeta135;
          modelica_metatype tmpMeta136;
          modelica_integer tmp137;
          modelica_metatype tmpMeta138;
          modelica_integer tmp139;
          modelica_metatype tmpMeta140;
          modelica_metatype tmpMeta141;
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          modelica_metatype tmpMeta144;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_2,14,4) == 0) goto tmp8_end;
          tmpMeta125 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 2));
          tmpMeta126 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 3));
          tmpMeta127 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 5));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta127,9,4) == 0) goto tmp8_end;
          tmpMeta128 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta127), 3));
          
          _path = tmpMeta125;
          _e2lst = tmpMeta126;
          _tp = tmpMeta127;
          _varLst = tmpMeta128;
          tmp9 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e1_1 = omc_Expression_extendArrExp(threadData, _inExp1, 0 /* false */, NULL);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta129 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta130 = stringAppend(tmpMeta129,intString(_eq_idx));
          tmpMeta131 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta130, _tp, tmpMeta131);

          _e2_1 = omc_Expression_crefExp(threadData, _cr);

          tmpMeta132 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp, _e2_1, _e1_1, _source);
          _stms = tmpMeta132;

          tmpMeta133 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta134 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta133, _eqAttr);
          _simeqn_complex = tmpMeta134;

          _eq_idx = ((modelica_integer) 1) + _eq_idx;

          _e1lst = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr);

          _exptl = omc_List_zip(threadData, _e1lst, _e2lst);

          /* Pattern-matching tuple assignment */
          tmpMeta140 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta141 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta142 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta140, tmpMeta141, &tmpMeta135);
          _eqSystlst = tmpMeta142;
          tmpMeta136 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta135), 1));
          tmp137 = mmc_unbox_integer(tmpMeta136);
          tmpMeta138 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta135), 2));
          tmp139 = mmc_unbox_integer(tmpMeta138);
          _eq_idx = tmp137  /* pattern as ty=Integer */;
          _res_idx = tmp139  /* pattern as ty=Integer */;

          tmpMeta143 = mmc_mk_cons(_simeqn_complex, _eqSystlst);
          _eqSystlst = tmpMeta143;

          _tempvars = omc_SimCodeUtil_createTempVars(threadData, _varLst, _cr, _tempvars);
          tmpMeta144 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta144;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 8: {
          modelica_metatype tmpMeta145;
          modelica_metatype tmpMeta146;
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          modelica_metatype tmpMeta149;
          modelica_metatype tmpMeta150;
          modelica_metatype tmpMeta151;
          modelica_metatype tmpMeta152;
          modelica_metatype tmpMeta153;
          modelica_metatype tmpMeta154;
          modelica_integer tmp155;
          modelica_metatype tmpMeta156;
          modelica_integer tmp157;
          modelica_metatype tmpMeta158;
          modelica_metatype tmpMeta159;
          modelica_metatype tmpMeta160;
          modelica_metatype tmpMeta161;
          modelica_metatype tmpMeta162;
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_1,19,1) == 0) goto tmp8_end;
          tmpMeta145 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp9_2,13,3) == 0) goto tmp8_end;
          tmpMeta146 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp9_2), 2));
          
          _expl = tmpMeta145;
          _path = tmpMeta146;
          /* Pattern matching succeeded */
          _tp = omc_Expression_typeof(threadData, _inExp);

          _ident = omc_AbsynUtil_pathStringUnquoteReplaceDot(threadData, _path, _OMC_LIT566);

          tmpMeta147 = stringAppend(_OMC_LIT560,_ident);
          tmpMeta148 = stringAppend(tmpMeta147,intString(_eq_idx));
          tmpMeta149 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr = omc_ComponentReferenceBasics_makeCrefIdent(threadData, tmpMeta148, _tp, tmpMeta149);

          _crexplst = omc_List_map1(threadData, _expl, boxvar_Expression_generateCrefsExpFromExp, _cr);

          tmpMeta150 = mmc_mk_box5(4, &DAE_Statement_STMT__TUPLE__ASSIGN__desc, _tp, _crexplst, _inExp1, _source);
          _stms = tmpMeta150;

          tmpMeta151 = mmc_mk_cons(_stms, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta152 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_eq_idx), tmpMeta151, _eqAttr);
          _simeqn_complex = tmpMeta152;

          _eq_idx = ((modelica_integer) 1) + _eq_idx;

          _expl = omc_List_filterOnTrue(threadData, _expl, boxvar_Expression_isNotWild);

          _expl = omc_List_flatten(threadData, omc_List_map1(threadData, _expl, boxvar_Expression_generateCrefsExpLstFromExp, mmc_mk_none()));

          _crexplst = omc_List_flatten(threadData, omc_List_map1(threadData, _expl, boxvar_Expression_generateCrefsExpLstFromExp, mmc_mk_some(_cr)));

          _crlst = omc_List_map(threadData, _crexplst, boxvar_Expression_expCref);

          _crlstlst = omc_List_map1(threadData, _crlst, boxvar_ComponentReference_expandCref, mmc_mk_boolean(1 /* true */));

          _crlst = omc_List_flatten(threadData, _crlstlst);

          _crexplst = omc_List_map(threadData, _crlst, boxvar_Expression_crefExp);

          _crlst = omc_List_map(threadData, _expl, boxvar_Expression_expCref);

          _crlstlst = omc_List_map1(threadData, _crlst, boxvar_ComponentReference_expandCref, mmc_mk_boolean(1 /* true */));

          _crlst = omc_List_flatten(threadData, _crlstlst);

          _expl = omc_List_map(threadData, _crlst, boxvar_Expression_crefExp);

          _exptl = omc_List_zip(threadData, _expl, _crexplst);

          /* Pattern-matching tuple assignment */
          tmpMeta158 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta159 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta160 = omc_List_map2Fold(threadData, _exptl, boxvar_SimCodeUtil_makeSES__RESIDUAL1, _source, _eqAttr, tmpMeta158, tmpMeta159, &tmpMeta153);
          _eqSystlst = tmpMeta160;
          tmpMeta154 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta153), 1));
          tmp155 = mmc_unbox_integer(tmpMeta154);
          tmpMeta156 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta153), 2));
          tmp157 = mmc_unbox_integer(tmpMeta156);
          _eq_idx = tmp155  /* pattern as ty=Integer */;
          _res_idx = tmp157  /* pattern as ty=Integer */;

          tmpMeta161 = mmc_mk_cons(_simeqn_complex, _eqSystlst);
          _eqSystlst = tmpMeta161;

          _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, listReverse(_crexplst), _tempvars);
          tmpMeta162 = mmc_mk_box2(0, mmc_mk_integer(_eq_idx), mmc_mk_integer(_res_idx));
          tmpMeta[0+0] = _eqSystlst;
          tmpMeta[0+1] = tmpMeta162;
          tmpMeta[0+2] = _tempvars;
          goto tmp8_done;
        }
        case 9: {
          modelica_metatype tmpMeta163;
          
          /* Pattern matching succeeded */
          _s1 = omc_ExpressionBasics_printExpStr(threadData, _inExp);

          _s2 = omc_ExpressionBasics_printExpStr(threadData, _inExp1);

          tmpMeta163 = mmc_mk_cons(_OMC_LIT760, mmc_mk_cons(_s1, mmc_mk_cons(_OMC_LIT224, mmc_mk_cons(_s2, MMC_REFSTRUCTLIT(mmc_nil)))));
          _s = stringAppendList(tmpMeta163);

          omc_Error_addInternalError(threadData, _s, _OMC_LIT761);
          goto goto_7;
          goto tmp8_done;
        }
        }
        goto tmp8_end;
        tmp8_end: ;
      }
      goto goto_7;
      tmp8_done:
      (void)tmp9;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp8_done2;
      goto_7:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp9 < 10) {
        goto tmp8_top;
      }
      MMC_THROW_INTERNAL();
      tmp8_done2:;
    }
  }
  _equations_ = tmpMeta[0+0];
  _idx_tpl = tmpMeta[0+1];
  _tempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_idx_tpl) { *out_idx_tpl = _idx_tpl; }
  if (out_tempvars) { *out_tempvars = _tempvars; }
  return _equations_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_solveAlgorithmInverse(threadData_t *threadData, modelica_metatype _inStmts, modelica_metatype _inSolveFor)
{
  modelica_metatype _outStmts = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outStmts has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inStmts;
    tmp4_2 = _inSolveFor;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _e11 = NULL;
      modelica_metatype _e12 = NULL;
      modelica_metatype _varexp1 = NULL;
      modelica_metatype _solvedExp1 = NULL;
      modelica_metatype _source1 = NULL;
      modelica_metatype _tp1 = NULL;
      modelica_metatype _v1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e21 = NULL;
      modelica_metatype _e22 = NULL;
      modelica_metatype _varexp2 = NULL;
      modelica_metatype _solvedExp2 = NULL;
      modelica_metatype _source2 = NULL;
      modelica_metatype _tp2 = NULL;
      modelica_metatype _v2 = NULL;
      modelica_metatype _asserts = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _e11 has no default value.
      // _e12 has no default value.
      // _varexp1 has no default value.
      // _solvedExp1 has no default value.
      // _source1 has no default value.
      // _tp1 has no default value.
      // _v1 has no default value.
      // _cr2 has no default value.
      // _e21 has no default value.
      // _e22 has no default value.
      // _varexp2 has no default value.
      // _solvedExp2 has no default value.
      // _source2 has no default value.
      // _tp2 has no default value.
      // _v2 has no default value.
      // _asserts has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_2);
          tmpMeta7 = MMC_CDR(tmp4_2);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_1);
          tmpMeta10 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 5));
          if (!listEmpty(tmpMeta10)) goto tmp3_end;
          _v1 = tmpMeta6;
          _cr1 = tmpMeta8;
          _e11 = tmpMeta11;
          _e12 = tmpMeta12;
          _source1 = tmpMeta13;
          /* Pattern matching succeeded */
          _varexp1 = omc_Expression_crefExp(threadData, _cr1);

          _varexp1 = (omc_BackendVariable_isStateVar(threadData, _v1)?omc_Expression_expDer(threadData, _varexp1):_varexp1);

          _solvedExp1 = omc_ExpressionSolve_solve(threadData, _e11, _e12, _varexp1, mmc_mk_none() ,&_asserts);

          _cr1 = (omc_BackendVariable_isStateVar(threadData, _v1)?omc_ComponentReference_crefPrefixDer(threadData, _cr1):_cr1);

          _source1 = omc_ElementSource_addSymbolicTransformationSolve(threadData, 1 /* true */, _source1, _cr1, _e11, _e12, _solvedExp1, _asserts);

          _tp1 = omc_Expression_typeof(threadData, _varexp1);
          tmpMeta15 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp1, _varexp1, _solvedExp1, _source1);
          tmpMeta14 = mmc_mk_cons(tmpMeta15, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_boolean tmp32;
          modelica_boolean tmp33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta16 = MMC_CAR(tmp4_2);
          tmpMeta17 = MMC_CDR(tmp4_2);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          if (listEmpty(tmpMeta17)) goto tmp3_end;
          tmpMeta19 = MMC_CAR(tmpMeta17);
          tmpMeta20 = MMC_CDR(tmpMeta17);
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          if (!listEmpty(tmpMeta20)) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta22 = MMC_CAR(tmp4_1);
          tmpMeta23 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,0,4) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 3));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 4));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 5));
          if (listEmpty(tmpMeta23)) goto tmp3_end;
          tmpMeta27 = MMC_CAR(tmpMeta23);
          tmpMeta28 = MMC_CDR(tmpMeta23);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,0,4) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 3));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 4));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 5));
          if (!listEmpty(tmpMeta28)) goto tmp3_end;
          _v1 = tmpMeta16;
          _cr1 = tmpMeta18;
          _v2 = tmpMeta19;
          _cr2 = tmpMeta21;
          _e11 = tmpMeta24;
          _e12 = tmpMeta25;
          _source1 = tmpMeta26;
          _e21 = tmpMeta29;
          _e22 = tmpMeta30;
          _source2 = tmpMeta31;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp32 = omc_Expression_expHasCref(threadData, _e12, _cr2);
          if (0 /* false */ != tmp32) goto goto_2;

          /* Pattern-matching assignment */
          tmp33 = omc_Expression_expHasCref(threadData, _e22, _cr1);
          if (0 /* false */ != tmp33) goto goto_2;

          _varexp1 = omc_Expression_crefExp(threadData, _cr1);

          _varexp1 = (omc_BackendVariable_isStateVar(threadData, _v1)?omc_Expression_expDer(threadData, _varexp1):_varexp1);

          _solvedExp1 = omc_ExpressionSolve_solve(threadData, _e11, _e12, _varexp1, mmc_mk_none() ,&_asserts);

          _cr1 = (omc_BackendVariable_isStateVar(threadData, _v1)?omc_ComponentReference_crefPrefixDer(threadData, _cr1):_cr1);

          _source1 = omc_ElementSource_addSymbolicTransformationSolve(threadData, 1 /* true */, _source1, _cr1, _e11, _e12, _solvedExp1, _asserts);

          _tp1 = omc_Expression_typeof(threadData, _varexp1);

          _varexp2 = omc_Expression_crefExp(threadData, _cr2);

          _varexp2 = (omc_BackendVariable_isStateVar(threadData, _v2)?omc_Expression_expDer(threadData, _varexp2):_varexp2);

          _solvedExp2 = omc_ExpressionSolve_solve(threadData, _e21, _e22, _varexp2, mmc_mk_none() ,&_asserts);

          _cr2 = (omc_BackendVariable_isStateVar(threadData, _v2)?omc_ComponentReference_crefPrefixDer(threadData, _cr2):_cr2);

          _source2 = omc_ElementSource_addSymbolicTransformationSolve(threadData, 1 /* true */, _source2, _cr2, _e21, _e22, _solvedExp2, _asserts);

          _tp2 = omc_Expression_typeof(threadData, _varexp2);
          tmpMeta35 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp1, _varexp1, _solvedExp1, _source1);
          tmpMeta36 = mmc_mk_box5(3, &DAE_Statement_STMT__ASSIGN__desc, _tp2, _varexp2, _solvedExp2, _source2);
          tmpMeta34 = mmc_mk_cons(tmpMeta35, mmc_mk_cons(tmpMeta36, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta1 = tmpMeta34;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outStmts = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outStmts;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_replaceIFBrancheswithoutVar(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outTpl has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inExp;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _crexp = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_boolean _b1;
      modelica_boolean _b2;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _crexp has no default value.
      // _cond has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _b1 has no default value.
      // _b2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_boolean tmp12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _cond = tmpMeta6;
          _e1 = tmpMeta7;
          _e2 = tmpMeta8;
          _crexp = tmpMeta9;
          _exp = tmpMeta10;
          /* Pattern matching succeeded */
          _b1 = omc_Expression_expContains(threadData, _e1, _crexp);

          _e1 = (_b1?_e1:_exp);

          _b2 = omc_Expression_expContains(threadData, _e2, _crexp);

          _e2 = (_b2?_e2:_exp);
          tmp12 = (modelica_boolean)(_b1 && _b2);
          if(tmp12)
          {
            tmpMeta13 = _inExp;
          }
          else
          {
            tmpMeta11 = mmc_mk_box4(15, &DAE_Exp_IFEXP__desc, _cond, _e1, _e2);
            tmpMeta13 = tmpMeta11;
          }
          tmpMeta[0+0] = tmpMeta13;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outExp = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationImpl(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _v, modelica_metatype _vars, modelica_metatype _partitionKind, modelica_metatype _shared, modelica_boolean _skipDiscInAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equation_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[6] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equation_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eqn;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _var = NULL;
      modelica_integer _uniqueEqIndex1;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _algStatements = NULL;
      modelica_metatype _conditions = NULL;
      modelica_metatype _solveCr = NULL;
      modelica_metatype _resEqs = NULL;
      modelica_metatype _varOutput = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _varexp = NULL;
      modelica_metatype _exp_ = NULL;
      modelica_metatype _start = NULL;
      modelica_metatype _cond = NULL;
      modelica_string _iter = NULL;
      modelica_metatype _whenEquation = NULL;
      modelica_metatype _elseWhen = NULL;
      modelica_metatype _oelseWhen = NULL;
      modelica_string _algStr = NULL;
      modelica_string _message = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _asserts = NULL;
      modelica_metatype _elseWhenEquation = NULL;
      modelica_metatype _simEqSys = NULL;
      modelica_metatype _alg = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_boolean _initialCall;
      modelica_metatype _crefExpand = NULL;
      modelica_boolean _homotopySupport;
      modelica_metatype _funcs = NULL;
      modelica_metatype _solveEqns = NULL;
      modelica_metatype _eqSystlst = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _oelseWhenSimEq = NULL;
      modelica_metatype _eqAttr = NULL;
      modelica_boolean _b;
      int tmp4;
      // _cr has no default value.
      // _var has no default value.
      // _uniqueEqIndex1 has no default value.
      // _uniqueEqIndex has no default value.
      // _algStatements has no default value.
      // _conditions has no default value.
      // _solveCr has no default value.
      // _resEqs has no default value.
      // _varOutput has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _varexp has no default value.
      // _exp_ has no default value.
      // _start has no default value.
      // _cond has no default value.
      // _iter has no default value.
      // _whenEquation has no default value.
      // _elseWhen has no default value.
      // _oelseWhen has no default value.
      // _algStr has no default value.
      // _message has no default value.
      // _source has no default value.
      // _asserts has no default value.
      // _elseWhenEquation has no default value.
      // _simEqSys has no default value.
      // _alg has no default value.
      // _tempvars has no default value.
      // _initialCall has no default value.
      // _crefExpand has no default value.
      // _homotopySupport has no default value.
      // _funcs has no default value.
      // _solveEqns has no default value.
      // _eqSystlst has no default value.
      // _eqs has no default value.
      // _whenStmtLst has no default value.
      // _oelseWhenSimEq has no default value.
      // _eqAttr has no default value.
      // _b has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 4: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta5,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _cr = tmpMeta6;
          _e2 = tmpMeta7;
          _source = tmpMeta8;
          _eqAttr = tmpMeta9;
          /* Pattern matching succeeded */
          _varexp = omc_Expression_crefExp(threadData, _cr);

          tmpMeta10 = mmc_mk_box6(8, &SimCode_SimEqSystem_SES__ARRAY__CALL__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _varexp, _e2, _source, _eqAttr);
          _simEqSys = tmpMeta10;
          tmpMeta11 = mmc_mk_cons(_simEqSys, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta11;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_boolean tmp17_c0 __attribute__((unused)) = 0;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          _varexp = tmpMeta12;
          _start = tmpMeta13;
          _cond = tmpMeta14;
          _source = tmpMeta15;
          _eqAttr = tmpMeta16;
          /* Pattern matching succeeded */
          
          
          
          { /* match expression */
            modelica_metatype tmp20_1;
            tmp20_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5)));
            {
              int tmp20;
              {
                switch (MMC_SWITCH_CAST(valueConstructor(tmp20_1))) {
                case 3: {
                  modelica_metatype tmpMeta21;
                  modelica_metatype tmpMeta22;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp20_1,0,4) == 0) goto tmp19_end;
                  tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp20_1), 2));
                  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp20_1), 3));
                  
                  _e1 = tmpMeta21;
                  _e2 = tmpMeta22;
                  /* Pattern matching succeeded */
                  tmp17_c0 = 1 /* true */;
                  tmpMeta[3+1] = _e1;
                  tmpMeta[3+2] = _e2;
                  goto tmp19_done;
                }
                case 4: {
                  modelica_metatype tmpMeta23;
                  modelica_metatype tmpMeta24;
                  if (mmc__uniontype__metarecord__typedef__equal(tmp20_1,1,6) == 0) goto tmp19_end;
                  tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp20_1), 3));
                  tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp20_1), 4));
                  
                  _e1 = tmpMeta23;
                  _e2 = tmpMeta24;
                  /* Pattern matching succeeded */
                  tmp17_c0 = 1 /* true */;
                  tmpMeta[3+1] = _e1;
                  tmpMeta[3+2] = _e2;
                  goto tmp19_done;
                }
                default:
                tmp19_default: OMC_LABEL_UNUSED; {
                  
                  /* Pattern matching succeeded */
                  tmp17_c0 = 0 /* false */;
                  tmpMeta[3+1] = _OMC_LIT265;
                  tmpMeta[3+2] = _OMC_LIT265;
                  goto tmp19_done;
                }
                }
                goto tmp19_end;
                tmp19_end: ;
              }
              goto goto_18;
              goto_18:;
              goto goto_2;
              goto tmp19_done;
              tmp19_done:;
            }
          }
          _b = tmp17_c0;
          _e1 = tmpMeta[3+1];
          _e2 = tmpMeta[3+2];

          /* Pattern-matching assignment */
          tmpMeta25 = _varexp;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,6,2) == 0) goto goto_2;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,1,3) == 0) goto goto_2;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          _iter = tmpMeta27;

          _var = _v;

          tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta31 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _iter, _OMC_LIT762, tmpMeta30);
          tmpMeta32 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, tmpMeta31, _OMC_LIT762);
          tmpMeta33 = mmc_mk_box2(5, &DAE_Subscript_INDEX__desc, tmpMeta32);
          tmpMeta29 = mmc_mk_cons(tmpMeta33, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta28 = MMC_TAGPTR(mmc_alloc_words(20));
          memcpy(MMC_UNTAGPTR(tmpMeta28), MMC_UNTAGPTR(_var), 20*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta28))[2] = omc_ComponentReference_crefApplySubs(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2))), tmpMeta29);
          _var = tmpMeta28;

          if(_b)
          {
            _cr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_var), 2)));

            /* Pattern-matching assignment */
            tmpMeta34 = _shared;
            tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 12));
            _funcs = tmpMeta35;

            { /* matchcontinue expression */
              {
                volatile mmc_switch_type tmp38;
                int tmp39;
                tmp38 = 0;
                MMC_TRY_INTERNAL(mmc_jumper)
                tmp37_top:
                threadData->mmc_jumper = &new_mmc_jumper;
                for (; tmp38 < 2; tmp38++) {
                  switch (MMC_SWITCH_CAST(tmp38)) {
                  case 0: {
                    /* Pattern matching succeeded */
                    _exp_ = omc_ExpressionSolve_solve2(threadData, _e1, _e2, omc_Expression_crefExp(threadData, _cr), mmc_mk_some(_funcs), mmc_mk_some(mmc_mk_integer(_iuniqueEqIndex)), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _shared) ,&_asserts ,&_solveEqns ,&_solveCr);
                    goto tmp37_done;
                  }
                  case 1: {
                    modelica_metatype tmpMeta40;
                    modelica_metatype tmpMeta41;
                    modelica_metatype tmpMeta42;
                    modelica_metatype tmpMeta43;
                    /* Pattern matching succeeded */
                    tmpMeta40 = stringAppend(_OMC_LIT763,omc_BackendDump_equationString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5)))));
                    tmpMeta41 = stringAppend(tmpMeta40,_OMC_LIT562);
                    tmpMeta42 = stringAppend(tmpMeta41,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
                    tmpMeta43 = stringAppend(tmpMeta42,_OMC_LIT169);
                    omc_Error_addInternalError(threadData, tmpMeta43, _OMC_LIT764);

                    goto goto_36;
                    goto tmp37_done;
                  }
                  }
                  goto tmp37_end;
                  tmp37_end: ;
                }
                goto goto_36;
                tmp37_done:
                (void)tmp38;
                MMC_RESTORE_INTERNAL(mmc_jumper);
                goto tmp37_done2;
                goto_36:;
                MMC_CATCH_INTERNAL(mmc_jumper);
                if (++tmp38 < 2) {
                  goto tmp37_top;
                }
                goto goto_2;
                tmp37_done2:;
              }
            }
            ;

            tmpMeta44 = mmc_mk_box9(19, &SimCode_SimEqSystem_SES__FOR__LOOP__desc, mmc_mk_integer(_iuniqueEqIndex), _varexp, _start, _cond, _cr, _exp_, _source, _eqAttr);
            _simEqSys = tmpMeta44;

            _otempvars = _itempvars;
          }
          else
          {
            _resEqs = omc_SimCodeUtil_createEquationImpl(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))), _var, _vars, _partitionKind, _shared, _skipDiscInAlgorithm, _iuniqueEqIndex, _itempvars, _cons ,NULL ,&_otempvars);

            tmpMeta45 = mmc_mk_box8(20, &SimCode_SimEqSystem_SES__FOR__EQUATION__desc, mmc_mk_integer(_iuniqueEqIndex), _varexp, _start, _cond, _resEqs, _source, _eqAttr);
            _simEqSys = tmpMeta45;
          }
          tmpMeta46 = mmc_mk_cons(_simEqSys, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta46;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _otempvars;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _e2 = tmpMeta47;
          _source = tmpMeta48;
          _eqAttr = tmpMeta49;
          /* Pattern matching succeeded */
          _cr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2)));

          _varexp = omc_Expression_crefExp(threadData, _cr);

          _varexp = (omc_BackendVariable_isStateVar(threadData, _v)?omc_Expression_expDer(threadData, _varexp):_varexp);
          tmpMeta51 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_iuniqueEqIndex), _cr, _e2, _source, _eqAttr);
          tmpMeta50 = mmc_mk_cons(tmpMeta51, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta50;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _whenEquation = tmpMeta52;
          _source = tmpMeta53;
          _eqAttr = tmpMeta54;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta55 = _whenEquation;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 3));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 4));
          _cond = tmpMeta56;
          _whenStmtLst = tmpMeta57;
          _oelseWhen = tmpMeta58;

          if(isSome(_oelseWhen))
          {
            /* Pattern-matching assignment */
            tmpMeta59 = _oelseWhen;
            if (optionNone(tmpMeta59)) goto goto_2;
            tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta59), 1));
            _elseWhen = tmpMeta60;

            tmpMeta61 = MMC_REFSTRUCTLIT(mmc_nil);
            _elseWhenEquation = omc_SimCodeUtil_createElseWhenEquation(threadData, _elseWhen, tmpMeta61, ((modelica_integer) 1) + _iuniqueEqIndex, _source, _eqAttr ,&_uniqueEqIndex);

            _oelseWhenSimEq = mmc_mk_some(_elseWhenEquation);
          }
          else
          {
            _uniqueEqIndex = ((modelica_integer) 1) + _iuniqueEqIndex;

            _oelseWhenSimEq = mmc_mk_none();
          }

          _conditions = omc_BackendDAEUtil_getConditionList(threadData, _cond ,&_initialCall);
          tmpMeta63 = mmc_mk_box8(18, &SimCode_SimEqSystem_SES__WHEN__desc, mmc_mk_integer(_iuniqueEqIndex), _conditions, mmc_mk_boolean(_initialCall), _whenStmtLst, _oelseWhenSimEq, _source, _eqAttr);
          tmpMeta62 = mmc_mk_cons(tmpMeta63, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta62;
          tmp1_c1 = ((modelica_integer) 1) + _uniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _e1 = tmpMeta64;
          _e2 = tmpMeta65;
          _source = tmpMeta66;
          _eqAttr = tmpMeta67;
          /* Pattern matching succeeded */
          _cr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_v), 2)));

          _varexp = omc_Expression_crefExp(threadData, _cr);

          _varexp = (omc_BackendVariable_isStateVar(threadData, _v)?omc_Expression_expDer(threadData, _varexp):_varexp);

          /* Pattern-matching assignment */
          tmpMeta68 = _shared;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 12));
          _funcs = tmpMeta69;

          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp72;
              int tmp73;
              tmp72 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp71_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp72 < 2; tmp72++) {
                switch (MMC_SWITCH_CAST(tmp72)) {
                case 0: {
                  modelica_metatype tmpMeta74;
                  modelica_integer tmp75;
                  modelica_metatype tmpMeta76;
                  modelica_metatype tmpMeta77;
                  modelica_metatype tmpMeta78;
                  modelica_metatype tmpMeta79;
                  modelica_metatype tmpMeta80;
                  /* Pattern matching succeeded */
                  _exp_ = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _varexp, mmc_mk_some(_funcs), mmc_mk_some(mmc_mk_integer(_iuniqueEqIndex)), 1 /* true */, omc_BackendDAEUtil_isSimulationDAE(threadData, _shared) ,&_asserts ,&_solveEqns ,&_solveCr);

                  _solveEqns = listReverse(_solveEqns);

                  _solveCr = listReverse(_solveCr);

                  _cr = (omc_BackendVariable_isStateVar(threadData, _v)?omc_ComponentReference_crefPrefixDer(threadData, _cr):_cr);

                  _source = omc_ElementSource_addSymbolicTransformationSolve(threadData, 1 /* true */, _source, _cr, _e1, _e2, _exp_, _asserts);

                  /* Pattern-matching tuple assignment */
                  tmpMeta76 = omc_List_mapFold(threadData, _solveEqns, boxvar_SimCodeUtil_makeSolved, mmc_mk_integer(_iuniqueEqIndex), &tmpMeta74);
                  _eqs = tmpMeta76;
                  tmp75 = mmc_unbox_integer(tmpMeta74);
                  _uniqueEqIndex1 = tmp75  /* pattern as ty=Integer */;

                  if(listEmpty(_cons))
                  {
                    tmpMeta78 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_uniqueEqIndex1), _cr, _exp_, _source, _eqAttr);
                    tmpMeta77 = mmc_mk_cons(tmpMeta78, MMC_REFSTRUCTLIT(mmc_nil));
                    _resEqs = omc_SimCodeUtil_addAssertEqn(threadData, _asserts, tmpMeta77, ((modelica_integer) 1) + _uniqueEqIndex1 ,&_uniqueEqIndex);
                  }
                  else
                  {
                    tmpMeta80 = mmc_mk_box7(7, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__CONSTRAINTS__desc, mmc_mk_integer(_uniqueEqIndex1), _cr, _exp_, _source, _cons, _eqAttr);
                    tmpMeta79 = mmc_mk_cons(tmpMeta80, MMC_REFSTRUCTLIT(mmc_nil));
                    _resEqs = omc_SimCodeUtil_addAssertEqn(threadData, _asserts, tmpMeta79, ((modelica_integer) 1) + _uniqueEqIndex1 ,&_uniqueEqIndex);
                  }

                  _eqSystlst = listAppend(_eqs, _resEqs);

                  _tempvars = omc_SimCodeUtil_createTempVarsforCrefs(threadData, omc_List_map(threadData, _solveCr, boxvar_Expression_crefExp), _itempvars);
                  goto tmp71_done;
                }
                case 1: {
                  modelica_metatype tmpMeta81;
                  modelica_metatype tmpMeta82;
                  modelica_integer tmp83;
                  modelica_metatype tmpMeta84;
                  modelica_metatype tmpMeta85;
                  modelica_metatype tmpMeta86;
                  modelica_metatype tmpMeta87;
                  modelica_metatype tmpMeta88;
                  modelica_integer tmp89;
                  modelica_metatype tmpMeta90;
                  modelica_metatype tmpMeta91;
                  modelica_metatype tmpMeta92;
                  modelica_metatype tmpMeta93;
                  /* Pattern matching succeeded */
                  /* Pattern-matching tuple assignment */
                  tmpMeta85 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta86 = mmc_mk_box2(0, mmc_mk_integer(_iuniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
                  tmpMeta87 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, tmpMeta85, tmpMeta86, _itempvars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), &tmpMeta81, &tmpMeta84);
                  _resEqs = tmpMeta87;
                  tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta81), 1));
                  tmp83 = mmc_unbox_integer(tmpMeta82);
                  _uniqueEqIndex = tmp83  /* pattern as ty=Integer */;
                  _tempvars = tmpMeta84;

                  _resEqs = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _resEqs);

                  _cr = (omc_BackendVariable_isStateVar(threadData, _v)?omc_ComponentReference_crefPrefixDer(threadData, _cr):_cr);

                  /* Pattern-matching tuple assignment, wild first pattern */
                  omc_BackendEquation_traverseExpsOfEquation(threadData, _eqn, boxvar_BackendDAEUtil_containsHomotopyCall, mmc_mk_boolean(0 /* false */), &tmpMeta88);
                  tmp89 = mmc_unbox_integer(tmpMeta88);
                  _homotopySupport = tmp89  /* pattern as ty=Boolean */;

                  tmpMeta91 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
                  tmpMeta92 = mmc_mk_box11(3, &SimCode_NonlinearSystem_NONLINEARSYSTEM__desc, mmc_mk_integer(_uniqueEqIndex), _resEqs, tmpMeta91, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 1)), mmc_mk_none(), mmc_mk_boolean(_homotopySupport), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), omc_SimCodeUtil_partitionKindToClockIndex(threadData, _partitionKind));
                  tmpMeta93 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, tmpMeta92, mmc_mk_none(), _eqAttr);
                  tmpMeta90 = mmc_mk_cons(tmpMeta93, MMC_REFSTRUCTLIT(mmc_nil));
                  _eqSystlst = tmpMeta90;

                  _uniqueEqIndex = ((modelica_integer) 1) + _uniqueEqIndex;
                  goto tmp71_done;
                }
                }
                goto tmp71_end;
                tmp71_end: ;
              }
              goto goto_70;
              tmp71_done:
              (void)tmp72;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp71_done2;
              goto_70:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp72 < 2) {
                goto tmp71_top;
              }
              goto goto_2;
              tmp71_done2:;
            }
          }
          ;
          tmpMeta[0+0] = _eqSystlst;
          tmp1_c1 = _uniqueEqIndex;
          tmpMeta[0+2] = _tempvars;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _alg = tmpMeta94;
          _source = tmpMeta95;
          _crefExpand = tmpMeta96;
          _eqAttr = tmpMeta97;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta98 = omc_CheckModel_checkAndGetAlgorithmOutputs(threadData, _alg, _source, _crefExpand);
          if (listEmpty(tmpMeta98)) goto goto_2;
          tmpMeta99 = MMC_CAR(tmpMeta98);
          tmpMeta100 = MMC_CDR(tmpMeta98);
          if (!listEmpty(tmpMeta100)) goto goto_2;
          _varOutput = tmpMeta99;

          /* Pattern-matching assignment */
          tmpMeta101 = omc_BackendDAEUtil_collateAlgorithm(threadData, _alg, mmc_mk_none());
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta101), 2));
          _algStatements = tmpMeta102;

          if(omc_ComponentReferenceBasics_crefEqualNoStringCompare(threadData, omc_BackendVariable_varCref(threadData, _v), _varOutput))
          {
            if(_skipDiscInAlgorithm)
            {
              _algStatements = omc_BackendDAEUtil_removeDiscreteAssignments(threadData, _algStatements, _vars);
            }
          }
          else
          {
            { /* matchcontinue expression */
              {
                volatile mmc_switch_type tmp105;
                int tmp106;
                tmp105 = 0;
                MMC_TRY_INTERNAL(mmc_jumper)
                tmp104_top:
                threadData->mmc_jumper = &new_mmc_jumper;
                for (; tmp105 < 2; tmp105++) {
                  switch (MMC_SWITCH_CAST(tmp105)) {
                  case 0: {
                    modelica_metatype tmpMeta107;
                    /* Pattern matching succeeded */
                    tmpMeta107 = mmc_mk_cons(_v, MMC_REFSTRUCTLIT(mmc_nil));
                    _algStatements = omc_SimCodeUtil_solveAlgorithmInverse(threadData, _algStatements, tmpMeta107);
                    goto tmp104_done;
                  }
                  case 1: {
                    modelica_metatype tmpMeta108;
                    modelica_metatype tmpMeta109;
                    modelica_metatype tmpMeta110;
                    /* Pattern matching succeeded */
                    tmpMeta109 = mmc_mk_box3(19, &DAE_Element_ALGORITHM__desc, _alg, _source);
                    tmpMeta108 = mmc_mk_cons(tmpMeta109, MMC_REFSTRUCTLIT(mmc_nil));
                    _algStr = omc_DAEDump_dumpAlgorithmsStr(threadData, tmpMeta108);

                    _message = omc_ComponentReferenceBasics_printComponentRefStr(threadData, omc_BackendVariable_varCref(threadData, _v));

                    tmpMeta110 = mmc_mk_cons(_OMC_LIT554, mmc_mk_cons(_message, mmc_mk_cons(_OMC_LIT555, mmc_mk_cons(_algStr, mmc_mk_cons(_OMC_LIT765, MMC_REFSTRUCTLIT(mmc_nil))))));
                    _message = stringAppendList(tmpMeta110);

                    omc_Error_addInternalError(threadData, _message, _OMC_LIT766);

                    goto goto_103;
                    goto tmp104_done;
                  }
                  }
                  goto tmp104_end;
                  tmp104_end: ;
                }
                goto goto_103;
                tmp104_done:
                (void)tmp105;
                MMC_RESTORE_INTERNAL(mmc_jumper);
                goto tmp104_done2;
                goto_103:;
                MMC_CATCH_INTERNAL(mmc_jumper);
                if (++tmp105 < 2) {
                  goto tmp104_top;
                }
                goto goto_2;
                tmp104_done2:;
              }
            }
            ;
          }
          tmpMeta112 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _algStatements, _eqAttr);
          tmpMeta111 = mmc_mk_cons(tmpMeta112, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta111;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          tmpMeta[0+2] = _itempvars;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _equation_ = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _otempvars = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equation_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationImpl(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _v, modelica_metatype _vars, modelica_metatype _partitionKind, modelica_metatype _shared, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equation_ = NULL;
  tmp1 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _equation_ = omc_SimCodeUtil_createEquationImpl(threadData, _eqn, _v, _vars, _partitionKind, _shared, tmp1, tmp2, _itempvars, _cons, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equation_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equation_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquation(threadData_t *threadData, modelica_integer _eqNum, modelica_integer _varNum, modelica_metatype _syst, modelica_metatype _shared, modelica_boolean _skipDiscInAlgorithm, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equation_ = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _eqns = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _v = NULL;
  modelica_metatype _partitionKind = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equation_ has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _vars has no default value.
  // _eqns has no default value.
  // _eqn has no default value.
  // _v has no default value.
  // _partitionKind has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _syst;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 9));
  _vars = tmpMeta2;
  _eqns = tmpMeta3;
  _partitionKind = tmpMeta4;

  _eqn = omc_BackendEquation_get(threadData, _eqns, _eqNum);

  { /* match expression */
    modelica_metatype tmp8_1;
    tmp8_1 = _eqn;
    {
      volatile mmc_switch_type tmp8;
      int tmp9;
      tmp8 = 0;
      for (; tmp8 < 2; tmp8++) {
        switch (MMC_SWITCH_CAST(tmp8)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp8_1,5,4) == 0) goto tmp7_end;
          
          /* Pattern matching succeeded */
          tmpMeta5 = omc_BackendVariable_makeVar(threadData, _OMC_LIT768);
          goto tmp7_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta5 = omc_BackendVariable_getVarAt(threadData, _vars, _varNum);
          goto tmp7_done;
        }
        }
        goto tmp7_end;
        tmp7_end: ;
      }
      goto goto_6;
      goto_6:;
      MMC_THROW_INTERNAL();
      goto tmp7_done;
      tmp7_done:;
    }
  }
  _v = tmpMeta5;

  _equation_ = omc_SimCodeUtil_createEquationImpl(threadData, _eqn, _v, _vars, _partitionKind, _shared, _skipDiscInAlgorithm, _iuniqueEqIndex, _itempvars, _cons ,&_ouniqueEqIndex ,&_otempvars);
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equation_;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquation(threadData_t *threadData, modelica_metatype _eqNum, modelica_metatype _varNum, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equation_ = NULL;
  tmp1 = mmc_unbox_integer(_eqNum);
  tmp2 = mmc_unbox_integer(_varNum);
  tmp3 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp4 = mmc_unbox_integer(_iuniqueEqIndex);
  _equation_ = omc_SimCodeUtil_createEquation(threadData, tmp1, tmp2, _syst, _shared, tmp3, tmp4, _itempvars, _cons, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equation_; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equation_;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_partitionKindToClockIndex(threadData_t *threadData, modelica_metatype _kind)
{
  modelica_metatype _clockIndex = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _clockIndex has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _kind;
    {
      modelica_integer _index;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _index has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          _index = tmp7  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_some(mmc_mk_integer(_index));
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _clockIndex = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _clockIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addAssertEqn(threadData_t *threadData, modelica_metatype _asserts, modelica_metatype _iequations, modelica_integer _iuniqueEqIndex, modelica_integer *out_ouniqueEqIndex)
{
  modelica_metatype _oequations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oequations has no default value.
  // _ouniqueEqIndex has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _asserts;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iequations;
          tmp1_c1 = _iuniqueEqIndex;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_box4(13, &SimCode_SimEqSystem_SES__ALGORITHM__desc, mmc_mk_integer(_iuniqueEqIndex), _asserts, _OMC_LIT535);
          tmpMeta6 = mmc_mk_cons(tmpMeta7, _iequations);
          tmpMeta[0+0] = tmpMeta6;
          tmp1_c1 = ((modelica_integer) 1) + _iuniqueEqIndex;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oequations = tmpMeta[0+0];
  _ouniqueEqIndex = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  return _oequations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_addAssertEqn(threadData_t *threadData, modelica_metatype _asserts, modelica_metatype _iequations, modelica_metatype _iuniqueEqIndex, modelica_metatype *out_ouniqueEqIndex)
{
  modelica_integer tmp1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _oequations = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  _oequations = omc_SimCodeUtil_addAssertEqn(threadData, _asserts, _iequations, tmp1, &_ouniqueEqIndex);
  /* skip box _oequations; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  return _oequations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListIndx(threadData_t *threadData, modelica_metatype _iIntList, modelica_metatype _iMappingArray)
{
  modelica_metatype _oIntList = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oIntList has no default value.
  _oIntList = omc_List_map1r(threadData, _iIntList, boxvar_arrayGet, _iMappingArray);
  _return: OMC_LABEL_UNUSED
  return _oIntList;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListMappingToArray1(threadData_t *threadData, modelica_metatype _iMapping, modelica_metatype _iMappingArray)
{
  modelica_metatype _outMappingArray = NULL;
  modelica_integer _simEqIdx;
  modelica_integer _BackendEqnIdx;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMappingArray has no default value.
  // _simEqIdx has no default value.
  // _BackendEqnIdx has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iMapping;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  _simEqIdx = tmp3  /* pattern as ty=Integer */;
  _BackendEqnIdx = tmp5  /* pattern as ty=Integer */;

  _outMappingArray = arrayUpdate(_iMappingArray, _BackendEqnIdx, mmc_mk_integer(_simEqIdx));
  _return: OMC_LABEL_UNUSED
  return _outMappingArray;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_convertListMappingToArray(threadData_t *threadData, modelica_metatype _iMapping, modelica_integer _numOfBackendEqs)
{
  modelica_metatype _outMapping = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMapping has no default value.
  _outMapping = arrayCreate(_numOfBackendEqs, mmc_mk_integer(((modelica_integer) -1)));

  _outMapping = omc_List_fold(threadData, _iMapping, boxvar_SimCodeUtil_convertListMappingToArray1, _outMapping);
  _return: OMC_LABEL_UNUSED
  return _outMapping;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_convertListMappingToArray(threadData_t *threadData, modelica_metatype _iMapping, modelica_metatype _numOfBackendEqs)
{
  modelica_integer tmp1;
  modelica_metatype _outMapping = NULL;
  tmp1 = mmc_unbox_integer(_numOfBackendEqs);
  _outMapping = omc_SimCodeUtil_convertListMappingToArray(threadData, _iMapping, tmp1);
  /* skip box _outMapping; array<#Integer> */
  return _outMapping;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateZeroCrossEqnIndexHelp(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMappingArray, modelica_metatype _iAccum)
{
  modelica_metatype _ozeroCrossings = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ozeroCrossings has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _izeroCrossings;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _occurEquLst = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _iter = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _occurEquLst has no default value.
      // _rest has no default value.
      // _iter has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = listReverseInPlace(_iAccum);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          _exp = tmpMeta8;
          _occurEquLst = tmpMeta9;
          _iter = tmpMeta10;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _occurEquLst = omc_SimCodeUtil_convertListIndx(threadData, _occurEquLst, _eqBackendSimCodeMappingArray);
          tmpMeta12 = mmc_mk_box5(3, &BackendDAE_ZeroCrossing_ZERO__CROSSING__desc, mmc_mk_integer(((modelica_integer) 0)), _exp, _occurEquLst, _iter);
          tmpMeta11 = mmc_mk_cons(tmpMeta12, _iAccum);
          /* Tail recursive call */
          _izeroCrossings = _rest;
          _iAccum = tmpMeta11;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _ozeroCrossings = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _ozeroCrossings;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateZeroCrossEqnIndex(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMapping, modelica_integer _numEqnsinArray)
{
  modelica_metatype _ozeroCrossings = NULL;
  modelica_metatype _mappingArray = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ozeroCrossings has no default value.
  // _mappingArray has no default value.
  _mappingArray = omc_SimCodeUtil_convertListMappingToArray(threadData, _eqBackendSimCodeMapping, _numEqnsinArray);

  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _ozeroCrossings = omc_SimCodeUtil_updateZeroCrossEqnIndexHelp(threadData, _izeroCrossings, _mappingArray, tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return _ozeroCrossings;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_updateZeroCrossEqnIndex(threadData_t *threadData, modelica_metatype _izeroCrossings, modelica_metatype _eqBackendSimCodeMapping, modelica_metatype _numEqnsinArray)
{
  modelica_integer tmp1;
  modelica_metatype _ozeroCrossings = NULL;
  tmp1 = mmc_unbox_integer(_numEqnsinArray);
  _ozeroCrossings = omc_SimCodeUtil_updateZeroCrossEqnIndex(threadData, _izeroCrossings, _eqBackendSimCodeMapping, tmp1);
  /* skip box _ozeroCrossings; list<BackendDAE.ZeroCrossing> */
  return _ozeroCrossings;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_whenEquationsIndices(threadData_t *threadData, modelica_metatype _eqns)
{
  modelica_metatype _res = NULL;
  modelica_boolean _b;
  modelica_integer _i;
  modelica_integer _size;
  modelica_metatype tmpMeta1;
  modelica_boolean tmp2 = 0;
  modelica_metatype tmpMeta7;
  modelica_boolean tmp8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  // _b has no default value.
  _i = ((modelica_integer) 1);
  // _size has no default value.
  _size = omc_BackendEquation_getNumberOfEquations(threadData, _eqns);

  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _res = tmpMeta1;

  while(1)
  {
    if(!(_i <= _size)) break;
    { /* match expression */
      modelica_metatype tmp5_1;
      tmp5_1 = omc_BackendEquation_get(threadData, _eqns, _i);
      {
        volatile mmc_switch_type tmp5;
        int tmp6;
        tmp5 = 0;
        for (; tmp5 < 2; tmp5++) {
          switch (MMC_SWITCH_CAST(tmp5)) {
          case 0: {
            if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,5,4) == 0) goto tmp4_end;
            
            /* Pattern matching succeeded */
            tmp2 = 1 /* true */;
            goto tmp4_done;
          }
          case 1: {
            
            /* Pattern matching succeeded */
            tmp2 = 0 /* false */;
            goto tmp4_done;
          }
          }
          goto tmp4_end;
          tmp4_end: ;
        }
        goto goto_3;
        goto_3:;
        MMC_THROW_INTERNAL();
        goto tmp4_done;
        tmp4_done:;
      }
    }
    _b = tmp2;

    tmp8 = (modelica_boolean)_b;
    if(tmp8)
    {
      tmpMeta7 = mmc_mk_cons(mmc_mk_integer(_i), _res);
      tmpMeta9 = tmpMeta7;
    }
    else
    {
      tmpMeta9 = _res;
    }
    _res = tmpMeta9;

    _i = ((modelica_integer) 1) + _i;
  }
  _return: OMC_LABEL_UNUSED
  return _res;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_zeroCrossingEquations(threadData_t *threadData, modelica_metatype _inZC)
{
  modelica_metatype _outLst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outLst has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inZC;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _outLst = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outLst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_zeroCrossingsEquations(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared)
{
  modelica_metatype _eqns = NULL;
  modelica_metatype _zeroCrossingLst = NULL;
  modelica_metatype _zcEqns = NULL;
  modelica_metatype _wcEqns = NULL;
  modelica_metatype _orderedEqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqns has no default value.
  // _zeroCrossingLst has no default value.
  // _zcEqns has no default value.
  // _wcEqns has no default value.
  // _orderedEqs has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _syst;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  _orderedEqs = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = _shared;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 13));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 3));
  _zeroCrossingLst = tmpMeta5;

  _zcEqns = omc_List_map(threadData, omc_ZeroCrossings_toList(threadData, _zeroCrossingLst), boxvar_SimCodeUtil_zeroCrossingEquations);

  _wcEqns = omc_SimCodeUtil_whenEquationsIndices(threadData, _orderedEqs);

  tmpMeta6 = mmc_mk_cons(_wcEqns, MMC_REFSTRUCTLIT(mmc_nil));
  _eqns = omc_List_unionList(threadData, listAppend(_zcEqns, tmpMeta6));
  _return: OMC_LABEL_UNUSED
  return _eqns;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_sortSimVarsAndWriteIndex(threadData_t *threadData, modelica_metatype _inSimVar, modelica_metatype _crefToSimVarHT)
{
  modelica_metatype _outSimVar = NULL;
  modelica_metatype _crefs = NULL;
  modelica_metatype _sorted = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSimVar has no default value.
  // _crefs has no default value.
  // _sorted has no default value.
  _crefs = omc_List_map(threadData, _inSimVar, boxvar_SimCodeUtil_getSimVarCompRef);

  _sorted = omc_SimCodeUtil_getSimVars2Crefs(threadData, _crefs, _crefToSimVarHT);

  _sorted = omc_List_sort(threadData, _sorted, boxvar_SimCodeUtil_compareVarIndexGt);

  _outSimVar = omc_SimCodeUtil_rewriteIndex(threadData, _sorted, ((modelica_integer) 0), NULL);
  _return: OMC_LABEL_UNUSED
  return _outSimVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSimCodeDAEModeDataEqns(threadData_t *threadData, modelica_metatype _inOptDaeMode)
{
  modelica_metatype _daeEquations = NULL;
  modelica_metatype _daeModeData = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _daeEquations has no default value.
  // _daeModeData has no default value.
  if(isSome(_inOptDaeMode))
  {
    _daeModeData = omc_Util_getOption(threadData, _inOptDaeMode);

    _daeEquations = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_daeModeData), 2)));
  }
  else
  {
    tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
    _daeEquations = tmpMeta1;
  }
  _return: OMC_LABEL_UNUSED
  return _daeEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsWork(threadData_t *threadData, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comp, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_noDiscEquations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations = NULL;
  modelica_metatype _noDiscEquations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_integer tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations has no default value.
  // _noDiscEquations has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_boolean tmp4_2;modelica_boolean tmp4_3;modelica_metatype tmp4_4;modelica_metatype tmp4_5;modelica_metatype tmp4_6;
    tmp4_1 = _includeWhen;
    tmp4_2 = _skipDiscInZc;
    tmp4_3 = _genDiscrete;
    tmp4_4 = _syst;
    tmp4_5 = _shared;
    tmp4_6 = _comp;
    {
      modelica_integer _index;
      modelica_integer _vindex;
      modelica_integer _uniqueEqIndex;
      modelica_metatype _vars = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqnlst = NULL;
      modelica_metatype _varlst = NULL;
      modelica_metatype _equations1 = NULL;
      modelica_metatype _noDiscEquations1 = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _ei = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _index has no default value.
      // _vindex has no default value.
      // _uniqueEqIndex has no default value.
      // _vars has no default value.
      // _eqns has no default value.
      // _eqnlst has no default value.
      // _varlst has no default value.
      // _equations1 has no default value.
      // _noDiscEquations1 has no default value.
      // _tempvars has no default value.
      // _ei has no default value.
      tmp4 = 0;
      for (; tmp4 < 13; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,0,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          
          _index = tmp7  /* pattern as ty=Integer */;
          _eqns = tmpMeta8;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_BackendEquation_isWhenEquation(threadData, omc_BackendEquation_get(threadData, _eqns, _index))) goto tmp3_end;
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta9;
          tmpMeta[0+1] = tmpMeta10;
          tmp1_c2 = _iuniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,5,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta11;
          tmpMeta[0+1] = tmpMeta12;
          tmp1_c2 = _iuniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (0 /* false */ != tmp4_3) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,0,2) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 3));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          
          _index = tmp14  /* pattern as ty=Integer */;
          _vars = tmpMeta15;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_BackendVariable_isVarDiscrete(threadData, omc_BackendVariable_getVarAt(threadData, _vars, _index))) goto tmp3_end;
          tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta16;
          tmpMeta[0+1] = tmpMeta17;
          tmp1_c2 = _iuniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (0 /* false */ != tmp4_3) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,5,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta18;
          tmpMeta[0+1] = tmpMeta19;
          tmp1_c2 = _iuniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,0,2) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 2));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 3));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          
          _index = tmp21  /* pattern as ty=Integer */;
          _vindex = tmp23  /* pattern as ty=Integer */;
          _vars = tmpMeta24;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_BackendVariable_isVarDiscrete(threadData, omc_BackendVariable_getVarAt(threadData, _vars, _vindex)) && listMember(mmc_mk_integer(_index), omc_SimCodeUtil_zeroCrossingsEquations(threadData, _syst, _shared)))) goto tmp3_end;
          tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta25;
          tmpMeta[0+1] = tmpMeta26;
          tmp1_c2 = _iuniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta27;
          modelica_integer tmp28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,0,2) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 2));
          tmp28 = mmc_unbox_integer(tmpMeta27);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_6), 3));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          
          _index = tmp28  /* pattern as ty=Integer */;
          _vindex = tmp30  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          if(((omc_Flags_isSet(threadData, _OMC_LIT773) || omc_Flags_isSet(threadData, _OMC_LIT776)) && (!listEmpty(_cons))))
          {
            tmpMeta31 = stringAppend(_OMC_LIT769,omc_BackendDump_equationString(threadData, omc_BackendEquation_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), _index)));
            tmpMeta32 = stringAppend(tmpMeta31,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta32),stdout);

            tmpMeta33 = stringAppend(_OMC_LIT770,omc_ExpressionDump_constraintDTlistToString(threadData, _cons, _OMC_LIT48));
            tmpMeta34 = stringAppend(tmpMeta33,_OMC_LIT352);
            fputs(MMC_STRINGDATA(tmpMeta34),stdout);
          }

          _equations1 = omc_SimCodeUtil_createEquation(threadData, _index, _vindex, _syst, _shared, _skipDiscInAlgorithm, _iuniqueEqIndex, _itempvars, _cons ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _equations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,2,2) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          
          _vars = tmpMeta35;
          _eqns = tmpMeta36;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);
          tmpMeta[0+0] = omc_SimCodeUtil_createSingleArrayEqnCode(threadData, _genDiscrete, _eqnlst, _varlst, _iuniqueEqIndex, _itempvars, _shared, &tmpMeta[0+1], &tmp1_c2, &tmpMeta[0+3]);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,3,2) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          
          _vars = tmpMeta37;
          _eqns = tmpMeta38;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleAlgorithmCode(threadData, _eqnlst, _varlst, _skipDiscInAlgorithm, _iuniqueEqIndex, omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 9)))) ,&_uniqueEqIndex);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _equations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _itempvars;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,4,2) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_5), 17));
          
          _vars = tmpMeta39;
          _eqns = tmpMeta40;
          _ei = tmpMeta41;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleComplexEqnCode(threadData, listHead(_eqnlst), _varlst, _iuniqueEqIndex, _itempvars, _ei, _genDiscrete, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 9)))) ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _equations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,5,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          
          _vars = tmpMeta42;
          _eqns = tmpMeta43;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleWhenEqnCode(threadData, listHead(_eqnlst), _varlst, _shared, _iuniqueEqIndex, _itempvars ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _equations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_6,6,2) == 0) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 3));
          
          _vars = tmpMeta44;
          _eqns = tmpMeta45;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, _eqns, _vars ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleIfEqnCode(threadData, listHead(_eqnlst), _varlst, _shared, _genDiscrete, _iuniqueEqIndex, _itempvars ,&_uniqueEqIndex ,&_tempvars);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _equations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta46;
          
          /* Pattern matching succeeded */
          tmpMeta46 = MMC_REFSTRUCTLIT(mmc_nil);
          _equations1 = omc_SimCodeUtil_createOdeSystem(threadData, _genDiscrete, _skipDiscInAlgorithm, _syst, _shared, _comp, _iuniqueEqIndex, _itempvars, ((modelica_integer) 1), tmpMeta46, _OMC_LIT205 ,&_noDiscEquations1 ,&_uniqueEqIndex ,&_tempvars ,NULL ,NULL);
          tmpMeta[0+0] = _equations1;
          tmpMeta[0+1] = _noDiscEquations1;
          tmp1_c2 = _uniqueEqIndex;
          tmpMeta[0+3] = _tempvars;
          goto tmp3_done;
        }
        case 12: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT777, _OMC_LIT778);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _equations = tmpMeta[0+0];
  _noDiscEquations = tmpMeta[0+1];
  _ouniqueEqIndex = tmp1_c2;
  _otempvars = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_noDiscEquations) { *out_noDiscEquations = _noDiscEquations; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsWork(threadData_t *threadData, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comp, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _cons, modelica_metatype *out_noDiscEquations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations = NULL;
  tmp1 = mmc_unbox_integer(_includeWhen);
  tmp2 = mmc_unbox_integer(_skipDiscInZc);
  tmp3 = mmc_unbox_integer(_genDiscrete);
  tmp4 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp5 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations = omc_SimCodeUtil_createEquationsWork(threadData, tmp1, tmp2, tmp3, tmp4, _syst, _shared, _comp, tmp5, _itempvars, _cons, out_noDiscEquations, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations; list<SimCode.SimEqSystem> */
  /* skip box _noDiscEquations; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquations(threadData_t *threadData, modelica_boolean _includeWhen, modelica_boolean _skipDiscInZc, modelica_boolean _genDiscrete, modelica_boolean _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_noDiscEquations, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_metatype _equations = NULL;
  modelica_metatype _noDiscEquations = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _accEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _accNoDiscEquations = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _equations has no default value.
  // _noDiscEquations has no default value.
  _ouniqueEqIndex = _iuniqueEqIndex;
  _otempvars = _itempvars;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _accEquations = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _accNoDiscEquations = tmpMeta2;
  {
    modelica_metatype _comp;
    for (tmpMeta3 = _comps; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _comp = MMC_CAR(tmpMeta3);
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _equations = omc_SimCodeUtil_createEquationsWork(threadData, _includeWhen, _skipDiscInZc, _genDiscrete, _skipDiscInAlgorithm, _syst, _shared, _comp, _ouniqueEqIndex, _otempvars, tmpMeta4 ,&_noDiscEquations ,&_ouniqueEqIndex ,&_otempvars);

      tmpMeta5 = mmc_mk_cons(_equations, _accEquations);
      _accEquations = tmpMeta5;

      tmpMeta6 = mmc_mk_cons(_noDiscEquations, _accNoDiscEquations);
      _accNoDiscEquations = tmpMeta6;
    }
  }

  _equations = omc_List_flattenReverse(threadData, _accEquations);

  _noDiscEquations = omc_List_flattenReverse(threadData, _accNoDiscEquations);
  _return: OMC_LABEL_UNUSED
  if (out_noDiscEquations) { *out_noDiscEquations = _noDiscEquations; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _equations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquations(threadData_t *threadData, modelica_metatype _includeWhen, modelica_metatype _skipDiscInZc, modelica_metatype _genDiscrete, modelica_metatype _skipDiscInAlgorithm, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype *out_noDiscEquations, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _equations = NULL;
  tmp1 = mmc_unbox_integer(_includeWhen);
  tmp2 = mmc_unbox_integer(_skipDiscInZc);
  tmp3 = mmc_unbox_integer(_genDiscrete);
  tmp4 = mmc_unbox_integer(_skipDiscInAlgorithm);
  tmp5 = mmc_unbox_integer(_iuniqueEqIndex);
  _equations = omc_SimCodeUtil_createEquations(threadData, tmp1, tmp2, tmp3, tmp4, _syst, _shared, _comps, tmp5, _itempvars, out_noDiscEquations, &_ouniqueEqIndex, out_otempvars);
  /* skip box _equations; list<SimCode.SimEqSystem> */
  /* skip box _noDiscEquations; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _equations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendSccIdxRange(threadData_t *threadData, modelica_integer _iCurrentIdxStart, modelica_integer _iCurrentIdxStop, modelica_integer _iSccIdx, modelica_metatype _iSccIdc)
{
  modelica_metatype _oSccIdc = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _oSccIdc = _iSccIdc;
  tmp3 = _iCurrentIdxStop; tmp4 = ((modelica_integer) -1); tmp5 = _iCurrentIdxStart;
  if(!(((tmp4 > 0) && (tmp3 > tmp5)) || ((tmp4 < 0) && (tmp3 < tmp5))))
  {
    modelica_integer _i;
    for(_i = _iCurrentIdxStop; in_range_integer(_i, tmp3, tmp5); _i += tmp4)
    {
      tmpMeta2 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_iSccIdx));
      tmpMeta1 = mmc_mk_cons(tmpMeta2, _iSccIdc);
      _oSccIdc = tmpMeta1;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _oSccIdc;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendSccIdxRange(threadData_t *threadData, modelica_metatype _iCurrentIdxStart, modelica_metatype _iCurrentIdxStop, modelica_metatype _iSccIdx, modelica_metatype _iSccIdc)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_metatype _oSccIdc = NULL;
  tmp1 = mmc_unbox_integer(_iCurrentIdxStart);
  tmp2 = mmc_unbox_integer(_iCurrentIdxStop);
  tmp3 = mmc_unbox_integer(_iSccIdx);
  _oSccIdc = omc_SimCodeUtil_appendSccIdxRange(threadData, tmp1, tmp2, tmp3, _iSccIdc);
  /* skip box _oSccIdc; list<tuple<#Integer, #Integer>> */
  return _oSccIdc;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_appendSccIdx(threadData_t *threadData, modelica_integer _iCurrentIdx, modelica_integer _iSccIdx, modelica_metatype _iSccIdc)
{
  modelica_metatype _oSccIdc = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSccIdc has no default value.
  tmpMeta2 = mmc_mk_box2(0, mmc_mk_integer(_iCurrentIdx), mmc_mk_integer(_iSccIdx));
  tmpMeta1 = mmc_mk_cons(tmpMeta2, _iSccIdc);
  _oSccIdc = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oSccIdc;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_appendSccIdx(threadData_t *threadData, modelica_metatype _iCurrentIdx, modelica_metatype _iSccIdx, modelica_metatype _iSccIdc)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _oSccIdc = NULL;
  tmp1 = mmc_unbox_integer(_iCurrentIdx);
  tmp2 = mmc_unbox_integer(_iSccIdx);
  _oSccIdc = omc_SimCodeUtil_appendSccIdx(threadData, tmp1, tmp2, _iSccIdc);
  /* skip box _oSccIdc; list<tuple<#Integer, #Integer>> */
  return _oSccIdc;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystem1(threadData_t *threadData, modelica_metatype _comp, modelica_metatype _inArg, modelica_metatype _clockIndex, modelica_metatype _inFold)
{
  modelica_metatype _outFold = NULL;
  modelica_metatype _stateeqnsmark = NULL;
  modelica_metatype _zceqnsmark = NULL;
  modelica_metatype _syst = NULL;
  modelica_metatype _shared = NULL;
  modelica_integer _uniqueEqIndex;
  modelica_integer _sccIndex;
  modelica_metatype _tempvars = NULL;
  modelica_metatype _eqSccMapping = NULL;
  modelica_metatype _eqBackendSimCodeMapping = NULL;
  modelica_metatype _backendMapping = NULL;
  modelica_metatype _odeEquations = NULL;
  modelica_metatype _algebraicEquations = NULL;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _equationsforZeroCrossings = NULL;
  modelica_metatype _eqsIdx = NULL;
  modelica_metatype _varIdx = NULL;
  modelica_metatype _varlst = NULL;
  modelica_metatype _eqnlst = NULL;
  modelica_boolean _createAlgebraicEquations;
  modelica_boolean _bdynamic;
  modelica_boolean _skip;
  modelica_boolean _debug;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_integer tmp20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFold has no default value.
  // _stateeqnsmark has no default value.
  // _zceqnsmark has no default value.
  // _syst has no default value.
  // _shared has no default value.
  // _uniqueEqIndex has no default value.
  // _sccIndex has no default value.
  // _tempvars has no default value.
  // _eqSccMapping has no default value.
  // _eqBackendSimCodeMapping has no default value.
  // _backendMapping has no default value.
  // _odeEquations has no default value.
  // _algebraicEquations has no default value.
  // _allEquations has no default value.
  // _equationsforZeroCrossings has no default value.
  // _eqsIdx has no default value.
  // _varIdx has no default value.
  // _varlst has no default value.
  // _eqnlst has no default value.
  // _createAlgebraicEquations has no default value.
  // _bdynamic has no default value.
  // _skip has no default value.
  _debug = 0 /* false */;
  /* Pattern-matching assignment */
  tmpMeta1 = _inArg;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  _stateeqnsmark = tmpMeta2;
  _zceqnsmark = tmpMeta3;
  _syst = tmpMeta4;
  _shared = tmpMeta5;
  _createAlgebraicEquations = tmp7  /* pattern as ty=Boolean */;

  /* Pattern-matching assignment */
  tmpMeta8 = _inFold;
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 5));
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 6));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 7));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 8));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 9));
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 10));
  tmp20 = mmc_unbox_integer(tmpMeta19);
  _uniqueEqIndex = tmp10  /* pattern as ty=Integer */;
  _odeEquations = tmpMeta11;
  _algebraicEquations = tmpMeta12;
  _allEquations = tmpMeta13;
  _equationsforZeroCrossings = tmpMeta14;
  _tempvars = tmpMeta15;
  _eqSccMapping = tmpMeta16;
  _eqBackendSimCodeMapping = tmpMeta17;
  _backendMapping = tmpMeta18;
  _sccIndex = tmp20  /* pattern as ty=Integer */;

  _varlst = omc_BackendDAEUtil_getStrongComponentVarsAndEquations(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))) ,&_varIdx ,&_eqnlst ,&_eqsIdx);

  _bdynamic = omc_BackendDAEUtil_blockIsDynamic(threadData, _eqsIdx, _stateeqnsmark);

  _skip = 0 /* false */;

  if(_debug)
  {
    tmpMeta21 = stringAppend(_OMC_LIT779,omc_BackendDump_strongComponentString(threadData, _comp));
    tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT48);
    fputs(MMC_STRINGDATA(tmpMeta22),stdout);

    omc_BackendDump_dumpEquationList(threadData, _eqnlst, _OMC_LIT780);

    omc_BackendDump_dumpVarList(threadData, _varlst, _OMC_LIT781);
  }

  _skip = omc_List_all(threadData, _eqnlst, boxvar_BackendEquation_isWhenEquation);

  _skip = (_skip || omc_List_all(threadData, _varlst, boxvar_BackendVariable_isVarDiscrete));

  { /* match expression */
    modelica_metatype tmp26_1;
    tmp26_1 = _comp;
    {
      modelica_integer _e;
      modelica_integer _index;
      modelica_integer _vindex;
      modelica_integer _firstEqIndex;
      modelica_integer _uniqueEqIndex1;
      modelica_metatype _firstSES = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _equations1 = NULL;
      modelica_metatype _noDiscEquations1 = NULL;
      modelica_string _message = NULL;
      volatile mmc_switch_type tmp26;
      int tmp27;
      // _e has no default value.
      // _index has no default value.
      // _vindex has no default value.
      // _firstEqIndex has no default value.
      // _uniqueEqIndex1 has no default value.
      // _firstSES has no default value.
      // _eqnslst has no default value.
      // _equations1 has no default value.
      // _noDiscEquations1 has no default value.
      // _message has no default value.
      tmp26 = 0;
      for (; tmp26 < 10; tmp26++) {
        switch (MMC_SWITCH_CAST(tmp26)) {
        case 0: {
          modelica_metatype tmpMeta28;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((!(_createAlgebraicEquations || _bdynamic)) || (_skip && (!_createAlgebraicEquations)))) goto tmp25_end;
          tmpMeta28 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(_sccIndex));
          tmpMeta23 = tmpMeta28;
          goto tmp25_done;
        }
        case 1: {
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,0,2) == 0) goto tmp25_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 3));
          tmp32 = mmc_unbox_integer(tmpMeta31);
          _index = tmp30  /* pattern as ty=Integer */;
          _vindex = tmp32  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta33 = MMC_REFSTRUCTLIT(mmc_nil);
          _equations1 = omc_SimCodeUtil_createEquation(threadData, _index, _vindex, _syst, _shared, 0 /* false */, _uniqueEqIndex, _tempvars, tmpMeta33 ,&_uniqueEqIndex1 ,&_tempvars);

          if((!listEmpty(_equations1)))
          {
            _firstSES = listHead(_equations1);

            _firstEqIndex = (omc_SimCodeUtil_isSimEqSys(threadData, _firstSES)?((modelica_integer) -1) + _uniqueEqIndex1:_uniqueEqIndex);

            _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

            _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _index, _eqBackendSimCodeMapping);

            tmpMeta34 = mmc_mk_cons(mmc_mk_integer(_index), MMC_REFSTRUCTLIT(mmc_nil));
            _backendMapping = omc_SimCodeUtil_setEqMapping(threadData, omc_List_intRange2(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1), tmpMeta34, _backendMapping);
          }

          if(omc_BackendEquation_isWhenEquation(threadData, omc_BackendEquation_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), _index)))
          {
            tmpMeta35 = mmc_mk_cons(_equations1, _allEquations);
            _allEquations = tmpMeta35;
          }
          else
          {
            tmpMeta36 = mmc_mk_cons(mmc_mk_integer(_index), MMC_REFSTRUCTLIT(mmc_nil));
            _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta36, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          }
          tmpMeta37 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta37;
          goto tmp25_done;
        }
        case 2: {
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,2,2) == 0) goto tmp25_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          tmp39 = mmc_unbox_integer(tmpMeta38);
          
          _e = tmp39  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleArrayEqnCode(threadData, 1 /* true */, _eqnlst, _varlst, _uniqueEqIndex, _tempvars, _shared ,NULL ,&_uniqueEqIndex1 ,&_tempvars);

          _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

          _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _e, _eqBackendSimCodeMapping);

          tmpMeta40 = mmc_mk_cons(mmc_mk_integer(_e), MMC_REFSTRUCTLIT(mmc_nil));
          _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta40, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          tmpMeta41 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta41;
          goto tmp25_done;
        }
        case 3: {
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,3,2) == 0) goto tmp25_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          tmp43 = mmc_unbox_integer(tmpMeta42);
          
          _e = tmp43  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleAlgorithmCode(threadData, _eqnlst, _varlst, 0 /* false */, _uniqueEqIndex, _clockIndex ,&_uniqueEqIndex1);

          _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

          _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _e, _eqBackendSimCodeMapping);

          tmpMeta44 = mmc_mk_cons(mmc_mk_integer(_e), MMC_REFSTRUCTLIT(mmc_nil));
          _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta44, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          tmpMeta45 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta45;
          goto tmp25_done;
        }
        case 4: {
          modelica_metatype tmpMeta46;
          modelica_integer tmp47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,4,2) == 0) goto tmp25_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          tmp47 = mmc_unbox_integer(tmpMeta46);
          
          _e = tmp47  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varlst ,NULL);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleComplexEqnCode(threadData, listHead(_eqnlst), _varlst, _uniqueEqIndex, _tempvars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 17))), 1 /* true */, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 12))), _clockIndex ,&_uniqueEqIndex1 ,&_tempvars);

          _eqSccMapping = omc_SimCodeUtil_appendSccIdx(threadData, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

          _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _e, _eqBackendSimCodeMapping);

          tmpMeta48 = mmc_mk_cons(mmc_mk_integer(_e), MMC_REFSTRUCTLIT(mmc_nil));
          _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta48, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          tmpMeta49 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta49;
          goto tmp25_done;
        }
        case 5: {
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,5,2) == 0) goto tmp25_end;
          
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varlst ,&_index);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleWhenEqnCode(threadData, listHead(_eqnlst), _varlst, _shared, _uniqueEqIndex, _tempvars ,&_uniqueEqIndex1 ,&_tempvars);

          _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

          _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _index, _eqBackendSimCodeMapping);

          tmpMeta50 = mmc_mk_cons(_equations1, _allEquations);
          _allEquations = tmpMeta50;
          tmpMeta51 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta51;
          goto tmp25_done;
        }
        case 6: {
          modelica_metatype tmpMeta52;
          modelica_integer tmp53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,6,2) == 0) goto tmp25_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          tmp53 = mmc_unbox_integer(tmpMeta52);
          
          _e = tmp53  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendDAETransform_getEquationAndSolvedVar(threadData, _comp, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varlst ,&_index);

          _varlst = omc_List_map(threadData, _varlst, boxvar_BackendVariable_transformXToXd);

          _equations1 = omc_SimCodeUtil_createSingleIfEqnCode(threadData, listHead(_eqnlst), _varlst, _shared, 1 /* true */, _uniqueEqIndex, _tempvars ,&_uniqueEqIndex1 ,&_tempvars);

          _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

          _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _uniqueEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _index, _eqBackendSimCodeMapping);

          tmpMeta54 = mmc_mk_cons(mmc_mk_integer(_e), MMC_REFSTRUCTLIT(mmc_nil));
          _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta54, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          tmpMeta55 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta55;
          goto tmp25_done;
        }
        case 7: {
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_integer tmp59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_integer tmp63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          if (mmc__uniontype__metarecord__typedef__equal(tmp26_1,1,5) == 0) goto tmp25_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 2));
          if (listEmpty(tmpMeta56)) goto tmp25_end;
          tmpMeta57 = MMC_CAR(tmpMeta56);
          tmpMeta58 = MMC_CDR(tmpMeta56);
          tmp59 = mmc_unbox_integer(tmpMeta57);
          if (!listEmpty(tmpMeta58)) goto tmp25_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp26_1), 3));
          if (listEmpty(tmpMeta60)) goto tmp25_end;
          tmpMeta61 = MMC_CAR(tmpMeta60);
          tmpMeta62 = MMC_CDR(tmpMeta60);
          tmp63 = mmc_unbox_integer(tmpMeta61);
          if (!listEmpty(tmpMeta62)) goto tmp25_end;
          
          _index = tmp59  /* pattern as ty=Integer */;
          _vindex = tmp63  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta64 = MMC_REFSTRUCTLIT(mmc_nil);
          _equations1 = omc_SimCodeUtil_createEquation(threadData, _index, _vindex, _syst, _shared, 0 /* false */, _uniqueEqIndex, _tempvars, tmpMeta64 ,&_uniqueEqIndex1 ,&_tempvars);

          if((!listEmpty(_equations1)))
          {
            _firstSES = listHead(_equations1);

            _firstEqIndex = (omc_SimCodeUtil_isSimEqSys(threadData, _firstSES)?((modelica_integer) -1) + _uniqueEqIndex1:_uniqueEqIndex);

            _eqSccMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _sccIndex, _eqSccMapping);

            _eqBackendSimCodeMapping = omc_SimCodeUtil_appendSccIdxRange(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1, _index, _eqBackendSimCodeMapping);

            tmpMeta65 = mmc_mk_cons(mmc_mk_integer(_index), MMC_REFSTRUCTLIT(mmc_nil));
            _backendMapping = omc_SimCodeUtil_setEqMapping(threadData, omc_List_intRange2(threadData, _firstEqIndex, ((modelica_integer) -1) + _uniqueEqIndex1), tmpMeta65, _backendMapping);
          }

          if(omc_BackendEquation_isWhenEquation(threadData, omc_BackendEquation_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), _index)))
          {
            tmpMeta66 = mmc_mk_cons(_equations1, _allEquations);
            _allEquations = tmpMeta66;
          }
          else
          {
            tmpMeta67 = mmc_mk_cons(mmc_mk_integer(_index), MMC_REFSTRUCTLIT(mmc_nil));
            _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _equations1, _stateeqnsmark, _zceqnsmark, tmpMeta67, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          }
          tmpMeta68 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta68;
          goto tmp25_done;
        }
        case 8: {
          modelica_metatype tmpMeta69;
          
          /* Pattern matching succeeded */
          _eqnslst = omc_BackendDAETransform_getEquationAndSolvedVarIndxes(threadData, _comp, NULL);

          omc_SimCodeUtil_createOdeSystem(threadData, _createAlgebraicEquations, 0 /* false */, _syst, _shared, _comp, _uniqueEqIndex, _tempvars, _sccIndex, _eqSccMapping, _backendMapping ,&_noDiscEquations1 ,&_uniqueEqIndex1 ,&_tempvars ,&_eqSccMapping ,&_backendMapping);

          _odeEquations = omc_SimCodeUtil_addEquationsToLists(threadData, _noDiscEquations1, _stateeqnsmark, _zceqnsmark, _eqnslst, _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings ,&_algebraicEquations ,&_allEquations ,&_equationsforZeroCrossings);
          tmpMeta69 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex1), _odeEquations, _algebraicEquations, _allEquations, _equationsforZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(((modelica_integer) 1) + _sccIndex));
          tmpMeta23 = tmpMeta69;
          goto tmp25_done;
        }
        case 9: {
          modelica_metatype tmpMeta70;
          
          /* Pattern matching succeeded */
          tmpMeta70 = stringAppend(_OMC_LIT782,omc_BackendDump_strongComponentString(threadData, _comp));
          _message = tmpMeta70;

          omc_Error_addInternalError(threadData, _message, _OMC_LIT783);
          goto goto_24;
          goto tmp25_done;
        }
        }
        goto tmp25_end;
        tmp25_end: ;
      }
      goto goto_24;
      goto_24:;
      MMC_THROW_INTERNAL();
      goto tmp25_done;
      tmp25_done:;
    }
  }
  _outFold = tmpMeta23;
  _return: OMC_LABEL_UNUSED
  return _outFold;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addEquationsToLists(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _eqsIdx, modelica_metatype _inOdeEquations, modelica_metatype _inAlgebraicEquations, modelica_metatype _inAllEquations, modelica_metatype _inEquationsforZeroCrossings, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings)
{
  modelica_metatype _outOdeEquations = NULL;
  modelica_metatype _outAlgebraicEquations = NULL;
  modelica_metatype _outAllEquations = NULL;
  modelica_metatype _outEquationsforZeroCrossings = NULL;
  modelica_boolean _bdynamic;
  modelica_boolean _bzceqns;
  modelica_metatype tmpMeta1;
  modelica_boolean tmp2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_boolean tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_boolean tmp9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outOdeEquations has no default value.
  // _outAlgebraicEquations has no default value.
  // _outAllEquations has no default value.
  // _outEquationsforZeroCrossings has no default value.
  // _bdynamic has no default value.
  // _bzceqns has no default value.
  _bdynamic = omc_BackendDAEUtil_blockIsDynamic(threadData, _eqsIdx, _stateeqnsmark);

  _bzceqns = omc_BackendDAEUtil_blockIsDynamic(threadData, _eqsIdx, _zceqnsmark);

  tmp2 = (modelica_boolean)_bdynamic;
  if(tmp2)
  {
    tmpMeta1 = mmc_mk_cons(_inEq, _inOdeEquations);
    tmpMeta3 = tmpMeta1;
  }
  else
  {
    tmpMeta3 = _inOdeEquations;
  }
  _outOdeEquations = tmpMeta3;

  tmp5 = (modelica_boolean)(!_bdynamic);
  if(tmp5)
  {
    tmpMeta4 = mmc_mk_cons(_inEq, _inAlgebraicEquations);
    tmpMeta6 = tmpMeta4;
  }
  else
  {
    tmpMeta6 = _inAlgebraicEquations;
  }
  _outAlgebraicEquations = tmpMeta6;

  tmpMeta7 = mmc_mk_cons(_inEq, _inAllEquations);
  _outAllEquations = tmpMeta7;

  tmp9 = (modelica_boolean)_bzceqns;
  if(tmp9)
  {
    tmpMeta8 = mmc_mk_cons(_inEq, _inEquationsforZeroCrossings);
    tmpMeta10 = tmpMeta8;
  }
  else
  {
    tmpMeta10 = _inEquationsforZeroCrossings;
  }
  _outEquationsforZeroCrossings = tmpMeta10;
  _return: OMC_LABEL_UNUSED
  if (out_outAlgebraicEquations) { *out_outAlgebraicEquations = _outAlgebraicEquations; }
  if (out_outAllEquations) { *out_outAllEquations = _outAllEquations; }
  if (out_outEquationsforZeroCrossings) { *out_outEquationsforZeroCrossings = _outEquationsforZeroCrossings; }
  return _outOdeEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystem(threadData_t *threadData, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_integer _iuniqueEqIndex, modelica_metatype _itempvars, modelica_integer _iSccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _iBackendMapping, modelica_boolean _createAlgebraicEquations, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_oBackendMapping)
{
  modelica_metatype _outOdeEquations = NULL;
  modelica_metatype _outAlgebraicEquations = NULL;
  modelica_metatype _outAllEquations = NULL;
  modelica_metatype _outEquationsforZeroCrossings = NULL;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _oeqSccMapping = NULL;
  modelica_metatype _oeqBackendSimCodeMapping = NULL;
  modelica_metatype _oBackendMapping = NULL;
  modelica_metatype _foldArg = NULL;
  modelica_metatype _arg = NULL;
  modelica_metatype _odeEquations = NULL;
  modelica_metatype _algebraicEquations = NULL;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _equationsforZeroCrossings = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outOdeEquations has no default value.
  // _outAlgebraicEquations has no default value.
  // _outAllEquations has no default value.
  // _outEquationsforZeroCrossings has no default value.
  // _ouniqueEqIndex has no default value.
  // _otempvars has no default value.
  // _oeqSccMapping has no default value.
  // _oeqBackendSimCodeMapping has no default value.
  // _oBackendMapping has no default value.
  // _foldArg has no default value.
  // _arg has no default value.
  // _odeEquations has no default value.
  // _algebraicEquations has no default value.
  // _allEquations has no default value.
  // _equationsforZeroCrossings has no default value.
  tmpMeta1 = mmc_mk_box5(0, _stateeqnsmark, _zceqnsmark, _syst, _shared, mmc_mk_boolean(_createAlgebraicEquations));
  _arg = tmpMeta1;

  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta6 = mmc_mk_box10(0, mmc_mk_integer(_iuniqueEqIndex), tmpMeta2, tmpMeta3, tmpMeta4, tmpMeta5, _itempvars, _ieqSccMapping, _ieqBackendSimCodeMapping, _iBackendMapping, mmc_mk_integer(_iSccIndex));
  _foldArg = tmpMeta6;

  _foldArg = omc_List_fold2(threadData, _comps, boxvar_SimCodeUtil_createEquationsForSystem1, _arg, omc_SimCodeUtil_partitionKindToClockIndex(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 9)))), _foldArg);

  /* Pattern-matching assignment */
  tmpMeta7 = _foldArg;
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
  tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 4));
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 5));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 6));
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 7));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 8));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 9));
  _ouniqueEqIndex = tmp9  /* pattern as ty=Integer */;
  _odeEquations = tmpMeta10;
  _algebraicEquations = tmpMeta11;
  _allEquations = tmpMeta12;
  _equationsforZeroCrossings = tmpMeta13;
  _otempvars = tmpMeta14;
  _oeqSccMapping = tmpMeta15;
  _oeqBackendSimCodeMapping = tmpMeta16;
  _oBackendMapping = tmpMeta17;

  _outOdeEquations = omc_List_flattenReverse(threadData, _odeEquations);

  _outAlgebraicEquations = omc_List_flattenReverse(threadData, _algebraicEquations);

  _outAllEquations = omc_List_flattenReverse(threadData, _allEquations);

  _outEquationsforZeroCrossings = omc_List_flattenReverse(threadData, _equationsforZeroCrossings);
  _return: OMC_LABEL_UNUSED
  if (out_outAlgebraicEquations) { *out_outAlgebraicEquations = _outAlgebraicEquations; }
  if (out_outAllEquations) { *out_outAllEquations = _outAllEquations; }
  if (out_outEquationsforZeroCrossings) { *out_outEquationsforZeroCrossings = _outEquationsforZeroCrossings; }
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_oeqSccMapping) { *out_oeqSccMapping = _oeqSccMapping; }
  if (out_oeqBackendSimCodeMapping) { *out_oeqBackendSimCodeMapping = _oeqBackendSimCodeMapping; }
  if (out_oBackendMapping) { *out_oBackendMapping = _oBackendMapping; }
  return _outOdeEquations;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsForSystem(threadData_t *threadData, modelica_metatype _stateeqnsmark, modelica_metatype _zceqnsmark, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _comps, modelica_metatype _iuniqueEqIndex, modelica_metatype _itempvars, modelica_metatype _iSccIndex, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _iBackendMapping, modelica_metatype _createAlgebraicEquations, modelica_metatype *out_outAlgebraicEquations, modelica_metatype *out_outAllEquations, modelica_metatype *out_outEquationsforZeroCrossings, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_oBackendMapping)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outOdeEquations = NULL;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_iSccIndex);
  tmp3 = mmc_unbox_integer(_createAlgebraicEquations);
  _outOdeEquations = omc_SimCodeUtil_createEquationsForSystem(threadData, _stateeqnsmark, _zceqnsmark, _syst, _shared, _comps, tmp1, _itempvars, tmp2, _ieqSccMapping, _ieqBackendSimCodeMapping, _iBackendMapping, tmp3, out_outAlgebraicEquations, out_outAllEquations, out_outEquationsforZeroCrossings, &_ouniqueEqIndex, out_otempvars, out_oeqSccMapping, out_oeqBackendSimCodeMapping, out_oBackendMapping);
  /* skip box _outOdeEquations; list<SimCode.SimEqSystem> */
  /* skip box _outAlgebraicEquations; list<SimCode.SimEqSystem> */
  /* skip box _outAllEquations; list<SimCode.SimEqSystem> */
  /* skip box _outEquationsforZeroCrossings; list<SimCode.SimEqSystem> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  /* skip box _oeqSccMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _oeqBackendSimCodeMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _oBackendMapping; SimCode.BackendMapping */
  return _outOdeEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createEquationsForSystems1(threadData_t *threadData, modelica_metatype _inSyst, modelica_metatype _inArg, modelica_metatype _inFold)
{
  modelica_metatype _outFold = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outFold has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 7)));
    {
      modelica_metatype _odeEquations1 = NULL;
      modelica_metatype _algebraicEquations1 = NULL;
      modelica_metatype _allEquations1 = NULL;
      modelica_metatype _comps = NULL;
      modelica_metatype _syst = NULL;
      modelica_metatype _odeEquations = NULL;
      modelica_metatype _algebraicEquations = NULL;
      modelica_metatype _allEquations = NULL;
      modelica_metatype _equationsForZeroCrossings = NULL;
      modelica_metatype _equationsForZeroCrossings1 = NULL;
      modelica_integer _uniqueEqIndex;
      modelica_integer _sccOffset;
      modelica_metatype _ass1 = NULL;
      modelica_metatype _stateeqnsmark = NULL;
      modelica_metatype _zceqnsmarks = NULL;
      modelica_metatype _tempvars = NULL;
      modelica_metatype _funcs = NULL;
      modelica_metatype _eqSccMapping = NULL;
      modelica_metatype _eqBackendSimCodeMapping = NULL;
      modelica_metatype _backendMapping = NULL;
      modelica_metatype _zeroCrossings = NULL;
      modelica_metatype _shared = NULL;
      modelica_boolean _createAlgebraicEquations;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _odeEquations1 has no default value.
      // _algebraicEquations1 has no default value.
      // _allEquations1 has no default value.
      // _comps has no default value.
      // _syst has no default value.
      // _odeEquations has no default value.
      // _algebraicEquations has no default value.
      // _allEquations has no default value.
      // _equationsForZeroCrossings has no default value.
      // _equationsForZeroCrossings1 has no default value.
      // _uniqueEqIndex has no default value.
      // _sccOffset has no default value.
      // _ass1 has no default value.
      // _stateeqnsmark has no default value.
      // _zceqnsmarks has no default value.
      // _tempvars has no default value.
      // _funcs has no default value.
      // _eqSccMapping has no default value.
      // _eqBackendSimCodeMapping has no default value.
      // _backendMapping has no default value.
      // _zeroCrossings has no default value.
      // _shared has no default value.
      // _createAlgebraicEquations has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _ass1 = tmpMeta6;
          _comps = tmpMeta7;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT786))
          {
            omc_BackendDump_dumpEqSystemBLTmatrixHTML(threadData, _inSyst);
          }

          /* Pattern-matching assignment */
          tmpMeta8 = _inArg;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          _shared = tmpMeta9;
          _zeroCrossings = tmpMeta10;
          _createAlgebraicEquations = tmp12  /* pattern as ty=Boolean */;

          /* Pattern-matching assignment */
          tmpMeta13 = _inFold;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 3));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 4));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 5));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 6));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 7));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 8));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 9));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 10));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          _uniqueEqIndex = tmp15  /* pattern as ty=Integer */;
          _odeEquations = tmpMeta16;
          _algebraicEquations = tmpMeta17;
          _allEquations = tmpMeta18;
          _equationsForZeroCrossings = tmpMeta19;
          _tempvars = tmpMeta20;
          _eqSccMapping = tmpMeta21;
          _eqBackendSimCodeMapping = tmpMeta22;
          _backendMapping = tmpMeta23;
          _sccOffset = tmp25  /* pattern as ty=Integer */;

          _funcs = omc_BackendDAEUtil_getFunctions(threadData, _shared);

          _syst = omc_BackendDAEUtil_getAdjacencyMatrixfromOption(threadData, _inSyst, _OMC_LIT787, mmc_mk_some(_funcs), omc_BackendDAEUtil_isInitializationDAE(threadData, _shared), NULL, NULL);

          _stateeqnsmark = arrayCreate(omc_BackendDAEUtil_equationArraySizeDAE(threadData, _syst), mmc_mk_integer(((modelica_integer) 0)));

          _zceqnsmarks = arrayCreate(omc_BackendDAEUtil_equationArraySizeDAE(threadData, _syst), mmc_mk_integer(((modelica_integer) 0)));

          _stateeqnsmark = omc_BackendDAEUtil_markStateEquations(threadData, _syst, _stateeqnsmark, _ass1);

          _zceqnsmarks = omc_BackendDAEUtil_markZeroCrossingEquations(threadData, _syst, _zeroCrossings, _zceqnsmarks, _ass1);

          _odeEquations1 = omc_SimCodeUtil_createEquationsForSystem(threadData, _stateeqnsmark, _zceqnsmarks, _syst, _shared, _comps, _uniqueEqIndex, _tempvars, _sccOffset, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, _createAlgebraicEquations ,&_algebraicEquations1 ,&_allEquations1 ,&_equationsForZeroCrossings1 ,&_uniqueEqIndex ,&_tempvars ,&_eqSccMapping ,&_eqBackendSimCodeMapping ,&_backendMapping);

          omc_GCExt_free(threadData, _stateeqnsmark);

          omc_GCExt_free(threadData, _zceqnsmarks);

          _odeEquations = omc_List_consOnTrue(threadData, (!listEmpty(_odeEquations1)), _odeEquations1, _odeEquations);

          _algebraicEquations = omc_List_consOnTrue(threadData, (!listEmpty(_algebraicEquations1)), _algebraicEquations1, _algebraicEquations);

          _allEquations = omc_List_append__reverse(threadData, _allEquations1, _allEquations);

          _equationsForZeroCrossings = omc_List_append__reverse(threadData, _equationsForZeroCrossings1, _equationsForZeroCrossings);
          tmpMeta26 = mmc_mk_box10(0, mmc_mk_integer(_uniqueEqIndex), _odeEquations, _algebraicEquations, _allEquations, _equationsForZeroCrossings, _tempvars, _eqSccMapping, _eqBackendSimCodeMapping, _backendMapping, mmc_mk_integer(listLength(_comps) + _sccOffset));
          tmpMeta1 = tmpMeta26;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inFold;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outFold = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outFold;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_SimCodeUtil_createEquationsForSystems(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _shared, modelica_integer _iuniqueEqIndex, modelica_metatype _inAllZeroCrossings, modelica_metatype _itempvars, modelica_integer _iSccOffset, modelica_metatype _iBackendMapping, modelica_boolean _createAlgebraicEquations, modelica_metatype *out_oodeEquations, modelica_metatype *out_oalgebraicEquations, modelica_metatype *out_olocalKnownVars, modelica_metatype *out_oallEquations, modelica_metatype *out_oequationsForZeroCrossings, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_obackendMapping, modelica_integer *out_oSccOffset)
{
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _oodeEquations = NULL;
  modelica_metatype _oalgebraicEquations = NULL;
  modelica_metatype _olocalKnownVars = NULL;
  modelica_metatype _oallEquations = NULL;
  modelica_metatype _oequationsForZeroCrossings = NULL;
  modelica_metatype _otempvars = NULL;
  modelica_metatype _oeqSccMapping = NULL;
  modelica_metatype _oeqBackendSimCodeMapping = NULL;
  modelica_metatype _obackendMapping = NULL;
  modelica_integer _oSccOffset;
  modelica_metatype _foldArg = NULL;
  modelica_metatype _arg = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ouniqueEqIndex has no default value.
  // _oodeEquations has no default value.
  // _oalgebraicEquations has no default value.
  // _olocalKnownVars has no default value.
  // _oallEquations has no default value.
  // _oequationsForZeroCrossings has no default value.
  // _otempvars has no default value.
  // _oeqSccMapping has no default value.
  // _oeqBackendSimCodeMapping has no default value.
  // _obackendMapping has no default value.
  // _oSccOffset has no default value.
  // _foldArg has no default value.
  // _arg has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          /* Pattern matching succeeded */
          tmpMeta5 = mmc_mk_box3(0, _shared, _inAllZeroCrossings, mmc_mk_boolean(_createAlgebraicEquations));
          _arg = tmpMeta5;

          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta12 = mmc_mk_box10(0, mmc_mk_integer(_iuniqueEqIndex), tmpMeta6, tmpMeta7, tmpMeta8, tmpMeta9, _itempvars, tmpMeta10, tmpMeta11, _iBackendMapping, mmc_mk_integer(_iSccOffset));
          _foldArg = tmpMeta12;

          _foldArg = omc_List_fold1(threadData, _inSysts, boxvar_SimCodeUtil_createEquationsForSystems1, _arg, _foldArg);

          /* Pattern-matching assignment */
          tmpMeta13 = _foldArg;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 3));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 4));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 5));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 6));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 7));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 8));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 9));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 10));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          _ouniqueEqIndex = tmp15  /* pattern as ty=Integer */;
          _oodeEquations = tmpMeta16;
          _oalgebraicEquations = tmpMeta17;
          _oallEquations = tmpMeta18;
          _oequationsForZeroCrossings = tmpMeta19;
          _otempvars = tmpMeta20;
          _oeqSccMapping = tmpMeta21;
          _oeqBackendSimCodeMapping = tmpMeta22;
          _obackendMapping = tmpMeta23;
          _oSccOffset = tmp25  /* pattern as ty=Integer */;

          _oequationsForZeroCrossings = listReverseInPlace(_oequationsForZeroCrossings);

          /* Pattern-matching assignment */
          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta27 = mmc_mk_box2(0, mmc_mk_integer(_ouniqueEqIndex), tmpMeta26);
          tmpMeta28 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 3))), boxvar_SimCodeUtil_traverseKnVarsToSimEqSystem, tmpMeta27);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 2));
          _ouniqueEqIndex = tmp30  /* pattern as ty=Integer */;
          _olocalKnownVars = tmpMeta31;
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT788, _OMC_LIT789);

          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_oodeEquations) { *out_oodeEquations = _oodeEquations; }
  if (out_oalgebraicEquations) { *out_oalgebraicEquations = _oalgebraicEquations; }
  if (out_olocalKnownVars) { *out_olocalKnownVars = _olocalKnownVars; }
  if (out_oallEquations) { *out_oallEquations = _oallEquations; }
  if (out_oequationsForZeroCrossings) { *out_oequationsForZeroCrossings = _oequationsForZeroCrossings; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  if (out_oeqSccMapping) { *out_oeqSccMapping = _oeqSccMapping; }
  if (out_oeqBackendSimCodeMapping) { *out_oeqBackendSimCodeMapping = _oeqBackendSimCodeMapping; }
  if (out_obackendMapping) { *out_obackendMapping = _obackendMapping; }
  if (out_oSccOffset) { *out_oSccOffset = _oSccOffset; }
  return _ouniqueEqIndex;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_createEquationsForSystems(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _shared, modelica_metatype _iuniqueEqIndex, modelica_metatype _inAllZeroCrossings, modelica_metatype _itempvars, modelica_metatype _iSccOffset, modelica_metatype _iBackendMapping, modelica_metatype _createAlgebraicEquations, modelica_metatype *out_oodeEquations, modelica_metatype *out_oalgebraicEquations, modelica_metatype *out_olocalKnownVars, modelica_metatype *out_oallEquations, modelica_metatype *out_oequationsForZeroCrossings, modelica_metatype *out_otempvars, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_obackendMapping, modelica_metatype *out_oSccOffset)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer _oSccOffset;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype out_ouniqueEqIndex;
  tmp1 = mmc_unbox_integer(_iuniqueEqIndex);
  tmp2 = mmc_unbox_integer(_iSccOffset);
  tmp3 = mmc_unbox_integer(_createAlgebraicEquations);
  _ouniqueEqIndex = omc_SimCodeUtil_createEquationsForSystems(threadData, _inSysts, _shared, tmp1, _inAllZeroCrossings, _itempvars, tmp2, _iBackendMapping, tmp3, out_oodeEquations, out_oalgebraicEquations, out_olocalKnownVars, out_oallEquations, out_oequationsForZeroCrossings, out_otempvars, out_oeqSccMapping, out_oeqBackendSimCodeMapping, out_obackendMapping, &_oSccOffset);
  out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex);
  /* skip box _oodeEquations; list<list<SimCode.SimEqSystem>> */
  /* skip box _oalgebraicEquations; list<list<SimCode.SimEqSystem>> */
  /* skip box _olocalKnownVars; list<SimCode.SimEqSystem> */
  /* skip box _oallEquations; list<SimCode.SimEqSystem> */
  /* skip box _oequationsForZeroCrossings; list<SimCode.SimEqSystem> */
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  /* skip box _oeqSccMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _oeqBackendSimCodeMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _obackendMapping; SimCode.BackendMapping */
  if (out_oSccOffset) { *out_oSccOffset = mmc_mk_icon(_oSccOffset); }
  return out_ouniqueEqIndex;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_jacobianColumnsAreEmpty(threadData_t *threadData, modelica_metatype _columns)
{
  modelica_boolean _b;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _b = 1 /* true */;
  {
    modelica_metatype _col;
    for (tmpMeta1 = _columns; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _col = MMC_CAR(tmpMeta1);
      if((!(listEmpty((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_col), 2)))) && listEmpty((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_col), 5)))))))
      {
        _b = 0 /* false */;

        goto _return;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_SimCodeUtil_jacobianColumnsAreEmpty(threadData_t *threadData, modelica_metatype _columns)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_jacobianColumnsAreEmpty(threadData, _columns);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_rewriteJacPartIdx(threadData_t *threadData, modelica_metatype _inJac, modelica_integer _index)
{
  modelica_metatype _outJac = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outJac = _inJac;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(17));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_outJac), 17*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[13] = mmc_mk_integer(_index);
  _outJac = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outJac;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_rewriteJacPartIdx(threadData_t *threadData, modelica_metatype _inJac, modelica_metatype _index)
{
  modelica_integer tmp1;
  modelica_metatype _outJac = NULL;
  tmp1 = mmc_unbox_integer(_index);
  _outJac = omc_SimCodeUtil_rewriteJacPartIdx(threadData, _inJac, tmp1);
  /* skip box _outJac; SimCode.JacobianMatrix */
  return _outJac;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_addAlgebraicLoopsClockPartitions(threadData_t *threadData, modelica_metatype _inColockPartition, modelica_metatype _inModelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_outSymJacs)
{
  modelica_metatype _outColockPartition = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _outSymJacs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _subPartitionTmp = NULL;
  modelica_metatype _clockPartitionTmp = NULL;
  modelica_metatype _subPartitionsTmp = NULL;
  modelica_metatype _equations = NULL;
  modelica_metatype _tmpJacs = NULL;
  modelica_integer _clockIndex;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outColockPartition = tmpMeta1;
  _modelInfo = _inModelInfo;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSymJacs = tmpMeta2;
  // _subPartitionTmp has no default value.
  // _clockPartitionTmp has no default value.
  // _subPartitionsTmp has no default value.
  // _equations has no default value.
  // _tmpJacs has no default value.
  _clockIndex = ((modelica_integer) 0);
  {
    modelica_metatype _clockPartion;
    for (tmpMeta3 = _inColockPartition; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _clockPartion = MMC_CAR(tmpMeta3);
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _subPartitionsTmp = tmpMeta4;

      {
        modelica_metatype _subPartion;
        for (tmpMeta5 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_clockPartion), 3))); !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
        {
          _subPartion = MMC_CAR(tmpMeta5);
          _clockIndex = ((modelica_integer) 1) + _clockIndex;

          _equations = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartion), 3))), _modelInfo, 1 /* true */ ,&_modelInfo ,&_tmpJacs);

          {
            modelica_metatype __omcQ_24tmpVar71;
            modelica_metatype* tmp7;
            modelica_metatype tmpMeta8;
            modelica_metatype __omcQ_24tmpVar70;
            modelica_integer tmp9;
            modelica_metatype _a_loopVar = 0;
            modelica_metatype _a;
            _a_loopVar = _tmpJacs;
            tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar71 = tmpMeta8; /* defaultValue */
            tmp7 = &__omcQ_24tmpVar71;
            while(1) {
              tmp9 = 1;
              if (!listEmpty(_a_loopVar)) {
                _a = MMC_CAR(_a_loopVar);
                _a_loopVar = MMC_CDR(_a_loopVar);
                tmp9--;
              }
              if (tmp9 == 0) {
                __omcQ_24tmpVar70 = omc_SimCodeUtil_rewriteJacPartIdx(threadData, _a, _clockIndex);
                *tmp7 = mmc_mk_cons(__omcQ_24tmpVar70,0);
                tmp7 = &MMC_CDR(*tmp7);
              } else if (tmp9 == 1) {
                break;
              } else {
                MMC_THROW_INTERNAL();
              }
            }
            *tmp7 = mmc_mk_nil();
            tmpMeta6 = __omcQ_24tmpVar71;
          }
          _tmpJacs = tmpMeta6;

          _outSymJacs = listAppend(_tmpJacs, _outSymJacs);

          tmpMeta10 = mmc_mk_box6(3, &SimCode_SubPartition_SUBPARTITION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartion), 2))), _equations, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartion), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartion), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartion), 6))));
          _subPartitionTmp = tmpMeta10;

          tmpMeta11 = mmc_mk_cons(_subPartitionTmp, _subPartitionsTmp);
          _subPartitionsTmp = tmpMeta11;
        }
      }

      tmpMeta13 = mmc_mk_box3(3, &SimCode_ClockedPartition_CLOCKED__PARTITION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_clockPartion), 2))), listReverse(_subPartitionsTmp));
      _clockPartitionTmp = tmpMeta13;

      tmpMeta14 = mmc_mk_cons(_clockPartitionTmp, _outColockPartition);
      _outColockPartition = tmpMeta14;
    }
  }

  _outColockPartition = listReverse(_outColockPartition);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_outSymJacs) { *out_outSymJacs = _outSymJacs; }
  return _outColockPartition;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addAlgebraicLoopsModelInfoStateSets(threadData_t *threadData, modelica_metatype _inSets, modelica_metatype _inModelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_outSymJacs, modelica_metatype *out_outSymJacsInternal)
{
  modelica_metatype _outSets = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _outSymJacs = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _outSymJacsInternal = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _symJac = NULL;
  modelica_metatype _tmpSymJacs = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSets = tmpMeta1;
  _modelInfo = _inModelInfo;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSymJacs = tmpMeta2;
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSymJacsInternal = tmpMeta3;
  // _symJac has no default value.
  // _tmpSymJacs has no default value.
  {
    modelica_metatype _set;
    for (tmpMeta4 = _inSets; !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
    {
      _set = MMC_CAR(tmpMeta4);
      /* Pattern-matching tuple assignment */
      tmpMeta7 = mmc_mk_cons((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_set), 8))), MMC_REFSTRUCTLIT(mmc_nil));
      tmpMeta8 = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta7, _modelInfo, &tmpMeta5, &tmpMeta6);
      if (listEmpty(tmpMeta8)) MMC_THROW_INTERNAL();
      tmpMeta9 = MMC_CAR(tmpMeta8);
      tmpMeta10 = MMC_CDR(tmpMeta8);
      if (!listEmpty(tmpMeta10)) MMC_THROW_INTERNAL();
      _symJac = tmpMeta9;
      _modelInfo = tmpMeta5;
      _tmpSymJacs = tmpMeta6;

      _outSymJacsInternal = listAppend(_tmpSymJacs, _outSymJacsInternal);

      tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(9));
      memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_set), 9*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[8] = _symJac;
      _set = tmpMeta11;

      tmpMeta12 = mmc_mk_cons(_symJac, _outSymJacs);
      _outSymJacs = tmpMeta12;

      tmpMeta13 = mmc_mk_cons(_set, _outSets);
      _outSets = tmpMeta13;
    }
  }

  _outSets = listReverse(_outSets);

  _outSymJacs = listReverse(_outSymJacs);

  _outSymJacsInternal = listReverse(_outSymJacsInternal);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_outSymJacs) { *out_outSymJacs = _outSymJacs; }
  if (out_outSymJacsInternal) { *out_outSymJacsInternal = _outSymJacsInternal; }
  return _outSets;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fsymjacs, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_outSymJacsInSymJacs)
{
  modelica_metatype _symjacs = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _outSymJacsInSymJacs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _column = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _tmpSymJacs = NULL;
  modelica_metatype _outSymJacs = NULL;
  modelica_metatype tmpMeta2;
  modelica_boolean _debug;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta23;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _symjacs = __omcQ_24in_5Fsymjacs;
  _modelInfo = __omcQ_24in_5FmodelInfo;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSymJacsInSymJacs = tmpMeta1;
  // _column has no default value.
  // _eqs has no default value.
  // _varInfo has no default value.
  // _tmpSymJacs has no default value.
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outSymJacs = tmpMeta2;
  _debug = 0 /* false */;
  {
    modelica_metatype _symjac;
    for (tmpMeta3 = _symjacs; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _symjac = MMC_CAR(tmpMeta3);
      _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));

      tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(17));
      memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_symjac), 17*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[12] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 28)));
      _symjac = tmpMeta4;

      tmpMeta5 = MMC_TAGPTR(mmc_alloc_words(37));
      memcpy(MMC_UNTAGPTR(tmpMeta5), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta5))[28] = mmc_mk_integer(((modelica_integer) 1) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 28)))));
      _varInfo = tmpMeta5;

      tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(23));
      memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[10] = _varInfo;
      _modelInfo = tmpMeta6;

      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp9;
          int tmp10;
          tmp9 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp8_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp9 < 2; tmp9++) {
            switch (MMC_SWITCH_CAST(tmp9)) {
            case 0: {
              modelica_metatype tmpMeta11;
              modelica_metatype tmpMeta12;
              modelica_metatype tmpMeta13;
              modelica_metatype tmpMeta14;
              modelica_metatype tmpMeta18;
              modelica_metatype tmpMeta19;
              modelica_metatype tmpMeta20;
              modelica_metatype tmpMeta21;
              /* Pattern matching succeeded */
              /* Pattern-matching assignment */
              tmpMeta11 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_symjac), 2)));
              if (listEmpty(tmpMeta11)) goto goto_7;
              tmpMeta12 = MMC_CAR(tmpMeta11);
              tmpMeta13 = MMC_CDR(tmpMeta11);
              if (!listEmpty(tmpMeta13)) goto goto_7;
              _column = tmpMeta12;

              _eqs = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_column), 2))), _modelInfo, 1 /* true */ ,&_modelInfo ,&_tmpSymJacs);

              {
                modelica_metatype __omcQ_24tmpVar73;
                modelica_metatype* tmp15;
                modelica_metatype tmpMeta16;
                modelica_metatype __omcQ_24tmpVar72;
                modelica_integer tmp17;
                modelica_metatype _a_loopVar = 0;
                modelica_metatype _a;
                _a_loopVar = _tmpSymJacs;
                tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
                __omcQ_24tmpVar73 = tmpMeta16; /* defaultValue */
                tmp15 = &__omcQ_24tmpVar73;
                while(1) {
                  tmp17 = 1;
                  if (!listEmpty(_a_loopVar)) {
                    _a = MMC_CAR(_a_loopVar);
                    _a_loopVar = MMC_CDR(_a_loopVar);
                    tmp17--;
                  }
                  if (tmp17 == 0) {
                    __omcQ_24tmpVar72 = omc_SimCodeUtil_rewriteJacPartIdx(threadData, _a, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 17)))));
                    *tmp15 = mmc_mk_cons(__omcQ_24tmpVar72,0);
                    tmp15 = &MMC_CDR(*tmp15);
                  } else if (tmp17 == 1) {
                    break;
                  } else {
                    goto goto_7;
                  }
                }
                *tmp15 = mmc_mk_nil();
                tmpMeta14 = __omcQ_24tmpVar73;
              }
              _tmpSymJacs = tmpMeta14;

              _outSymJacsInSymJacs = listAppend(_tmpSymJacs, _outSymJacsInSymJacs);

              tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(6));
              memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_column), 6*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[2] = _eqs;
              _column = tmpMeta18;

              tmpMeta20 = mmc_mk_cons(_column, MMC_REFSTRUCTLIT(mmc_nil));
              tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(17));
              memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_symjac), 17*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[2] = tmpMeta20;
              _symjac = tmpMeta19;

              tmpMeta21 = mmc_mk_cons(_symjac, _outSymJacs);
              _outSymJacs = tmpMeta21;
              goto tmp8_done;
            }
            case 1: {
              modelica_metatype tmpMeta22;
              /* Pattern matching succeeded */
              tmpMeta22 = mmc_mk_cons(_symjac, _outSymJacs);
              _outSymJacs = tmpMeta22;
              goto tmp8_done;
            }
            }
            goto tmp8_end;
            tmp8_end: ;
          }
          goto goto_7;
          tmp8_done:
          (void)tmp9;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp8_done2;
          goto_7:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp9 < 2) {
            goto tmp8_top;
          }
          MMC_THROW_INTERNAL();
          tmp8_done2:;
        }
      }
      ;
    }
  }

  _symjacs = listReverse(_outSymJacs);

  _outSymJacsInSymJacs = listReverse(_outSymJacsInSymJacs);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_outSymJacsInSymJacs) { *out_outSymJacsInSymJacs = _outSymJacsInSymJacs; }
  return _symjacs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateLinearSyst(threadData_t *threadData, modelica_metatype __omcQ_24in_5FinSyst, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype __omcQ_24in_5FallSymJacs, modelica_metatype *out_modelInfo, modelica_metatype *out_allSymJacs)
{
  modelica_metatype _inSyst = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _allSymJacs = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _tmpSymJac = NULL;
  modelica_metatype _tmpSymJacs = NULL;
  modelica_boolean _debug;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _inSyst = __omcQ_24in_5FinSyst;
  _modelInfo = __omcQ_24in_5FmodelInfo;
  _allSymJacs = __omcQ_24in_5FallSymJacs;
  _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));
  // _eqs has no default value.
  // _tmpSymJac has no default value.
  // _tmpSymJacs has no default value.
  _debug = 0 /* false */;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(14));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_inSyst), 14*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[11] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 24)));
  _inSyst = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(37));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[24] = mmc_mk_integer(((modelica_integer) 1) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 24)))));
  _varInfo = tmpMeta2;

  tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(23));
  memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[10] = _varInfo;
  _modelInfo = tmpMeta3;

  if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 9)))))
  {
    _tmpSymJac = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 9))));

    if((!listEmpty((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpSymJac), 2))))))
    {
      /* Pattern-matching tuple assignment */
      tmpMeta6 = mmc_mk_cons(_tmpSymJac, MMC_REFSTRUCTLIT(mmc_nil));
      tmpMeta7 = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta6, _modelInfo, &tmpMeta4, &tmpMeta5);
      if (listEmpty(tmpMeta7)) MMC_THROW_INTERNAL();
      tmpMeta8 = MMC_CAR(tmpMeta7);
      tmpMeta9 = MMC_CDR(tmpMeta7);
      if (!listEmpty(tmpMeta9)) MMC_THROW_INTERNAL();
      _tmpSymJac = tmpMeta8;
      _modelInfo = tmpMeta4;
      _tmpSymJacs = tmpMeta5;

      tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(14));
      memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_inSyst), 14*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[9] = mmc_mk_some(_tmpSymJac);
      _inSyst = tmpMeta10;

      _allSymJacs = listAppend(_tmpSymJacs, _allSymJacs);

      tmpMeta11 = mmc_mk_cons(_tmpSymJac, _allSymJacs);
      _allSymJacs = tmpMeta11;
    }
  }

  _eqs = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 8))), _modelInfo, 1 /* true */ ,&_modelInfo ,&_tmpSymJacs);

  tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(14));
  memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_inSyst), 14*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[8] = _eqs;
  _inSyst = tmpMeta12;

  _allSymJacs = listAppend(_tmpSymJacs, _allSymJacs);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_allSymJacs) { *out_allSymJacs = _allSymJacs; }
  return _inSyst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_updateNonLinearSyst(threadData_t *threadData, modelica_metatype __omcQ_24in_5FinSyst, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype __omcQ_24in_5FallSymJacs, modelica_metatype *out_modelInfo, modelica_metatype *out_allSymJacs)
{
  modelica_metatype _inSyst = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _allSymJacs = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _tmpSymJac = NULL;
  modelica_metatype _tmpSymJacs = NULL;
  modelica_boolean _debug;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _inSyst = __omcQ_24in_5FinSyst;
  _modelInfo = __omcQ_24in_5FmodelInfo;
  _allSymJacs = __omcQ_24in_5FallSymJacs;
  _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));
  // _eqs has no default value.
  // _tmpSymJac has no default value.
  // _tmpSymJacs has no default value.
  _debug = 0 /* false */;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(12));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_inSyst), 12*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[5] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 25)));
  _inSyst = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(37));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[25] = mmc_mk_integer(((modelica_integer) 1) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varInfo), 25)))));
  _varInfo = tmpMeta2;

  tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(23));
  memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[10] = _varInfo;
  _modelInfo = tmpMeta3;

  if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 7)))))
  {
    _tmpSymJac = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 7))));

    if((!listEmpty((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpSymJac), 2))))))
    {
      /* Pattern-matching tuple assignment */
      tmpMeta6 = mmc_mk_cons(_tmpSymJac, MMC_REFSTRUCTLIT(mmc_nil));
      tmpMeta7 = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta6, _modelInfo, &tmpMeta4, &tmpMeta5);
      if (listEmpty(tmpMeta7)) MMC_THROW_INTERNAL();
      tmpMeta8 = MMC_CAR(tmpMeta7);
      tmpMeta9 = MMC_CDR(tmpMeta7);
      if (!listEmpty(tmpMeta9)) MMC_THROW_INTERNAL();
      _tmpSymJac = tmpMeta8;
      _modelInfo = tmpMeta4;
      _tmpSymJacs = tmpMeta5;

      tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(12));
      memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_inSyst), 12*sizeof(modelica_metatype));
      ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[7] = mmc_mk_some(_tmpSymJac);
      _inSyst = tmpMeta10;

      _allSymJacs = listAppend(_tmpSymJacs, _allSymJacs);

      tmpMeta11 = mmc_mk_cons(_tmpSymJac, _allSymJacs);
      _allSymJacs = tmpMeta11;
    }
  }

  _eqs = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 3))), _modelInfo, 0 /* false */ ,&_modelInfo ,&_tmpSymJacs);

  tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(12));
  memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_inSyst), 12*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[3] = _eqs;
  _inSyst = tmpMeta12;

  _allSymJacs = listAppend(_tmpSymJacs, _allSymJacs);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_allSymJacs) { *out_allSymJacs = _allSymJacs; }
  return _inSyst;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqns, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_boolean _addNLSToModelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_symJacs)
{
  modelica_metatype _eqns = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _symJacs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _resEqns = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqns = __omcQ_24in_5Feqns;
  _modelInfo = __omcQ_24in_5FmodelInfo;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _symJacs = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _resEqns = tmpMeta2;
  {
    modelica_metatype _eqn;
    for (tmpMeta3 = _eqns; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _eqn = MMC_CAR(tmpMeta3);
      { /* match expression */
        modelica_metatype tmp7_1;
        tmp7_1 = _eqn;
        {
          modelica_metatype _nlSyst = NULL;
          modelica_metatype _altNlSyst = NULL;
          modelica_metatype _optNlSyst = NULL;
          modelica_metatype _linearSyst = NULL;
          modelica_metatype _altLinearSyst = NULL;
          modelica_metatype _optLinearSyst = NULL;
          modelica_metatype _system = NULL;
          modelica_metatype _eqAttr = NULL;
          volatile mmc_switch_type tmp7;
          int tmp8;
          // _nlSyst has no default value.
          // _altNlSyst has no default value.
          // _optNlSyst has no default value.
          // _linearSyst has no default value.
          // _altLinearSyst has no default value.
          // _optLinearSyst has no default value.
          // _system has no default value.
          // _eqAttr has no default value.
          tmp7 = 0;
          for (; tmp7 < 3; tmp7++) {
            switch (MMC_SWITCH_CAST(tmp7)) {
            case 0: {
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              modelica_metatype tmpMeta11;
              modelica_metatype tmpMeta12;
              modelica_metatype tmpMeta13;
              modelica_metatype tmpMeta14;
              if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,13,3) == 0) goto tmp6_end;
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 2));
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
              tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 4));
              _nlSyst = tmpMeta9;
              _optNlSyst = tmpMeta10;
              _eqAttr = tmpMeta11;
              /* Pattern matching succeeded */
              _nlSyst = omc_SimCodeUtil_updateNonLinearSyst(threadData, _nlSyst, _modelInfo, _symJacs ,&_modelInfo ,&_symJacs);

              if(isSome(_optNlSyst))
              {
                _altNlSyst = omc_Util_getOption(threadData, _optNlSyst);

                _altNlSyst = omc_SimCodeUtil_updateNonLinearSyst(threadData, _altNlSyst, _modelInfo, _symJacs ,&_modelInfo ,&_symJacs);

                _optNlSyst = mmc_mk_some(_altNlSyst);
              }

              tmpMeta12 = mmc_mk_box4(16, &SimCode_SimEqSystem_SES__NONLINEAR__desc, _nlSyst, _optNlSyst, _eqAttr);
              _system = tmpMeta12;

              if(_addNLSToModelInfo)
              {
                tmpMeta14 = mmc_mk_cons(_system, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 21))));
                tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(23));
                memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
                ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[21] = tmpMeta14;
                _modelInfo = tmpMeta13;
              }
              tmpMeta4 = _system;
              goto tmp6_done;
            }
            case 1: {
              modelica_metatype tmpMeta15;
              modelica_metatype tmpMeta16;
              modelica_metatype tmpMeta17;
              modelica_metatype tmpMeta18;
              modelica_metatype tmpMeta19;
              modelica_metatype tmpMeta20;
              if (mmc__uniontype__metarecord__typedef__equal(tmp7_1,12,3) == 0) goto tmp6_end;
              tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 2));
              tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 3));
              tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp7_1), 4));
              _linearSyst = tmpMeta15;
              _optLinearSyst = tmpMeta16;
              _eqAttr = tmpMeta17;
              /* Pattern matching succeeded */
              _linearSyst = omc_SimCodeUtil_updateLinearSyst(threadData, _linearSyst, _modelInfo, _symJacs ,&_modelInfo ,&_symJacs);

              if(isSome(_optLinearSyst))
              {
                _altLinearSyst = omc_Util_getOption(threadData, _optLinearSyst);

                _altLinearSyst = omc_SimCodeUtil_updateLinearSyst(threadData, _altLinearSyst, _modelInfo, _symJacs ,&_modelInfo ,&_symJacs);

                _optLinearSyst = mmc_mk_some(_altLinearSyst);
              }

              tmpMeta18 = mmc_mk_box4(15, &SimCode_SimEqSystem_SES__LINEAR__desc, _linearSyst, _optLinearSyst, _eqAttr);
              _system = tmpMeta18;

              tmpMeta20 = mmc_mk_cons(_system, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 20))));
              tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(23));
              memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[20] = tmpMeta20;
              _modelInfo = tmpMeta19;
              tmpMeta4 = _system;
              goto tmp6_done;
            }
            case 2: {
              
              /* Pattern matching succeeded */
              tmpMeta4 = _eqn;
              goto tmp6_done;
            }
            }
            goto tmp6_end;
            tmp6_end: ;
          }
          goto goto_5;
          goto_5:;
          MMC_THROW_INTERNAL();
          goto tmp6_done;
          tmp6_done:;
        }
      }
      _eqn = tmpMeta4;

      tmpMeta21 = mmc_mk_cons(_eqn, _resEqns);
      _resEqns = tmpMeta21;
    }
  }

  _eqns = listReverse(_resEqns);
  _return: OMC_LABEL_UNUSED
  if (out_modelInfo) { *out_modelInfo = _modelInfo; }
  if (out_symJacs) { *out_symJacs = _symJacs; }
  return _eqns;
}
modelica_metatype boxptr_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqns, modelica_metatype __omcQ_24in_5FmodelInfo, modelica_metatype _addNLSToModelInfo, modelica_metatype *out_modelInfo, modelica_metatype *out_symJacs)
{
  modelica_integer tmp1;
  modelica_metatype _eqns = NULL;
  tmp1 = mmc_unbox_integer(_addNLSToModelInfo);
  _eqns = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, __omcQ_24in_5Feqns, __omcQ_24in_5FmodelInfo, tmp1, out_modelInfo, out_symJacs);
  /* skip box _eqns; list<SimCode.SimEqSystem> */
  /* skip box _modelInfo; SimCode.ModelInfo */
  /* skip box _symJacs; list<SimCode.JacobianMatrix> */
  return _eqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_setSystemIndexMap(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inSysIndexMap)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_integer _sysIndex;
      modelica_metatype _lSystem = NULL;
      modelica_metatype _nlSystem = NULL;
      modelica_metatype _alternativeTearingL = NULL;
      modelica_metatype _alternativeTearingNL = NULL;
      modelica_metatype _simEq = NULL;
      modelica_metatype _cont = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _sysIndex has no default value.
      // _lSystem has no default value.
      // _nlSystem has no default value.
      // _alternativeTearingL has no default value.
      // _alternativeTearingNL has no default value.
      // _simEq has no default value.
      // _cont has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _simEq = tmp4_1;
          _lSystem = tmpMeta6;
          _alternativeTearingL = tmpMeta7;
          /* Pattern matching succeeded */
          _sysIndex = mmc_unbox_integer(arrayGet(_inSysIndexMap,mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_lSystem), 2))))) /* DAE.ASUB */);

          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(14));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_lSystem), 14*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[11] = mmc_mk_integer(_sysIndex);
          _lSystem = tmpMeta8;

          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_simEq), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[2] = _lSystem;
          _simEq = tmpMeta9;

          if(isSome(_alternativeTearingL))
          {
            _lSystem = omc_Util_getOption(threadData, _alternativeTearingL);

            _sysIndex = mmc_unbox_integer(arrayGet(_inSysIndexMap,mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_lSystem), 2))))) /* DAE.ASUB */);

            tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(14));
            memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_lSystem), 14*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[11] = mmc_mk_integer(_sysIndex);
            _lSystem = tmpMeta10;

            _alternativeTearingL = mmc_mk_some(_lSystem);

            tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_simEq), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[3] = _alternativeTearingL;
            _simEq = tmpMeta11;
          }
          tmpMeta1 = _simEq;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _simEq = tmp4_1;
          _nlSystem = tmpMeta12;
          _alternativeTearingNL = tmpMeta13;
          /* Pattern matching succeeded */
          _sysIndex = mmc_unbox_integer(arrayGet(_inSysIndexMap,mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_nlSystem), 2))))) /* DAE.ASUB */);

          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(12));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_nlSystem), 12*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[5] = mmc_mk_integer(_sysIndex);
          _nlSystem = tmpMeta14;

          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_simEq), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[2] = _nlSystem;
          _simEq = tmpMeta15;

          if(isSome(_alternativeTearingNL))
          {
            _nlSystem = omc_Util_getOption(threadData, _alternativeTearingNL);

            _sysIndex = mmc_unbox_integer(arrayGet(_inSysIndexMap,mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_nlSystem), 2))))) /* DAE.ASUB */);

            tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(12));
            memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_nlSystem), 12*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[5] = mmc_mk_integer(_sysIndex);
            _nlSystem = tmpMeta16;

            _alternativeTearingNL = mmc_mk_some(_nlSystem);

            tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_simEq), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[3] = _alternativeTearingNL;
            _simEq = tmpMeta17;
          }
          tmpMeta1 = _simEq;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _simEq = tmp4_1;
          _cont = tmpMeta18;
          /* Pattern matching succeeded */
          _sysIndex = mmc_unbox_integer(arrayGet(_inSysIndexMap,mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simEq), 2))))) /* DAE.ASUB */);

          _cont = omc_SimCodeUtil_setSystemIndexMap(threadData, _cont, _inSysIndexMap);

          tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_simEq), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[3] = _cont;
          _simEq = tmpMeta19;

          tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_simEq), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[6] = mmc_mk_integer(_sysIndex);
          _simEq = tmpMeta20;
          tmpMeta1 = _simEq;
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inEqn;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEqn = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSystemIndexMap(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inSysIndexMap)
{
  modelica_metatype _outSysIndexMap = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSysIndexMap has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_integer _index;
      modelica_integer _systemIndex;
      modelica_integer _index2;
      modelica_integer _systemIndex2;
      modelica_metatype _sysIndexMap = NULL;
      modelica_metatype _cont = NULL;
      modelica_metatype _eqs = NULL;
      modelica_metatype _eqs2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _index has no default value.
      // _systemIndex has no default value.
      // _index2 has no default value.
      // _systemIndex2 has no default value.
      // _sysIndexMap has no default value.
      // _cont has no default value.
      // _eqs has no default value.
      // _eqs2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 11));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (!optionNone(tmpMeta11)) goto tmp3_end;
          
          _index = tmp8  /* pattern as ty=Integer */;
          _systemIndex = tmp10  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta1 = arrayUpdate(_inSysIndexMap, _index, mmc_mk_integer(_systemIndex));
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 5));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (!optionNone(tmpMeta18)) goto tmp3_end;
          
          _index = tmp14  /* pattern as ty=Integer */;
          _eqs = tmpMeta15;
          _systemIndex = tmp17  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _sysIndexMap = omc_List_fold(threadData, _eqs, boxvar_SimCodeUtil_getSystemIndexMap, _inSysIndexMap);
          tmpMeta1 = arrayUpdate(_sysIndexMap, _index, mmc_mk_integer(_systemIndex));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 11));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (optionNone(tmpMeta24)) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 11));
          tmp29 = mmc_unbox_integer(tmpMeta28);
          
          _index = tmp21  /* pattern as ty=Integer */;
          _systemIndex = tmp23  /* pattern as ty=Integer */;
          _index2 = tmp27  /* pattern as ty=Integer */;
          _systemIndex2 = tmp29  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          arrayUpdate(_inSysIndexMap, _index, mmc_mk_integer(_systemIndex));
          tmpMeta1 = arrayUpdate(_inSysIndexMap, _index2, mmc_mk_integer(_systemIndex2));
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_integer tmp42;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmp32 = mmc_unbox_integer(tmpMeta31);
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 3));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 5));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (optionNone(tmpMeta36)) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 1));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          tmp39 = mmc_unbox_integer(tmpMeta38);
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 3));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 5));
          tmp42 = mmc_unbox_integer(tmpMeta41);
          
          _index = tmp32  /* pattern as ty=Integer */;
          _eqs = tmpMeta33;
          _systemIndex = tmp35  /* pattern as ty=Integer */;
          _index2 = tmp39  /* pattern as ty=Integer */;
          _eqs2 = tmpMeta40;
          _systemIndex2 = tmp42  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _sysIndexMap = omc_List_fold(threadData, _eqs, boxvar_SimCodeUtil_getSystemIndexMap, _inSysIndexMap);

          _sysIndexMap = arrayUpdate(_sysIndexMap, _index, mmc_mk_integer(_systemIndex));

          _sysIndexMap = omc_List_fold(threadData, _eqs2, boxvar_SimCodeUtil_getSystemIndexMap, _inSysIndexMap);
          tmpMeta1 = arrayUpdate(_sysIndexMap, _index2, mmc_mk_integer(_systemIndex2));
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta43;
          modelica_integer tmp44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_integer tmp47;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,6) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp44 = mmc_unbox_integer(tmpMeta43);
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp47 = mmc_unbox_integer(tmpMeta46);
          
          _index = tmp44  /* pattern as ty=Integer */;
          _cont = tmpMeta45;
          _systemIndex = tmp47  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          omc_SimCodeUtil_getSystemIndexMap(threadData, _cont, _inSysIndexMap);
          tmpMeta1 = arrayUpdate(_inSysIndexMap, _index, mmc_mk_integer(_systemIndex));
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inSysIndexMap;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outSysIndexMap = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outSysIndexMap;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_addNumEqns(threadData_t *threadData, modelica_metatype _modelInfo, modelica_integer _numEqns)
{
  modelica_metatype _omodelInfo = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _omodelInfo = _modelInfo;
  // _varInfo has no default value.
  _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omodelInfo), 10)));

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(37));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[23] = mmc_mk_integer(_numEqns);
  _varInfo = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(23));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_omodelInfo), 23*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[10] = _varInfo;
  _omodelInfo = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _omodelInfo;
}
modelica_metatype boxptr_SimCodeUtil_addNumEqns(threadData_t *threadData, modelica_metatype _modelInfo, modelica_metatype _numEqns)
{
  modelica_integer tmp1;
  modelica_metatype _omodelInfo = NULL;
  tmp1 = mmc_unbox_integer(_numEqns);
  _omodelInfo = omc_SimCodeUtil_addNumEqns(threadData, _modelInfo, tmp1);
  /* skip box _omodelInfo; SimCode.ModelInfo */
  return _omodelInfo;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_setSeedVars(threadData_t *threadData, modelica_metatype _seedVars, modelica_metatype __omcQ_24in_5FmodelInfo)
{
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _modelInfo = __omcQ_24in_5FmodelInfo;
  // _vars has no default value.
  _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(32));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_vars), 32*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[25] = _seedVars;
  _vars = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(23));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[11] = _vars;
  _modelInfo = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _modelInfo;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_setJacobianVars(threadData_t *threadData, modelica_metatype _iJacobianVars, modelica_metatype _iModelInfo)
{
  modelica_metatype _oModelInfo = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _oModelInfo = _iModelInfo;
  // _vars has no default value.
  if((!listEmpty(_iJacobianVars)))
  {
    _vars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_oModelInfo), 11)));

    tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(32));
    memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_vars), 32*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[24] = _iJacobianVars;
    _vars = tmpMeta1;

    tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(23));
    memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_oModelInfo), 23*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[11] = _vars;
    _oModelInfo = tmpMeta2;
  }
  _return: OMC_LABEL_UNUSED
  return _oModelInfo;
}

PROTECTED_FUNCTION_STATIC void omc_SimCodeUtil_addTempVars(threadData_t *threadData, modelica_metatype _simVars, modelica_metatype _tempVars)
{
  modelica_integer _ix;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2 = 0;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ix has no default value.
  {
    modelica_metatype _e;
    for (tmpMeta1 = _tempVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _e = MMC_CAR(tmpMeta1);
      { /* match expression */
        modelica_metatype tmp5_1;
        tmp5_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_e), 13)));
        {
          int tmp5;
          {
            switch (MMC_SWITCH_CAST(valueConstructor(tmp5_1))) {
            case 3: {
              
              /* Pattern matching succeeded */
              tmp2 = ((modelica_integer) 9);
              goto tmp4_done;
            }
            case 8: {
              
              /* Pattern matching succeeded */
              tmp2 = ((modelica_integer) 9);
              goto tmp4_done;
            }
            case 6: {
              
              /* Pattern matching succeeded */
              tmp2 = ((modelica_integer) 12);
              goto tmp4_done;
            }
            case 5: {
              
              /* Pattern matching succeeded */
              tmp2 = ((modelica_integer) 15);
              goto tmp4_done;
            }
            default:
            tmp4_default: OMC_LABEL_UNUSED; {
              
              /* Pattern matching succeeded */
              tmp2 = ((modelica_integer) 3);
              goto tmp4_done;
            }
            }
            goto tmp4_end;
            tmp4_end: ;
          }
          goto goto_3;
          goto_3:;
          MMC_THROW_INTERNAL();
          goto tmp4_done;
          tmp4_done:;
        }
      }
      _ix = tmp2;

      tmpMeta6 = mmc_mk_cons(_e, arrayGet(_simVars,_ix) /* DAE.ASUB */);
      arrayUpdate(_simVars, _ix, tmpMeta6);
    }
  }
  _return: OMC_LABEL_UNUSED
  return;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getClockedEquations(threadData_t *threadData, modelica_metatype _inSubPartitions)
{
  modelica_metatype _outEqs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEqs = tmpMeta1;
  {
    modelica_metatype _part;
    for (tmpMeta2 = _inSubPartitions; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _part = MMC_CAR(tmpMeta2);
      _outEqs = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_part), 3))), _outEqs);

      _outEqs = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_part), 4))), _outEqs);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outEqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSubPartition(threadData_t *threadData, modelica_metatype _inPartition)
{
  modelica_metatype _outSubPartitions = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSubPartitions has no default value.
  _outSubPartitions = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inPartition), 3)));
  _return: OMC_LABEL_UNUSED
  return _outSubPartitions;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getSubPartitions(threadData_t *threadData, modelica_metatype _inPartitions)
{
  modelica_metatype _outSubPartitions = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSubPartitions has no default value.
  _outSubPartitions = omc_List_flatten(threadData, omc_List_map(threadData, _inPartitions, boxvar_SimCodeUtil_getSubPartition));
  _return: OMC_LABEL_UNUSED
  return _outSubPartitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getSimVarCompRef(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_metatype _outComp = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outComp has no default value.
  _outComp = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inVar), 2)));
  _return: OMC_LABEL_UNUSED
  return _outComp;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_getClockIndex(threadData_t *threadData, modelica_metatype _simVar, modelica_metatype _simCode)
{
  modelica_metatype _clockIndex = NULL;
  modelica_metatype _cref = NULL;
  modelica_metatype _clkHT = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _clockIndex has no default value.
  // _cref has no default value.
  // _clkHT has no default value.
  _cref = omc_SimCodeUtil_getSimVarCompRef(threadData, _simVar);

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _simCode;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 45));
          
          _clkHT = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = (omc_BaseHashTable_hasKey(threadData, _cref, _clkHT)?mmc_mk_some(omc_BaseHashTable_get(threadData, _cref, _clkHT)):mmc_mk_none());
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _clockIndex = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _clockIndex;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_collectClockedVars1(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _clkHT = NULL;
  modelica_integer _clockIndex;
  modelica_metatype _cref = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  // _clkHT has no default value.
  // _clockIndex has no default value.
  // _cref has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp4 = mmc_unbox_integer(tmpMeta3);
  _clkHT = tmpMeta2;
  _clockIndex = tmp4  /* pattern as ty=Integer */;

  
  
  { /* match expression */
    modelica_metatype tmp8_1;
    tmp8_1 = _inVar;
    {
      volatile mmc_switch_type tmp8;
      int tmp9;
      tmp8 = 0;
      for (; tmp8 < 2; tmp8++) {
        switch (MMC_SWITCH_CAST(tmp8)) {
        case 0: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 2));
          
          _cref = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta11 = mmc_mk_box2(0, _cref, mmc_mk_integer(_clockIndex));
          _clkHT = omc_BaseHashTable_add(threadData, tmpMeta11, _clkHT);

          tmpMeta12 = mmc_mk_box2(0, omc_ComponentReference_crefPrefixPrevious(threadData, _cref), mmc_mk_integer(_clockIndex));
          _clkHT = omc_BaseHashTable_add(threadData, tmpMeta12, _clkHT);
          tmpMeta13 = mmc_mk_box2(0, _clkHT, mmc_mk_integer(_clockIndex));
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = tmpMeta13;
          goto tmp7_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp7_done;
        }
        }
        goto tmp7_end;
        tmp7_end: ;
      }
      goto goto_6;
      goto_6:;
      MMC_THROW_INTERNAL();
      goto tmp7_done;
      tmp7_done:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_collectClockedVars(threadData_t *threadData, modelica_metatype _inEqSystem, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _inHT = NULL;
  modelica_metatype _outHT = NULL;
  modelica_integer _clockIndex;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _inHT has no default value.
  // _outHT has no default value.
  // _clockIndex has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp4 = mmc_unbox_integer(tmpMeta3);
  _inHT = tmpMeta2;
  _clockIndex = tmp4  /* pattern as ty=Integer */;

  { /* match expression */
    modelica_metatype tmp8_1;
    tmp8_1 = _inEqSystem;
    {
      volatile mmc_switch_type tmp8;
      int tmp9;
      tmp8 = 0;
      for (; tmp8 < 2; tmp8++) {
        switch (MMC_SWITCH_CAST(tmp8)) {
        case 0: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp8_1), 9));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,1,1) == 0) goto tmp7_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta11 = mmc_mk_box2(0, _inHT, mmc_mk_integer(_clockIndex));
          tmpMeta12 = omc_BackendVariable_traverseBackendDAEVars(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqSystem), 2))), boxvar_SimCodeUtil_collectClockedVars1, tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          _outHT = tmpMeta13;
          tmpMeta14 = mmc_mk_box2(0, _outHT, mmc_mk_integer(((modelica_integer) 1) + _clockIndex));
          tmpMeta5 = tmpMeta14;
          goto tmp7_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta5 = _inTpl;
          goto tmp7_done;
        }
        }
        goto tmp7_end;
        tmp7_end: ;
      }
      goto goto_6;
      goto_6:;
      MMC_THROW_INTERNAL();
      goto tmp7_done;
      tmp7_done:;
    }
  }
  _outTpl = tmpMeta5;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_createClockedSimPartitions(threadData_t *threadData, modelica_metatype _basePartitions, modelica_metatype _subPartitions)
{
  modelica_metatype _clockedPartitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _off;
  modelica_metatype _basePartition = NULL;
  modelica_metatype _simSubPartitions = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  modelica_integer tmp7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _clockedPartitions = tmpMeta1;
  _off = ((modelica_integer) 1);
  // _basePartition has no default value.
  // _simSubPartitions has no default value.
  tmp5 = ((modelica_integer) 1); tmp6 = 1; tmp7 = arrayLength(_basePartitions);
  if(!(((tmp6 > 0) && (tmp5 > tmp7)) || ((tmp6 < 0) && (tmp5 < tmp7))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp5, tmp7); _i += tmp6)
    {
      _basePartition = arrayGet(_basePartitions,_i) /* DAE.ASUB */;

      if((mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_basePartition), 3)))) > ((modelica_integer) 0)))
      {
        _simSubPartitions = omc_List_map(threadData, omc_Array_getRange(threadData, _off, ((modelica_integer) -1) + _off + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_basePartition), 3)))), _subPartitions), boxvar_Util_getOption);

        _simSubPartitions = listReverse(_simSubPartitions);
      }
      else
      {
        tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
        _simSubPartitions = tmpMeta2;
      }

      _off = _off + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_basePartition), 3))));

      tmpMeta4 = mmc_mk_box3(3, &SimCode_ClockedPartition_CLOCKED__PARTITION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_basePartition), 2))), _simSubPartitions);
      tmpMeta3 = mmc_mk_cons(tmpMeta4, _clockedPartitions);
      _clockedPartitions = tmpMeta3;
    }
  }

  _clockedPartitions = listReverse(_clockedPartitions);
  _return: OMC_LABEL_UNUSED
  return _clockedPartitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_translateClockedEquations(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_integer _iSccOffset, modelica_integer _iuniqueEqIndex, modelica_metatype _iBackendMapping, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _itempvars, modelica_integer *out_ouniqueEqIndex, modelica_metatype *out_oBackendMapping, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_otempvars)
{
  modelica_metatype _outPartitions = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _oBackendMapping = NULL;
  modelica_metatype _oeqSccMapping = NULL;
  modelica_metatype _oeqBackendSimCodeMapping = NULL;
  modelica_metatype _otempvars = NULL;
  modelica_integer _subPartIdx;
  modelica_metatype _removedEquations = NULL;
  modelica_metatype _equations = NULL;
  modelica_metatype _simSubPartition = NULL;
  modelica_boolean _holdEvents;
  modelica_metatype _ass1 = NULL;
  modelica_metatype _stateeqnsmark = NULL;
  modelica_metatype _zceqnsmarks = NULL;
  modelica_metatype _funcs = NULL;
  modelica_metatype _comps = NULL;
  modelica_integer _sccOffset;
  modelica_metatype _varIxs = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype _simVar = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype _clockedVars = NULL;
  modelica_metatype _prevClockedVars = NULL;
  modelica_metatype _simSubPartitions = NULL;
  modelica_metatype _subPartition = NULL;
  modelica_metatype _isPrevVar = NULL;
  modelica_metatype _simEq = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_integer tmp14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_metatype tmpMeta25;
  modelica_metatype tmpMeta26;
  modelica_metatype tmpMeta27;
  modelica_metatype tmpMeta28;
  modelica_integer tmp29;
  modelica_integer tmp30;
  modelica_integer tmp31;
  modelica_metatype tmpMeta32;
  static int tmp33 = 0;
  modelica_metatype tmpMeta34;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outPartitions = tmpMeta1;
  _ouniqueEqIndex = _iuniqueEqIndex;
  _oBackendMapping = _iBackendMapping;
  _oeqSccMapping = _ieqSccMapping;
  _oeqBackendSimCodeMapping = _ieqBackendSimCodeMapping;
  _otempvars = _itempvars;
  // _subPartIdx has no default value.
  // _removedEquations has no default value.
  // _equations has no default value.
  // _simSubPartition has no default value.
  // _holdEvents has no default value.
  // _ass1 has no default value.
  // _stateeqnsmark has no default value.
  // _zceqnsmarks has no default value.
  // _funcs has no default value.
  // _comps has no default value.
  _sccOffset = _iSccOffset;
  // _varIxs has no default value.
  // _var has no default value.
  // _simVar has no default value.
  // _cr has no default value.
  // _clockedVars has no default value.
  // _prevClockedVars has no default value.
  // _simSubPartitions has no default value.
  // _subPartition has no default value.
  // _isPrevVar has no default value.
  // _simEq has no default value.
  _simSubPartitions = arrayCreate(arrayLength((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 18)))), 3)))), mmc_mk_none());

  _funcs = omc_BackendDAEUtil_getFunctions(threadData, _inShared);

  {
    modelica_metatype _syst;
    for (tmpMeta2 = _inSysts; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _syst = MMC_CAR(tmpMeta2);
      /* Pattern-matching assignment */
      tmpMeta3 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 9)));
      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta3,1,1) == 0) MMC_THROW_INTERNAL();
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
      tmp5 = mmc_unbox_integer(tmpMeta4);
      _subPartIdx = tmp5  /* pattern as ty=Integer */;

      /* Pattern-matching assignment */
      tmpMeta6 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 7)));
      if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) MMC_THROW_INTERNAL();
      tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
      tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
      _ass1 = tmpMeta7;
      _comps = tmpMeta8;

      _subPartition = arrayGet((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 18)))), 3))),_subPartIdx) /* DAE.ASUB */;

      _syst = omc_BackendDAEUtil_getAdjacencyMatrixfromOption(threadData, _syst, _OMC_LIT787, mmc_mk_some(_funcs), omc_BackendDAEUtil_isInitializationDAE(threadData, _inShared), NULL, NULL);

      _stateeqnsmark = arrayCreate(omc_BackendDAEUtil_equationArraySizeDAE(threadData, _syst), mmc_mk_integer(((modelica_integer) 0)));

      _stateeqnsmark = omc_BackendDAEUtil_markStateEquations(threadData, _syst, _stateeqnsmark, _ass1);

      _zceqnsmarks = arrayCreate(omc_BackendDAEUtil_equationArraySizeDAE(threadData, _syst), mmc_mk_integer(((modelica_integer) 0)));

      tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
      omc_SimCodeUtil_createEquationsForSystem(threadData, _stateeqnsmark, _zceqnsmarks, _syst, _inShared, _comps, _ouniqueEqIndex, tmpMeta9, _sccOffset, _oeqSccMapping, _oeqBackendSimCodeMapping, _oBackendMapping, 1 /* true */ ,NULL ,&_equations ,NULL ,&_ouniqueEqIndex ,&_clockedVars ,&_oeqSccMapping ,&_oeqBackendSimCodeMapping ,&_oBackendMapping);

      _sccOffset = listLength(_comps) + _sccOffset;

      omc_GCExt_free(threadData, _stateeqnsmark);

      omc_GCExt_free(threadData, _zceqnsmarks);

      /* Pattern-matching assignment */
      tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
      tmpMeta11 = mmc_mk_box2(0, mmc_mk_integer(_ouniqueEqIndex), tmpMeta10);
      tmpMeta12 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 10))), boxvar_SimCodeUtil_traversedlowEqToSimEqSystem, tmpMeta11);
      tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
      tmp14 = mmc_unbox_integer(tmpMeta13);
      tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
      _ouniqueEqIndex = tmp14  /* pattern as ty=Integer */;
      _removedEquations = tmpMeta15;

      tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
      _prevClockedVars = tmpMeta16;

      _isPrevVar = arrayCreate(omc_BackendVariable_varsSize(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2)))), mmc_mk_boolean(0 /* false */));

      {
        modelica_metatype _cr;
        for (tmpMeta17 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartition), 4))); !listEmpty(tmpMeta17); tmpMeta17=MMC_CDR(tmpMeta17))
        {
          _cr = MMC_CAR(tmpMeta17);
          omc_BackendVariable_getVar(threadData, _cr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))) ,&_varIxs);

          {
            modelica_metatype _i;
            for (tmpMeta18 = _varIxs; !listEmpty(tmpMeta18); tmpMeta18=MMC_CDR(tmpMeta18))
            {
              _i = MMC_CAR(tmpMeta18);
              arrayUpdate(_isPrevVar, mmc_unbox_integer(_i), mmc_mk_boolean(1 /* true */));
            }
          }
        }
      }

      tmp29 = ((modelica_integer) 1); tmp30 = 1; tmp31 = omc_BackendVariable_varsSize(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))));
      if(!(((tmp30 > 0) && (tmp29 > tmp31)) || ((tmp30 < 0) && (tmp29 < tmp31))))
      {
        modelica_integer _i;
        for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp29, tmp31); _i += tmp30)
        {
          _var = omc_BackendVariable_getVarAt(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), _i);

          _simVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _var, mmc_mk_some((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 5)))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 2))), mmc_mk_none());

          tmpMeta22 = mmc_mk_box2(0, _simVar, arrayGet(_isPrevVar,_i) /* DAE.ASUB */);
          tmpMeta21 = mmc_mk_cons(tmpMeta22, _prevClockedVars);
          _prevClockedVars = tmpMeta21;

          tmpMeta23 = mmc_mk_cons(_simVar, _clockedVars);
          _clockedVars = tmpMeta23;

          if(mmc_unbox_boolean(arrayGet(_isPrevVar,_i) /* DAE.ASUB */))
          {
            _cr = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 2)));

            tmpMeta24 = MMC_TAGPTR(mmc_alloc_words(33));
            memcpy(MMC_UNTAGPTR(tmpMeta24), MMC_UNTAGPTR(_simVar), 33*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta24))[2] = omc_ComponentReference_crefPrefixPrevious(threadData, _cr);
            _simVar = tmpMeta24;

            tmpMeta25 = mmc_mk_cons(_simVar, _clockedVars);
            _clockedVars = tmpMeta25;

            tmpMeta26 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 13))));
            tmpMeta27 = mmc_mk_box6(6, &SimCode_SimEqSystem_SES__SIMPLE__ASSIGN__desc, mmc_mk_integer(_ouniqueEqIndex), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_simVar), 2))), tmpMeta26, _OMC_LIT92, _OMC_LIT535);
            _simEq = tmpMeta27;

            tmpMeta28 = mmc_mk_cons(_simEq, _equations);
            _equations = tmpMeta28;

            _ouniqueEqIndex = ((modelica_integer) 1) + _ouniqueEqIndex;
          }
        }
      }

      omc_GCExt_free(threadData, _isPrevVar);

      tmpMeta32 = mmc_mk_box6(3, &SimCode_SubPartition_SUBPARTITION__desc, _prevClockedVars, _equations, _removedEquations, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartition), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_subPartition), 3))));
      _simSubPartition = tmpMeta32;

      {
        if(!isNone(arrayGet(_simSubPartitions,_subPartIdx) /* DAE.ASUB */))
        {
          {
            FILE_INFO info = {"/projects/OpenModelica-session2/OMCompiler/Compiler/SimCode/SimCodeUtil.mo",958,5,958,97,0};
            omc_assert(threadData, info, MMC_STRINGDATA(_OMC_LIT790));
          }
        }
      }

      arrayUpdate(_simSubPartitions, _subPartIdx, mmc_mk_some(_simSubPartition));
    }
  }

  _outPartitions = omc_SimCodeUtil_createClockedSimPartitions(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 18)))), 2))), _simSubPartitions);

  omc_GCExt_free(threadData, _simSubPartitions);
  _return: OMC_LABEL_UNUSED
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = _ouniqueEqIndex; }
  if (out_oBackendMapping) { *out_oBackendMapping = _oBackendMapping; }
  if (out_oeqSccMapping) { *out_oeqSccMapping = _oeqSccMapping; }
  if (out_oeqBackendSimCodeMapping) { *out_oeqBackendSimCodeMapping = _oeqBackendSimCodeMapping; }
  if (out_otempvars) { *out_otempvars = _otempvars; }
  return _outPartitions;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_translateClockedEquations(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inShared, modelica_metatype _iSccOffset, modelica_metatype _iuniqueEqIndex, modelica_metatype _iBackendMapping, modelica_metatype _ieqSccMapping, modelica_metatype _ieqBackendSimCodeMapping, modelica_metatype _itempvars, modelica_metatype *out_ouniqueEqIndex, modelica_metatype *out_oBackendMapping, modelica_metatype *out_oeqSccMapping, modelica_metatype *out_oeqBackendSimCodeMapping, modelica_metatype *out_otempvars)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _ouniqueEqIndex;
  modelica_metatype _outPartitions = NULL;
  modelica_metatype tmpMeta3;
  tmp1 = mmc_unbox_integer(_iSccOffset);
  tmp2 = mmc_unbox_integer(_iuniqueEqIndex);
  _outPartitions = omc_SimCodeUtil_translateClockedEquations(threadData, _inSysts, _inShared, tmp1, tmp2, _iBackendMapping, _ieqSccMapping, _ieqBackendSimCodeMapping, _itempvars, &_ouniqueEqIndex, out_oBackendMapping, out_oeqSccMapping, out_oeqBackendSimCodeMapping, out_otempvars);
  /* skip box _outPartitions; list<SimCode.ClockedPartition> */
  if (out_ouniqueEqIndex) { *out_ouniqueEqIndex = mmc_mk_icon(_ouniqueEqIndex); }
  /* skip box _oBackendMapping; SimCode.BackendMapping */
  /* skip box _oeqSccMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _oeqBackendSimCodeMapping; list<tuple<#Integer, #Integer>> */
  /* skip box _otempvars; list<SimCodeVar.SimVar> */
  return _outPartitions;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_getParamAsserts(threadData_t *threadData, modelica_metatype _eqIn, modelica_metatype _vars, modelica_metatype _tplIn)
{
  modelica_metatype _tplOut = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _tplOut has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _eqIn;
    tmp4_2 = _tplIn;
    {
      modelica_metatype _stmts = NULL;
      modelica_metatype _crefs = NULL;
      modelica_metatype _varLst = NULL;
      modelica_metatype _varLstLst = NULL;
      modelica_metatype _varDep = NULL;
      modelica_metatype _paramDep = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stmts has no default value.
      // _crefs has no default value.
      // _varLst has no default value.
      // _varLstLst has no default value.
      // _varDep has no default value.
      // _paramDep has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_boolean tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _stmts = tmpMeta7;
          _varDep = tmpMeta8;
          _paramDep = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          _crefs = omc_List_fold(threadData, _stmts, boxvar_DAEUtil_getAssertConditionCrefs, tmpMeta10);

          _varLstLst = omc_List_map1__2(threadData, _crefs, boxvar_BackendVariable_getVar, _vars, NULL);

          _varLst = omc_List_flatten(threadData, _varLstLst);

          /* Pattern-matching assignment */
          tmp11 = omc_List_any(threadData, _varLst, boxvar_BackendVariable_isParam);
          if (1 /* true */ != tmp11) goto goto_2;
          tmpMeta12 = mmc_mk_cons(_eqIn, _paramDep);
          tmpMeta13 = mmc_mk_box2(0, _varDep, tmpMeta12);
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta14 = _tplIn;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 1));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          _varDep = tmpMeta15;
          _paramDep = tmpMeta16;
          tmpMeta17 = mmc_mk_cons(_eqIn, _varDep);
          tmpMeta18 = mmc_mk_box2(0, tmpMeta17, _paramDep);
          tmpMeta1 = tmpMeta18;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _tplOut = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _tplOut;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_createSimCode(threadData_t *threadData, modelica_metatype _inBackendDAE, modelica_metatype _inInitDAE, modelica_metatype _inInitDAE_lambda0, modelica_metatype _inInlineData, modelica_metatype _inRemovedInitialEquationLst, modelica_metatype _inClassName, modelica_string _filenamePrefix, modelica_string _inFileDir, modelica_metatype _functions, modelica_metatype _externalFunctionIncludes, modelica_metatype _includeDirs, modelica_metatype _libs, modelica_metatype _libPaths, modelica_metatype _program, modelica_metatype _simSettingsOpt, modelica_metatype _recordDecls, modelica_metatype _literals, modelica_metatype _args, modelica_boolean _isFMU, modelica_string _FMUVersion, modelica_string _fmuTargetName, modelica_metatype _inFMIDer, modelica_metatype *out_outMapping)
{
  modelica_metatype _simCode = NULL;
  modelica_metatype _outMapping = NULL;
  modelica_metatype _dlow = NULL;
  modelica_metatype _initDAE_lambda0 = NULL;
  modelica_metatype _removedEqs = NULL;
  modelica_metatype _eventInfo = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _symJacs = NULL;
  modelica_metatype _globalKnownVars = NULL;
  modelica_boolean _ifcpp;
  modelica_metatype _varToArrayIndexMapping = NULL;
  modelica_metatype _varToIndexMapping = NULL;
  modelica_integer _maxDelayedExpIndex;
  modelica_integer _uniqueEqIndex;
  modelica_integer _numStateSets;
  modelica_integer _sccOffset;
  modelica_integer _numberofFixedParameters;
  modelica_integer _reasonableSize;
  modelica_metatype _modelStructure = NULL;
  modelica_metatype _fmiSimulationFlags = NULL;
  modelica_metatype _backendMapping = NULL;
  modelica_metatype _extObjInfo = NULL;
  modelica_metatype _crefToSimVarHT = NULL;
  modelica_metatype _makefileParams = NULL;
  modelica_metatype _modelInfo = NULL;
  modelica_metatype _crefToClockIndexHT = NULL;
  modelica_metatype _systemIndexMap = NULL;
  modelica_metatype _clockedSysts = NULL;
  modelica_metatype _contSysts = NULL;
  modelica_metatype _timeEvents = NULL;
  modelica_metatype _zeroCrossingsSet = NULL;
  modelica_metatype _sampleZCSet = NULL;
  modelica_metatype _de_relations = NULL;
  modelica_metatype _zeroCrossings = NULL;
  modelica_metatype _sampleZC = NULL;
  modelica_metatype _relations = NULL;
  modelica_metatype _classAttributes = NULL;
  modelica_metatype _discreteModelVars = NULL;
  modelica_metatype _iterationVarsLst1 = NULL;
  modelica_metatype _iterationVarsLst2 = NULL;
  modelica_metatype _constraints = NULL;
  modelica_metatype _lits = NULL;
  modelica_metatype _clockedPartitions = NULL;
  modelica_metatype _LinearMatrices = NULL;
  modelica_metatype _SymbolicJacs = NULL;
  modelica_metatype _SymbolicJacsTemp = NULL;
  modelica_metatype _SymbolicJacsStateSelect = NULL;
  modelica_metatype _SymbolicJacsStateSelectInternal = NULL;
  modelica_metatype _SymbolicJacsNLS = NULL;
  modelica_metatype _SymbolicJacsFMI = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _SymbolicJacsdatarecon = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _algorithmAndEquationAsserts = NULL;
  modelica_metatype _localKnownVars = NULL;
  modelica_metatype _allEquations = NULL;
  modelica_metatype _equationsForZeroCrossings = NULL;
  modelica_metatype _initialEquations = NULL;
  modelica_metatype _initialEquations_lambda0 = NULL;
  modelica_metatype _jacobianEquations = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _maxValueEquations = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype _minValueEquations = NULL;
  modelica_metatype tmpMeta5;
  modelica_metatype _nominalValueEquations = NULL;
  modelica_metatype tmpMeta6;
  modelica_metatype _parameterEquations = NULL;
  modelica_metatype tmpMeta7;
  modelica_metatype _removedEquations = NULL;
  modelica_metatype _removedInitialEquations = NULL;
  modelica_metatype _startValueEquations = NULL;
  modelica_metatype tmpMeta8;
  modelica_metatype _stateSets = NULL;
  modelica_metatype _tempvars = NULL;
  modelica_metatype _jacobianSimvars = NULL;
  modelica_metatype _seedVars = NULL;
  modelica_metatype _algebraicEquations = NULL;
  modelica_metatype _odeEquations = NULL;
  modelica_metatype _inlineEquationsTemp = NULL;
  modelica_metatype _inlineEquations = NULL;
  modelica_metatype _tmpSimVars = NULL;
  modelica_metatype _varInfo = NULL;
  modelica_metatype _sensitivityVars = NULL;
  modelica_integer _countSenParams;
  modelica_metatype _equationSccMapping = NULL;
  modelica_metatype _eqBackendSimCodeMapping = NULL;
  modelica_metatype _delayedExps = NULL;
  modelica_metatype _spatialInfo = NULL;
  modelica_metatype _inlineData = NULL;
  modelica_metatype _inlineSimKnVars = NULL;
  modelica_metatype _emptyVars = NULL;
  modelica_integer _SymEuler_help;
  modelica_metatype _dtSimVar = NULL;
  modelica_metatype _dtVar = NULL;
  modelica_metatype _eqCache = NULL;
  modelica_metatype _dataReconJac = NULL;
  modelica_metatype _dataReconJacH = NULL;
  modelica_metatype _setcVars = NULL;
  modelica_metatype _datareconinputvars = NULL;
  modelica_metatype _setBVars = NULL;
  modelica_metatype _tmpsetcVars = NULL;
  modelica_metatype _tmpdatareconinputvars = NULL;
  modelica_metatype _tmpsetBVars = NULL;
  modelica_metatype _dataReconSimJac = NULL;
  modelica_metatype _dataReconSimJacH = NULL;
  modelica_integer _numRelatedBoundaryConditions;
  modelica_string _fullPathPrefix = NULL;
  modelica_string _fileNamePrefixHash = NULL;
  modelica_string _iterationVarsStr = NULL;
  modelica_metatype _omsiInitEquations = NULL;
  modelica_metatype _omsiSimEquations = NULL;
  modelica_metatype _omsiOptData = NULL;
  modelica_metatype _theSettings = NULL;
  modelica_boolean _debug;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _simCode has no default value.
  // _outMapping has no default value.
  // _dlow has no default value.
  // _initDAE_lambda0 has no default value.
  // _removedEqs has no default value.
  // _eventInfo has no default value.
  // _shared has no default value.
  // _symJacs has no default value.
  // _globalKnownVars has no default value.
  // _ifcpp has no default value.
  // _varToArrayIndexMapping has no default value.
  // _varToIndexMapping has no default value.
  // _maxDelayedExpIndex has no default value.
  // _uniqueEqIndex has no default value.
  // _numStateSets has no default value.
  // _sccOffset has no default value.
  // _numberofFixedParameters has no default value.
  // _reasonableSize has no default value.
  _modelStructure = mmc_mk_none();
  _fmiSimulationFlags = mmc_mk_none();
  // _backendMapping has no default value.
  // _extObjInfo has no default value.
  // _crefToSimVarHT has no default value.
  // _makefileParams has no default value.
  // _modelInfo has no default value.
  // _crefToClockIndexHT has no default value.
  // _systemIndexMap has no default value.
  // _clockedSysts has no default value.
  // _contSysts has no default value.
  // _timeEvents has no default value.
  // _zeroCrossingsSet has no default value.
  // _sampleZCSet has no default value.
  // _de_relations has no default value.
  // _zeroCrossings has no default value.
  // _sampleZC has no default value.
  // _relations has no default value.
  // _classAttributes has no default value.
  // _discreteModelVars has no default value.
  // _iterationVarsLst1 has no default value.
  // _iterationVarsLst2 has no default value.
  // _constraints has no default value.
  // _lits has no default value.
  // _clockedPartitions has no default value.
  // _LinearMatrices has no default value.
  // _SymbolicJacs has no default value.
  // _SymbolicJacsTemp has no default value.
  // _SymbolicJacsStateSelect has no default value.
  // _SymbolicJacsStateSelectInternal has no default value.
  // _SymbolicJacsNLS has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _SymbolicJacsFMI = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _SymbolicJacsdatarecon = tmpMeta2;
  // _algorithmAndEquationAsserts has no default value.
  // _localKnownVars has no default value.
  // _allEquations has no default value.
  // _equationsForZeroCrossings has no default value.
  // _initialEquations has no default value.
  // _initialEquations_lambda0 has no default value.
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _jacobianEquations = tmpMeta3;
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _maxValueEquations = tmpMeta4;
  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  _minValueEquations = tmpMeta5;
  tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
  _nominalValueEquations = tmpMeta6;
  tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
  _parameterEquations = tmpMeta7;
  // _removedEquations has no default value.
  // _removedInitialEquations has no default value.
  tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
  _startValueEquations = tmpMeta8;
  // _stateSets has no default value.
  // _tempvars has no default value.
  // _jacobianSimvars has no default value.
  // _seedVars has no default value.
  // _algebraicEquations has no default value.
  // _odeEquations has no default value.
  // _inlineEquationsTemp has no default value.
  // _inlineEquations has no default value.
  // _tmpSimVars has no default value.
  // _varInfo has no default value.
  // _sensitivityVars has no default value.
  // _countSenParams has no default value.
  // _equationSccMapping has no default value.
  // _eqBackendSimCodeMapping has no default value.
  // _delayedExps has no default value.
  // _spatialInfo has no default value.
  // _inlineData has no default value.
  // _inlineSimKnVars has no default value.
  // _emptyVars has no default value.
  _SymEuler_help = ((modelica_integer) 0);
  // _dtSimVar has no default value.
  // _dtVar has no default value.
  // _eqCache has no default value.
  // _dataReconJac has no default value.
  // _dataReconJacH has no default value.
  // _setcVars has no default value.
  // _datareconinputvars has no default value.
  // _setBVars has no default value.
  // _tmpsetcVars has no default value.
  // _tmpdatareconinputvars has no default value.
  // _tmpsetBVars has no default value.
  // _dataReconSimJac has no default value.
  // _dataReconSimJacH has no default value.
  // _numRelatedBoundaryConditions has no default value.
  // _fullPathPrefix has no default value.
  // _fileNamePrefixHash has no default value.
  // _iterationVarsStr has no default value.
  _omsiInitEquations = _OMC_LIT712;
  // _omsiSimEquations has no default value.
  // _omsiOptData has no default value.
  // _theSettings has no default value.
  _debug = 0 /* false */;
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp11;
      int tmp12;
      tmp11 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp10_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp11 < 2; tmp11++) {
        switch (MMC_SWITCH_CAST(tmp11)) {
        case 0: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_integer tmp58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_integer tmp67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_integer tmp73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_integer tmp78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_integer tmp83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_integer tmp88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_integer tmp93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_integer tmp98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_integer tmp103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_integer tmp109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_metatype tmpMeta117;
          modelica_metatype tmpMeta118;
          modelica_metatype tmpMeta119;
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          modelica_metatype tmpMeta125;
          modelica_metatype tmpMeta126;
          modelica_integer tmp127;
          modelica_integer tmp128;
          modelica_metatype tmpMeta129;
          modelica_metatype tmpMeta130;
          modelica_metatype tmpMeta131;
          modelica_integer tmp132;
          modelica_metatype tmpMeta133;
          modelica_metatype tmpMeta134;
          modelica_metatype tmpMeta135;
          modelica_metatype tmpMeta136;
          modelica_metatype tmpMeta137;
          modelica_metatype tmpMeta138;
          modelica_metatype tmpMeta139;
          modelica_metatype tmpMeta140;
          modelica_metatype tmpMeta141;
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          modelica_metatype tmpMeta144;
          modelica_metatype tmpMeta145;
          modelica_metatype tmpMeta146;
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          modelica_metatype tmpMeta149;
          modelica_metatype tmpMeta150;
          modelica_metatype tmpMeta151;
          modelica_metatype tmpMeta152;
          modelica_metatype tmpMeta153;
          modelica_metatype tmpMeta154;
          modelica_metatype tmpMeta155;
          modelica_metatype tmpMeta156;
          modelica_metatype tmpMeta157;
          modelica_metatype tmpMeta158;
          modelica_metatype tmpMeta159;
          modelica_metatype tmpMeta160;
          modelica_metatype tmpMeta161;
          modelica_metatype tmpMeta162;
          modelica_metatype tmpMeta163;
          modelica_metatype tmpMeta164;
          modelica_metatype tmpMeta165;
          modelica_metatype tmpMeta166;
          modelica_metatype tmpMeta167;
          modelica_metatype tmpMeta168;
          modelica_metatype tmpMeta169;
          modelica_integer tmp170;
          modelica_metatype tmpMeta171;
          modelica_metatype tmpMeta172;
          modelica_metatype tmpMeta173;
          modelica_metatype tmpMeta174;
          modelica_metatype tmpMeta175;
          modelica_metatype tmpMeta176;
          modelica_metatype tmpMeta177;
          modelica_metatype tmpMeta178;
          modelica_metatype tmpMeta179;
          modelica_metatype tmpMeta180;
          modelica_metatype tmpMeta181;
          modelica_metatype tmpMeta182;
          modelica_metatype tmpMeta183;
          modelica_metatype tmpMeta184;
          modelica_metatype tmpMeta185;
          modelica_metatype tmpMeta186;
          modelica_metatype tmpMeta187;
          modelica_metatype tmpMeta188;
          modelica_metatype tmpMeta189;
          modelica_metatype tmpMeta190;
          modelica_metatype tmpMeta191;
          modelica_metatype tmpMeta192;
          modelica_metatype tmpMeta193;
          modelica_metatype tmpMeta194;
          modelica_metatype tmpMeta195;
          modelica_metatype tmpMeta196;
          modelica_metatype tmpMeta197;
          modelica_metatype tmpMeta198;
          modelica_metatype tmpMeta199;
          modelica_metatype tmpMeta200;
          modelica_metatype tmpMeta201;
          modelica_metatype tmpMeta202;
          modelica_metatype tmpMeta203;
          modelica_metatype tmpMeta204;
          modelica_metatype tmpMeta205;
          modelica_metatype tmpMeta206;
          /* Pattern matching succeeded */
          omc_ExecStat_execStat(threadData, _OMC_LIT791);

          _dlow = omc_BackendDAEUtil_markNonlinearIterationVariables(threadData, _inBackendDAE);

          if(isSome(_simSettingsOpt))
          {
            /* Pattern-matching assignment */
            tmpMeta13 = _simSettingsOpt;
            if (optionNone(tmpMeta13)) goto goto_9;
            tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
            _theSettings = tmpMeta14;

            _shared = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)));

            tmpMeta16 = mmc_mk_box2(4, &DAE_Exp_RCONST__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_theSettings), 5))));
            tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(22));
            memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[21] = mmc_mk_some(tmpMeta16);
            _shared = tmpMeta15;

            tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(4));
            memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_dlow), 4*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[3] = _shared;
            _dlow = tmpMeta17;
          }

          omc_System_tmpTickReset(threadData, ((modelica_integer) 0));

          _uniqueEqIndex = ((modelica_integer) 1);

          _ifcpp = (stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119));

          _backendMapping = omc_SimCodeUtil_setUpBackendMapping(threadData, _inBackendDAE);

          if(omc_Flags_isSet(threadData, _OMC_LIT794))
          {
            _dlow = omc_VisualXML_visualizationInfoXML(threadData, _dlow, _filenamePrefix, _program);
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT797))
          {
            omc_BackendDAEOptimize_listAllIterationVariables(threadData, _dlow);
          }

          if((!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT120))))
          {
            tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
            _initialEquations = omc_SimCodeUtil_createInitialEquations(threadData, _inInitDAE, _uniqueEqIndex, tmpMeta18 ,&_uniqueEqIndex ,&_tempvars);

            if(isSome(_inInitDAE_lambda0))
            {
              /* Pattern-matching assignment */
              tmpMeta19 = _inInitDAE_lambda0;
              if (optionNone(tmpMeta19)) goto goto_9;
              tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 1));
              _initDAE_lambda0 = tmpMeta20;

              _initialEquations_lambda0 = omc_SimCodeUtil_createInitialEquations__lambda0(threadData, _initDAE_lambda0, _uniqueEqIndex, _tempvars ,&_uniqueEqIndex ,&_tempvars);
            }
            else
            {
              tmpMeta21 = MMC_REFSTRUCTLIT(mmc_nil);
              _initialEquations_lambda0 = tmpMeta21;
            }

            /* Pattern-matching tuple assignment */
            tmpMeta26 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), mmc_mk_integer(((modelica_integer) 0)));
            tmpMeta27 = omc_SimCodeUtil_createNonlinearResidualEquations(threadData, _inRemovedInitialEquationLst, tmpMeta26, _tempvars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)))), 12))), &tmpMeta22, &tmpMeta25);
            _removedInitialEquations = tmpMeta27;
            tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
            tmp24 = mmc_unbox_integer(tmpMeta23);
            _uniqueEqIndex = tmp24  /* pattern as ty=Integer */;
            _tempvars = tmpMeta25;

            _removedInitialEquations = omc_SimCodeUtil_fixNonlinearResidualIndices(threadData, _removedInitialEquations);

            omc_ExecStat_execStat(threadData, _OMC_LIT798);
          }
          else
          {
            tmpMeta28 = MMC_REFSTRUCTLIT(mmc_nil);
            _initialEquations_lambda0 = tmpMeta28;

            tmpMeta29 = MMC_REFSTRUCTLIT(mmc_nil);
            _initialEquations = tmpMeta29;

            tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
            _removedInitialEquations = tmpMeta30;

            tmpMeta31 = MMC_REFSTRUCTLIT(mmc_nil);
            _tempvars = tmpMeta31;

            tmpMeta32 = MMC_REFSTRUCTLIT(mmc_nil);
            _omsiInitEquations = omc_SimCodeUtil_createAllEquationOMSI(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inInitDAE), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3))), tmpMeta32, _uniqueEqIndex ,&_uniqueEqIndex);
          }

          /* Pattern-matching assignment */
          tmpMeta33 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3)));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 8));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 9));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 13));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 16));
          _shared = tmpMeta33;
          _globalKnownVars = tmpMeta34;
          _constraints = tmpMeta35;
          _classAttributes = tmpMeta36;
          _eventInfo = tmpMeta37;
          _symJacs = tmpMeta38;

          _removedEqs = omc_BackendDAEUtil_collapseRemovedEqs(threadData, _dlow);

          _timeEvents = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 2)));

          
          
          
          { /* match expression */
            modelica_metatype tmp42_1;
            tmp42_1 = _eventInfo;
            {
              volatile mmc_switch_type tmp42;
              int tmp43;
              tmp42 = 0;
              for (; tmp42 < 1; tmp42++) {
                switch (MMC_SWITCH_CAST(tmp42)) {
                case 0: {
                  modelica_metatype tmpMeta44;
                  modelica_metatype tmpMeta45;
                  modelica_metatype tmpMeta46;
                  tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp42_1), 3));
                  tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp42_1), 4));
                  tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp42_1), 5));
                  
                  _zeroCrossingsSet = tmpMeta44;
                  _de_relations = tmpMeta45;
                  _sampleZCSet = tmpMeta46;
                  /* Pattern matching succeeded */
                  tmpMeta[0+0] = omc_ZeroCrossings_toList(threadData, _zeroCrossingsSet);
                  tmpMeta[0+1] = omc_DoubleEnded_toListNoCopyNoClear(threadData, _de_relations);
                  tmpMeta[0+2] = omc_ZeroCrossings_toList(threadData, _sampleZCSet);
                  goto tmp41_done;
                }
                }
                goto tmp41_end;
                tmp41_end: ;
              }
              goto goto_40;
              goto_40:;
              goto goto_9;
              goto tmp41_done;
              tmp41_done:;
            }
          }
          _zeroCrossings = tmpMeta[0+0];
          _relations = tmpMeta[0+1];
          _sampleZC = tmpMeta[0+2];

          if(_ifcpp)
          {
            _zeroCrossings = listAppend(_relations, _sampleZC);
          }

          _clockedSysts = omc_List_splitOnTrue(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 2))), boxvar_BackendDAEUtil_isClockedSyst ,&_contSysts);

          omc_ExecStat_execStat(threadData, _OMC_LIT799);

          if((omc_Flags_getConfigEnum(threadData, _OMC_LIT320) > ((modelica_integer) 0)))
          {
            _SymEuler_help = omc_Flags_getConfigEnum(threadData, _OMC_LIT320);

            omc_FlagsUtil_setConfigEnum(threadData, _OMC_LIT320, ((modelica_integer) 0));
          }

          if((!(stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT120))))
          {
            _uniqueEqIndex = omc_SimCodeUtil_createEquationsForSystems(threadData, _contSysts, _shared, _uniqueEqIndex, _zeroCrossings, _tempvars, ((modelica_integer) 1), _backendMapping, 1 /* true */ ,&_odeEquations ,&_algebraicEquations ,&_localKnownVars ,&_allEquations ,&_equationsForZeroCrossings ,&_tempvars ,&_equationSccMapping ,&_eqBackendSimCodeMapping ,&_backendMapping ,&_sccOffset);

            _omsiOptData = mmc_mk_none();
          }
          else
          {
            tmpMeta47 = MMC_REFSTRUCTLIT(mmc_nil);
            _odeEquations = tmpMeta47;

            tmpMeta48 = MMC_REFSTRUCTLIT(mmc_nil);
            _algebraicEquations = tmpMeta48;

            tmpMeta49 = MMC_REFSTRUCTLIT(mmc_nil);
            _localKnownVars = tmpMeta49;

            tmpMeta50 = MMC_REFSTRUCTLIT(mmc_nil);
            _allEquations = tmpMeta50;

            tmpMeta51 = MMC_REFSTRUCTLIT(mmc_nil);
            _equationsForZeroCrossings = tmpMeta51;

            tmpMeta52 = MMC_REFSTRUCTLIT(mmc_nil);
            _equationSccMapping = tmpMeta52;

            tmpMeta53 = MMC_REFSTRUCTLIT(mmc_nil);
            _eqBackendSimCodeMapping = tmpMeta53;

            _sccOffset = ((modelica_integer) 0);

            _omsiSimEquations = omc_SimCodeUtil_createAllEquationOMSI(threadData, _contSysts, _shared, _zeroCrossings, _uniqueEqIndex ,&_uniqueEqIndex);

            /* Pattern-matching assignment */
            tmpMeta54 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta55 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta54);
            tmpMeta56 = omc_BackendEquation_traverseEquationArray(threadData, _removedEqs, boxvar_SimCodeUtil_traversedlowEqToSimEqSystem, tmpMeta55);
            tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 1));
            tmp58 = mmc_unbox_integer(tmpMeta57);
            tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 2));
            _uniqueEqIndex = tmp58  /* pattern as ty=Integer */;
            _removedEquations = tmpMeta59;

            tmpMeta60 = MMC_TAGPTR(mmc_alloc_words(9));
            memcpy(MMC_UNTAGPTR(tmpMeta60), MMC_UNTAGPTR(_omsiSimEquations), 9*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta60))[2] = listAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_omsiSimEquations), 2))), _removedEquations);
            _omsiSimEquations = tmpMeta60;

            tmpMeta61 = mmc_mk_box3(3, &SimCode_OMSIData_OMSI__DATA__desc, _omsiInitEquations, _omsiSimEquations);
            _omsiOptData = mmc_mk_some(tmpMeta61);
          }

          if((_SymEuler_help > ((modelica_integer) 0)))
          {
            omc_FlagsUtil_setConfigEnum(threadData, _OMC_LIT320, _SymEuler_help);
          }

          tmpMeta62 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _equationSccMapping);
          _outMapping = tmpMeta62;

          omc_ExecStat_execStat(threadData, _OMC_LIT800);

          /* Pattern-matching assignment */
          tmpMeta63 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta64 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta63);
          tmpMeta65 = omc_BackendEquation_traverseEquationArray(threadData, _removedEqs, boxvar_SimCodeUtil_traversedlowEqToSimEqSystem, tmpMeta64);
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta65), 1));
          tmp67 = mmc_unbox_integer(tmpMeta66);
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta65), 2));
          _uniqueEqIndex = tmp67  /* pattern as ty=Integer */;
          _removedEquations = tmpMeta68;

          _clockedPartitions = omc_SimCodeUtil_translateClockedEquations(threadData, _clockedSysts, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3))), _sccOffset, _uniqueEqIndex, _backendMapping, _equationSccMapping, _eqBackendSimCodeMapping, _tempvars ,&_uniqueEqIndex ,&_backendMapping ,&_equationSccMapping ,&_eqBackendSimCodeMapping ,&_tempvars);

          /* Pattern-matching assignment */
          tmpMeta69 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta70 = mmc_mk_box3(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta69, _globalKnownVars);
          tmpMeta71 = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_createStartValueEquations, tmpMeta70);
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 1));
          tmp73 = mmc_unbox_integer(tmpMeta72);
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 2));
          _uniqueEqIndex = tmp73  /* pattern as ty=Integer */;
          _startValueEquations = tmpMeta74;

          /* Pattern-matching assignment */
          tmpMeta75 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _nominalValueEquations);
          tmpMeta76 = omc_SimCodeUtil_createValueEquationsShared(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3))), boxvar_SimCodeUtil_createInitialAssignmentsFromNominal, tmpMeta75);
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta76), 1));
          tmp78 = mmc_unbox_integer(tmpMeta77);
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta76), 2));
          _uniqueEqIndex = tmp78  /* pattern as ty=Integer */;
          _nominalValueEquations = tmpMeta79;

          /* Pattern-matching assignment */
          tmpMeta80 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _nominalValueEquations);
          tmpMeta81 = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_createNominalValueEquations, tmpMeta80);
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta81), 1));
          tmp83 = mmc_unbox_integer(tmpMeta82);
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta81), 2));
          _uniqueEqIndex = tmp83  /* pattern as ty=Integer */;
          _nominalValueEquations = tmpMeta84;

          /* Pattern-matching assignment */
          tmpMeta85 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _minValueEquations);
          tmpMeta86 = omc_SimCodeUtil_createValueEquationsShared(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3))), boxvar_SimCodeUtil_createInitialAssignmentsFromMin, tmpMeta85);
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 1));
          tmp88 = mmc_unbox_integer(tmpMeta87);
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 2));
          _uniqueEqIndex = tmp88  /* pattern as ty=Integer */;
          _minValueEquations = tmpMeta89;

          /* Pattern-matching assignment */
          tmpMeta90 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _minValueEquations);
          tmpMeta91 = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_createMinValueEquations, tmpMeta90);
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 1));
          tmp93 = mmc_unbox_integer(tmpMeta92);
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 2));
          _uniqueEqIndex = tmp93  /* pattern as ty=Integer */;
          _minValueEquations = tmpMeta94;

          /* Pattern-matching assignment */
          tmpMeta95 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _maxValueEquations);
          tmpMeta96 = omc_SimCodeUtil_createValueEquationsShared(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dlow), 3))), boxvar_SimCodeUtil_createInitialAssignmentsFromMax, tmpMeta95);
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta96), 1));
          tmp98 = mmc_unbox_integer(tmpMeta97);
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta96), 2));
          _uniqueEqIndex = tmp98  /* pattern as ty=Integer */;
          _maxValueEquations = tmpMeta99;

          /* Pattern-matching assignment */
          tmpMeta100 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), _maxValueEquations);
          tmpMeta101 = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_createMaxValueEquations, tmpMeta100);
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta101), 1));
          tmp103 = mmc_unbox_integer(tmpMeta102);
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta101), 2));
          _uniqueEqIndex = tmp103  /* pattern as ty=Integer */;
          _maxValueEquations = tmpMeta104;

          _uniqueEqIndex = omc_SimCodeUtil_createParameterEquations(threadData, _uniqueEqIndex, _parameterEquations, _globalKnownVars ,&_parameterEquations ,&_numberofFixedParameters);

          /* Pattern-matching assignment */
          tmpMeta105 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta106 = mmc_mk_box2(0, mmc_mk_integer(_uniqueEqIndex), tmpMeta105);
          tmpMeta107 = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_createAlgorithmAndEquationAsserts, tmpMeta106);
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta107), 1));
          tmp109 = mmc_unbox_integer(tmpMeta108);
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta107), 2));
          _uniqueEqIndex = tmp109  /* pattern as ty=Integer */;
          _algorithmAndEquationAsserts = tmpMeta110;

          tmpMeta111 = MMC_REFSTRUCTLIT(mmc_nil);
          _discreteModelVars = omc_BackendDAEUtil_foldEqSystem(threadData, _dlow, boxvar_SimCodeUtil_extractDiscreteModelVars, tmpMeta111);

          _makefileParams = omc_SimCodeFunctionUtil_createMakefileParams(threadData, _includeDirs, _libs, _libPaths, 0 /* false */, _isFMU);

          _delayedExps = omc_SimCodeUtil_extractDelayedExpressions(threadData, _dlow ,&_maxDelayedExpIndex);

          _spatialInfo = omc_SimCodeUtil_extractSpatialDistributionInfo(threadData, _dlow);

          omc_ExecStat_execStat(threadData, _OMC_LIT801);

          _algebraicEquations = omc_List_appendElt(threadData, listReverse(_removedEquations), listReverse(_algebraicEquations));

          _allEquations = omc_List_append__reverse(threadData, _allEquations, _removedEquations);

          if(isSome(_inInlineData))
          {
            /* Pattern-matching assignment */
            tmpMeta112 = _inInlineData;
            if (optionNone(tmpMeta112)) goto goto_9;
            tmpMeta113 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 1));
            _inlineData = tmpMeta113;

            tmpMeta114 = MMC_REFSTRUCTLIT(mmc_nil);
            _uniqueEqIndex = omc_SimCodeUtil_createEquationsForSystems(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inlineData), 2))), _shared, _uniqueEqIndex, tmpMeta114, _tempvars, _uniqueEqIndex, _OMC_LIT205, 0 /* false */ ,&_inlineEquationsTemp ,NULL ,NULL ,NULL ,NULL ,&_tempvars ,NULL ,NULL ,NULL ,NULL);

            _inlineEquations = omc_List_flatten(threadData, _inlineEquationsTemp);
          }
          else
          {
            tmpMeta115 = MMC_REFSTRUCTLIT(mmc_nil);
            _inlineEquations = tmpMeta115;
          }

          tmpMeta116 = MMC_REFSTRUCTLIT(mmc_nil);
          _dlow = omc_SimCodeUtil_createStateSets(threadData, _dlow, tmpMeta116, _uniqueEqIndex, _tempvars ,&_stateSets ,&_uniqueEqIndex ,&_tempvars ,&_numStateSets);

          tmpMeta117 = MMC_REFSTRUCTLIT(mmc_nil);
          _modelInfo = omc_SimCodeUtil_createModelInfo(threadData, _inClassName, _program, _dlow, _inInitDAE, _functions, tmpMeta117, _numStateSets, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_spatialInfo), 3)))), _inFileDir, listLength(_clockedSysts), _tempvars);

          if((_ifcpp && omc_Flags_getConfigBool(threadData, _OMC_LIT807)))
          {
            omc_FlagsUtil_setConfigBool(threadData, _OMC_LIT804, 1 /* true */);
          }

          if(_ifcpp)
          {
            if(omc_Flags_getConfigBool(threadData, _OMC_LIT804))
            {
              tmpMeta118 = MMC_REFSTRUCTLIT(mmc_nil);
              _allEquations = omc_ReduceDAE_buildLabels(threadData, _allEquations, _modelInfo, tmpMeta118, _args ,&_modelInfo);
            }
          }

          _tmpSimVars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

          if(_ifcpp)
          {
            if(omc_Flags_getConfigBool(threadData, _OMC_LIT810))
            {
              _allEquations = omc_ReduceDAE_reduceTerms(threadData, _allEquations, _modelInfo, _args ,&_modelInfo);

              omc_FlagsUtil_setConfigBool(threadData, _OMC_LIT810, 0 /* false */);

              omc_FlagsUtil_disableDebug(threadData, _OMC_LIT813);
            }
          }

          _extObjInfo = omc_SimCodeUtil_createExtObjInfo(threadData, _shared);

          _zeroCrossings = omc_SimCodeUtil_updateZeroCrossEqnIndex(threadData, _zeroCrossings, _eqBackendSimCodeMapping, omc_BackendDAEUtil_equationArraySizeBDAE(threadData, _dlow));

          tmpMeta119 = MMC_REFSTRUCTLIT(mmc_nil);
          _SymbolicJacsNLS = tmpMeta119;

          _initialEquations = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, _initialEquations, _modelInfo, 1 /* true */ ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          _initialEquations_lambda0 = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, _initialEquations_lambda0, _modelInfo, 1 /* true */ ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          _parameterEquations = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, _parameterEquations, _modelInfo, 1 /* true */ ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          _allEquations = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, _allEquations, _modelInfo, 1 /* true */ ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          _clockedPartitions = omc_SimCodeUtil_addAlgebraicLoopsClockPartitions(threadData, _clockedPartitions, _modelInfo ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          _inlineEquations = omc_SimCodeUtil_addAlgebraicLoopsModelInfo(threadData, _inlineEquations, _modelInfo, 1 /* true */ ,&_modelInfo ,&_SymbolicJacsTemp);

          _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

          if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20)))))
          {
            /* Pattern-matching assignment */
            tmpMeta120 = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20))));
            tmpMeta121 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 2));
            tmpMeta122 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 3));
            tmpMeta123 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 4));
            tmpMeta124 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 5));
            tmpMeta125 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 6));
            tmpMeta126 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta120), 7));
            tmp127 = mmc_unbox_integer(tmpMeta126);
            _dataReconJac = tmpMeta121;
            _setcVars = tmpMeta122;
            _datareconinputvars = tmpMeta123;
            _setBVars = tmpMeta124;
            _dataReconJacH = tmpMeta125;
            _numRelatedBoundaryConditions = tmp127  /* pattern as ty=Integer */;

            /* Pattern-matching tuple assignment */
            tmpMeta130 = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, _dataReconJac, _uniqueEqIndex, _tempvars, 0 /* false */, &tmp128, &tmpMeta129);
            if (optionNone(tmpMeta130)) goto goto_9;
            tmpMeta131 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta130), 1));
            _dataReconSimJac = tmpMeta131;
            _uniqueEqIndex = tmp128;
            _tempvars = tmpMeta129;

            if(isSome(_dataReconJacH))
            {
              /* Pattern-matching tuple assignment */
              tmpMeta134 = omc_SimCodeUtil_createSymbolicSimulationJacobian(threadData, omc_Util_getOption(threadData, _dataReconJacH), _uniqueEqIndex, _tempvars, 0 /* false */, &tmp132, &tmpMeta133);
              if (optionNone(tmpMeta134)) goto goto_9;
              tmpMeta135 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta134), 1));
              _dataReconSimJacH = tmpMeta135;
              _uniqueEqIndex = tmp132;
              _tempvars = tmpMeta133;

              tmpMeta136 = mmc_mk_cons(_dataReconSimJac, mmc_mk_cons(_dataReconSimJacH, MMC_REFSTRUCTLIT(mmc_nil)));
              _SymbolicJacsdatarecon = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta136, _modelInfo ,&_modelInfo ,&_SymbolicJacsTemp);
            }
            else
            {
              tmpMeta137 = mmc_mk_cons(_dataReconSimJac, MMC_REFSTRUCTLIT(mmc_nil));
              _SymbolicJacsdatarecon = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, tmpMeta137, _modelInfo ,&_modelInfo ,&_SymbolicJacsTemp);
            }

            _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);

            omc_BackendDAEOptimize_listAllIterationVariables0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inInitDAE), 2))) ,&_iterationVarsLst1);

            omc_BackendDAEOptimize_listAllIterationVariables0(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inBackendDAE), 2))) ,&_iterationVarsLst2);

            _iterationVarsLst1 = omc_List_unique(threadData, listAppend(_iterationVarsLst1, _iterationVarsLst2));

            tmpMeta138 = stringAppend(_OMC_LIT814,intString(listLength(_iterationVarsLst1)));
            tmpMeta139 = stringAppend(tmpMeta138,_OMC_LIT815);
            tmpMeta140 = stringAppend(tmpMeta139,_OMC_LIT816);
            _iterationVarsStr = tmpMeta140;

            if(listEmpty(_iterationVarsLst1))
            {
              tmpMeta141 = stringAppend(_iterationVarsStr,_OMC_LIT817);
              _iterationVarsStr = tmpMeta141;
            }
            else
            {
              {
                modelica_metatype _var;
                for (tmpMeta142 = _iterationVarsLst1; !listEmpty(tmpMeta142); tmpMeta142=MMC_CDR(tmpMeta142))
                {
                  _var = MMC_CAR(tmpMeta142);
                  tmpMeta143 = stringAppend(_iterationVarsStr,omc_ComponentReference_crefStr(threadData, _var));
                  tmpMeta144 = stringAppend(tmpMeta143,_OMC_LIT48);
                  _iterationVarsStr = tmpMeta144;
                }
              }
            }

            tmpMeta146 = stringAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 17)))), 3))),_OMC_LIT818);
            omc_System_writeFile(threadData, tmpMeta146, _iterationVarsStr);
          }

          _stateSets = omc_SimCodeUtil_addAlgebraicLoopsModelInfoStateSets(threadData, _stateSets, _modelInfo ,&_modelInfo ,&_SymbolicJacsStateSelect ,&_SymbolicJacsStateSelectInternal);

          if(omc_FMI_isFMIVersion20(threadData, _FMUVersion))
          {
            _SymbolicJacsFMI = omc_SimCodeUtil_createFMIModelStructure(threadData, _inFMIDer, _modelInfo, _uniqueEqIndex, _inInitDAE, _inBackendDAE ,&_modelStructure ,&_modelInfo ,&_SymbolicJacsTemp ,&_uniqueEqIndex);

            _SymbolicJacsNLS = listAppend(_SymbolicJacsTemp, _SymbolicJacsNLS);
          }

          if(_isFMU)
          {
            _fmiSimulationFlags = omc_SimCodeUtil_createFMISimulationFlags(threadData, 1 /* true */);
          }

          _LinearMatrices = omc_SimCodeUtil_createJacobianLinearCode(threadData, _symJacs, _modelInfo, _uniqueEqIndex, _shared ,&_uniqueEqIndex);

          _SymbolicJacs = omc_SimCodeUtil_addAlgebraicLoopsModelInfoSymJacs(threadData, _LinearMatrices, _modelInfo ,&_modelInfo ,&_SymbolicJacsTemp);

          tmpMeta147 = mmc_mk_cons(_SymbolicJacsFMI, mmc_mk_cons(_SymbolicJacs, mmc_mk_cons(_SymbolicJacsStateSelect, mmc_mk_cons(_SymbolicJacsdatarecon, MMC_REFSTRUCTLIT(mmc_nil)))));
          _SymbolicJacs = omc_List_flatten(threadData, tmpMeta147);

          _delayedExps = omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData, _delayedExps, _maxDelayedExpIndex, _SymbolicJacsNLS ,&_maxDelayedExpIndex ,&_SymbolicJacsNLS);

          _delayedExps = omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData, _delayedExps, _maxDelayedExpIndex, _SymbolicJacs ,&_maxDelayedExpIndex ,&_SymbolicJacs);

          _delayedExps = omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData, _delayedExps, _maxDelayedExpIndex, _SymbolicJacsTemp ,&_maxDelayedExpIndex ,&_SymbolicJacsTemp);

          _delayedExps = omc_SimCodeUtil_extractJacobianDelayedExpressions(threadData, _delayedExps, _maxDelayedExpIndex, _SymbolicJacsStateSelectInternal ,&_maxDelayedExpIndex ,&_SymbolicJacsStateSelectInternal);

          _jacobianEquations = omc_SimCodeUtil_collectAllJacobianEquations(threadData, _SymbolicJacs);

          tmpMeta148 = mmc_mk_cons(listReverse(_SymbolicJacsNLS), mmc_mk_cons(_SymbolicJacs, mmc_mk_cons(_SymbolicJacsTemp, mmc_mk_cons(_SymbolicJacsStateSelectInternal, MMC_REFSTRUCTLIT(mmc_nil)))));
          _SymbolicJacs = omc_List_flatten(threadData, tmpMeta148);

          _jacobianSimvars = omc_SimCodeUtil_collectAllJacobianVars(threadData, _SymbolicJacs);

          _modelInfo = omc_SimCodeUtil_setJacobianVars(threadData, _jacobianSimvars, _modelInfo);

          _seedVars = omc_SimCodeUtil_collectAllSeedVars(threadData, _SymbolicJacs);

          _modelInfo = omc_SimCodeUtil_setSeedVars(threadData, _seedVars, _modelInfo);

          omc_ExecStat_execStat(threadData, _OMC_LIT819);

          _systemIndexMap = omc_List_fold(threadData, _allEquations, boxvar_SimCodeUtil_getSystemIndexMap, arrayCreate(_uniqueEqIndex, mmc_mk_integer(((modelica_integer) -1))));

          _odeEquations = omc_List_map1List(threadData, _odeEquations, boxvar_SimCodeUtil_setSystemIndexMap, _systemIndexMap);

          _algebraicEquations = omc_List_map1List(threadData, _algebraicEquations, boxvar_SimCodeUtil_setSystemIndexMap, _systemIndexMap);

          _modelInfo = omc_SimCodeUtil_addNumEqns(threadData, _modelInfo, _uniqueEqIndex);

          _odeEquations = omc_SimCodeUtil_makeEqualLengthLists(threadData, _odeEquations, omc_Config_noProc(threadData));

          _algebraicEquations = omc_SimCodeUtil_makeEqualLengthLists(threadData, _algebraicEquations, omc_Config_noProc(threadData));

          _odeEquations = omc_List_filterOnFalse(threadData, _odeEquations, boxvar_listEmpty);

          _algebraicEquations = omc_List_filterOnFalse(threadData, _algebraicEquations, boxvar_listEmpty);

          if(omc_Flags_isSet(threadData, _OMC_LIT823))
          {
            tmpMeta149 = stringAppend(_OMC_LIT820,realString(mmc_clock()));
            tmpMeta150 = stringAppend(tmpMeta149,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta150),stdout);
          }

          _crefToSimVarHT = omc_SimCodeUtil_createCrefToSimVarHT(threadData, _modelInfo);

          if(omc_Flags_isSet(threadData, _OMC_LIT823))
          {
            tmpMeta151 = stringAppend(_OMC_LIT824,realString(mmc_clock()));
            tmpMeta152 = stringAppend(tmpMeta151,_OMC_LIT48);
            fputs(MMC_STRINGDATA(tmpMeta152),stdout);
          }

          if((omc_Flags_getConfigEnum(threadData, _OMC_LIT320) > ((modelica_integer) 0)))
          {
            /* Pattern-matching assignment */
            tmpMeta153 = _inInlineData;
            if (optionNone(tmpMeta153)) goto goto_9;
            tmpMeta154 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta153), 1));
            _inlineData = tmpMeta154;

            _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

            _inlineSimKnVars = omc_SimCodeUtil_adjustStatesForInlineSolver(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)))), 2))));

            /* Pattern-matching tuple assignment */
            tmpMeta155 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta156 = omc_BackendVariable_getVar(threadData, omc_ComponentReferenceBasics_makeCrefIdent(threadData, _OMC_LIT825, _OMC_LIT86, tmpMeta155), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inlineData), 3))), NULL);
            if (listEmpty(tmpMeta156)) goto goto_9;
            tmpMeta157 = MMC_CAR(tmpMeta156);
            tmpMeta158 = MMC_CDR(tmpMeta156);
            if (!listEmpty(tmpMeta158)) goto goto_9;
            _dtVar = tmpMeta157;

            _dtSimVar = omc_SimCodeUtil_dlowvarToSimvar(threadData, _dtVar, mmc_mk_none(), _emptyVars, mmc_mk_none());

            tmpMeta159 = MMC_TAGPTR(mmc_alloc_words(33));
            memcpy(MMC_UNTAGPTR(tmpMeta159), MMC_UNTAGPTR(_dtSimVar), 33*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta159))[7] = mmc_mk_integer(listLength(_inlineSimKnVars));
            _dtSimVar = tmpMeta159;

            tmpMeta160 = mmc_mk_cons(_dtSimVar, _inlineSimKnVars);
            _inlineSimKnVars = tmpMeta160;

            _crefToSimVarHT = omc_List_fold(threadData, _inlineSimKnVars, boxvar_HashTableCrefSimVar_addSimVarToHashTable, _crefToSimVarHT);
          }

          if(omc_Flags_getConfigBool(threadData, _OMC_LIT828))
          {
            _tmpSimVars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

            _sensitivityVars = omc_SimCodeUtil_createSimVarsForSensitivities(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpSimVars), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_tmpSimVars), 13))), _numberofFixedParameters ,&_countSenParams);

            _sensitivityVars = omc_SimCodeUtil_rewriteIndex(threadData, _sensitivityVars, ((modelica_integer) 0), NULL);

            tmpMeta161 = MMC_TAGPTR(mmc_alloc_words(32));
            memcpy(MMC_UNTAGPTR(tmpMeta161), MMC_UNTAGPTR(_tmpSimVars), 32*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta161))[28] = _sensitivityVars;
            _tmpSimVars = tmpMeta161;

            tmpMeta162 = MMC_TAGPTR(mmc_alloc_words(23));
            memcpy(MMC_UNTAGPTR(tmpMeta162), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta162))[11] = _tmpSimVars;
            _modelInfo = tmpMeta162;

            _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));

            tmpMeta163 = MMC_TAGPTR(mmc_alloc_words(37));
            memcpy(MMC_UNTAGPTR(tmpMeta163), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta163))[31] = mmc_mk_integer(_countSenParams);
            _varInfo = tmpMeta163;

            tmpMeta164 = MMC_TAGPTR(mmc_alloc_words(23));
            memcpy(MMC_UNTAGPTR(tmpMeta164), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta164))[10] = _varInfo;
            _modelInfo = tmpMeta164;
          }

          if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20)))))
          {
            _tmpSimVars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 11)));

            /* Pattern-matching assignment */
            tmpMeta165 = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 20))));
            tmpMeta166 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta165), 3));
            tmpMeta167 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta165), 4));
            tmpMeta168 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta165), 5));
            tmpMeta169 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta165), 7));
            tmp170 = mmc_unbox_integer(tmpMeta169);
            _setcVars = tmpMeta166;
            _datareconinputvars = tmpMeta167;
            _setBVars = tmpMeta168;
            _numRelatedBoundaryConditions = tmp170  /* pattern as ty=Integer */;

            _emptyVars = omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013));

            /* Pattern-matching assignment */
            tmpMeta171 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta172 = mmc_mk_box2(0, tmpMeta171, _emptyVars);
            tmpMeta173 = omc_BackendVariable_traverseBackendDAEVars(threadData, _setcVars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta172);
            tmpMeta174 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta173), 1));
            _tmpsetcVars = tmpMeta174;

            _tmpsetcVars = omc_SimCodeUtil_rewriteIndex(threadData, _tmpsetcVars, ((modelica_integer) 0), NULL);

            tmpMeta175 = MMC_TAGPTR(mmc_alloc_words(32));
            memcpy(MMC_UNTAGPTR(tmpMeta175), MMC_UNTAGPTR(_tmpSimVars), 32*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta175))[29] = _tmpsetcVars;
            _tmpSimVars = tmpMeta175;

            tmpMeta176 = MMC_TAGPTR(mmc_alloc_words(23));
            memcpy(MMC_UNTAGPTR(tmpMeta176), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta176))[11] = _tmpSimVars;
            _modelInfo = tmpMeta176;

            /* Pattern-matching assignment */
            tmpMeta177 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta178 = mmc_mk_box2(0, tmpMeta177, _emptyVars);
            tmpMeta179 = omc_BackendVariable_traverseBackendDAEVars(threadData, _datareconinputvars, boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta178);
            tmpMeta180 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta179), 1));
            _tmpdatareconinputvars = tmpMeta180;

            _tmpdatareconinputvars = omc_SimCodeUtil_rewriteIndex(threadData, listReverse(_tmpdatareconinputvars), ((modelica_integer) 0), NULL);

            tmpMeta181 = MMC_TAGPTR(mmc_alloc_words(32));
            memcpy(MMC_UNTAGPTR(tmpMeta181), MMC_UNTAGPTR(_tmpSimVars), 32*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta181))[30] = _tmpdatareconinputvars;
            _tmpSimVars = tmpMeta181;

            tmpMeta182 = MMC_TAGPTR(mmc_alloc_words(23));
            memcpy(MMC_UNTAGPTR(tmpMeta182), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta182))[11] = _tmpSimVars;
            _modelInfo = tmpMeta182;

            if(isSome(_setBVars))
            {
              /* Pattern-matching assignment */
              tmpMeta183 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta184 = mmc_mk_box2(0, tmpMeta183, _emptyVars);
              tmpMeta185 = omc_BackendVariable_traverseBackendDAEVars(threadData, omc_Util_getOption(threadData, _setBVars), boxvar_SimCodeUtil_traversingdlowvarToSimvar, tmpMeta184);
              tmpMeta186 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta185), 1));
              _tmpsetBVars = tmpMeta186;

              _tmpsetBVars = omc_SimCodeUtil_rewriteIndex(threadData, _tmpsetBVars, ((modelica_integer) 0), NULL);

              tmpMeta187 = MMC_TAGPTR(mmc_alloc_words(32));
              memcpy(MMC_UNTAGPTR(tmpMeta187), MMC_UNTAGPTR(_tmpSimVars), 32*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta187))[31] = _tmpsetBVars;
              _tmpSimVars = tmpMeta187;

              tmpMeta188 = MMC_TAGPTR(mmc_alloc_words(23));
              memcpy(MMC_UNTAGPTR(tmpMeta188), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta188))[11] = _tmpSimVars;
              _modelInfo = tmpMeta188;

              _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));

              tmpMeta189 = MMC_TAGPTR(mmc_alloc_words(37));
              memcpy(MMC_UNTAGPTR(tmpMeta189), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta189))[35] = mmc_mk_integer(listLength(_tmpsetBVars));
              _varInfo = tmpMeta189;

              tmpMeta190 = MMC_TAGPTR(mmc_alloc_words(23));
              memcpy(MMC_UNTAGPTR(tmpMeta190), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta190))[10] = _varInfo;
              _modelInfo = tmpMeta190;
            }

            _varInfo = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_modelInfo), 10)));

            tmpMeta191 = MMC_TAGPTR(mmc_alloc_words(37));
            memcpy(MMC_UNTAGPTR(tmpMeta191), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta191))[32] = mmc_mk_integer(listLength(_tmpsetcVars));
            _varInfo = tmpMeta191;

            tmpMeta192 = MMC_TAGPTR(mmc_alloc_words(37));
            memcpy(MMC_UNTAGPTR(tmpMeta192), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta192))[33] = mmc_mk_integer(listLength(_tmpdatareconinputvars));
            _varInfo = tmpMeta192;

            tmpMeta193 = MMC_TAGPTR(mmc_alloc_words(37));
            memcpy(MMC_UNTAGPTR(tmpMeta193), MMC_UNTAGPTR(_varInfo), 37*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta193))[36] = mmc_mk_integer(_numRelatedBoundaryConditions);
            _varInfo = tmpMeta193;

            tmpMeta194 = MMC_TAGPTR(mmc_alloc_words(23));
            memcpy(MMC_UNTAGPTR(tmpMeta194), MMC_UNTAGPTR(_modelInfo), 23*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta194))[10] = _varInfo;
            _modelInfo = tmpMeta194;
          }

          _backendMapping = omc_SimCodeUtil_setBackendVarMapping(threadData, _inBackendDAE, _crefToSimVarHT, _modelInfo, _backendMapping);

          _varToArrayIndexMapping = omc_SimCodeUtilShared_createVarToArrayIndexMapping(threadData, _modelInfo ,&_varToIndexMapping);

          /* Pattern-matching assignment */
          tmpMeta195 = mmc_mk_box2(0, omc_HashTable_emptyHashTable(threadData), mmc_mk_integer(((modelica_integer) 1)));
          tmpMeta196 = omc_List_fold(threadData, listReverse((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inBackendDAE), 2)))), boxvar_SimCodeUtil_collectClockedVars, tmpMeta195);
          tmpMeta197 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta196), 1));
          _crefToClockIndexHT = tmpMeta197;

          omc_ExecStat_execStat(threadData, _OMC_LIT829);

          if((!stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT119)))
          {
            _reasonableSize = omc_Util_nextPrime(threadData, ((modelica_integer) 10) + ((modelica_integer)floor((1.4) * (((modelica_real)omc_BackendDAEUtil_equationArraySizeBDAE(threadData, _inBackendDAE) + omc_BackendDAEUtil_equationArraySizeBDAE(threadData, _inInitDAE) + listLength(_parameterEquations))))));

            _eqCache = omc_HashTableSimCodeEqCache_emptyHashTableSized(threadData, _reasonableSize);

            _allEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _allEquations, _eqCache ,&_eqCache);

            _odeEquations = omc_SimCodeUtil_aliasSimEqSystems(threadData, _odeEquations, _eqCache ,&_eqCache);

            _algebraicEquations = omc_SimCodeUtil_aliasSimEqSystems(threadData, _algebraicEquations, _eqCache ,&_eqCache);

            _initialEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _initialEquations, _eqCache ,&_eqCache);

            _initialEquations_lambda0 = omc_SimCodeUtil_aliasSimEqs(threadData, _initialEquations_lambda0, _eqCache ,&_eqCache);

            _removedEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _removedEquations, _eqCache ,&_eqCache);

            _removedInitialEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _removedInitialEquations, _eqCache ,&_eqCache);

            _algorithmAndEquationAsserts = omc_SimCodeUtil_aliasSimEqs(threadData, _algorithmAndEquationAsserts, _eqCache ,&_eqCache);

            _jacobianEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _jacobianEquations, _eqCache ,&_eqCache);

            _parameterEquations = omc_SimCodeUtil_aliasSimEqs(threadData, _parameterEquations, _eqCache ,&_eqCache);

            omc_ExecStat_execStat(threadData, _OMC_LIT830);
          }

          _fileNamePrefixHash = omc_Util_hashFileNamePrefix(threadData, _filenamePrefix);

          if(_isFMU)
          {
            if((stringEqual(omc_Config_simCodeTarget(threadData), _OMC_LIT120)))
            {
              tmpMeta198 = stringAppend(_fileNamePrefixHash,_OMC_LIT832);
              _fullPathPrefix = tmpMeta198;
            }
            else
            {
              tmpMeta199 = stringAppend(_fileNamePrefixHash,_OMC_LIT831);
              _fullPathPrefix = tmpMeta199;
            }
          }
          else
          {
            _fullPathPrefix = _OMC_LIT31;
          }

          tmpMeta200 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta201 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta202 = mmc_mk_box3(3, &SimCode_DelayedExpression_DELAYED__EXPRESSIONS__desc, _delayedExps, mmc_mk_integer(_maxDelayedExpIndex));
          tmpMeta203 = mmc_mk_box(53, 3, &SimCode_SimCode_SIMCODE__desc, _modelInfo, tmpMeta200, _recordDecls, _externalFunctionIncludes, tmpMeta201, _localKnownVars, _allEquations, _odeEquations, _algebraicEquations, _clockedPartitions, _initialEquations, _initialEquations_lambda0, _removedInitialEquations, _startValueEquations, _nominalValueEquations, _minValueEquations, _maxValueEquations, _parameterEquations, _removedEquations, _algorithmAndEquationAsserts, _equationsForZeroCrossings, _jacobianEquations, _stateSets, _constraints, _classAttributes, omc_ZeroCrossings_updateIndices(threadData, _zeroCrossings), omc_ZeroCrossings_updateIndices(threadData, _relations), _timeEvents, _discreteModelVars, _extObjInfo, _makefileParams, tmpMeta202, _spatialInfo, _SymbolicJacs, _simSettingsOpt, _filenamePrefix, _fullPathPrefix, _fmuTargetName, _OMC_LIT833, (_isFMU?omc_SimCodeUtil_getValueReferenceMapping(threadData, _modelInfo):_OMC_LIT80), _varToArrayIndexMapping, _varToIndexMapping, _crefToSimVarHT, _crefToClockIndexHT, mmc_mk_some(_backendMapping), _modelStructure, _fmiSimulationFlags, _OMC_LIT834, mmc_mk_none(), _inlineEquations, _omsiOptData, mmc_mk_boolean(1 /* true */));
          _simCode = tmpMeta203;

          /* Pattern-matching tuple assignment */
          tmpMeta206 = omc_SimCodeUtil_traverseExpsSimCode(threadData, _simCode, boxvar_SimCodeFunctionUtil_findLiteralsHelper, _literals, &tmpMeta204);
          _simCode = tmpMeta206;
          tmpMeta205 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta204), 3));
          _lits = tmpMeta205;

          _simCode = omc_SimCodeUtil_setSimCodeLiterals(threadData, _simCode, listReverse(_lits));

          omc_ExecStat_execStat(threadData, _OMC_LIT835);

          if(omc_Flags_isSet(threadData, _OMC_LIT838))
          {
            omc_SimCodeUtil_dumpSimCodeDebug(threadData, _simCode);
          }
          goto tmp10_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT839, _OMC_LIT840);

          goto goto_9;
          goto tmp10_done;
        }
        }
        goto tmp10_end;
        tmp10_end: ;
      }
      goto goto_9;
      tmp10_done:
      (void)tmp11;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp10_done2;
      goto_9:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp11 < 2) {
        goto tmp10_top;
      }
      MMC_THROW_INTERNAL();
      tmp10_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_outMapping) { *out_outMapping = _outMapping; }
  return _simCode;
}
modelica_metatype boxptr_SimCodeUtil_createSimCode(threadData_t *threadData, modelica_metatype _inBackendDAE, modelica_metatype _inInitDAE, modelica_metatype _inInitDAE_lambda0, modelica_metatype _inInlineData, modelica_metatype _inRemovedInitialEquationLst, modelica_metatype _inClassName, modelica_metatype _filenamePrefix, modelica_metatype _inFileDir, modelica_metatype _functions, modelica_metatype _externalFunctionIncludes, modelica_metatype _includeDirs, modelica_metatype _libs, modelica_metatype _libPaths, modelica_metatype _program, modelica_metatype _simSettingsOpt, modelica_metatype _recordDecls, modelica_metatype _literals, modelica_metatype _args, modelica_metatype _isFMU, modelica_metatype _FMUVersion, modelica_metatype _fmuTargetName, modelica_metatype _inFMIDer, modelica_metatype *out_outMapping)
{
  modelica_integer tmp1;
  modelica_metatype _simCode = NULL;
  tmp1 = mmc_unbox_integer(_isFMU);
  _simCode = omc_SimCodeUtil_createSimCode(threadData, _inBackendDAE, _inInitDAE, _inInitDAE_lambda0, _inInlineData, _inRemovedInitialEquationLst, _inClassName, _filenamePrefix, _inFileDir, _functions, _externalFunctionIncludes, _includeDirs, _libs, _libPaths, _program, _simSettingsOpt, _recordDecls, _literals, _args, tmp1, _FMUVersion, _fmuTargetName, _inFMIDer, out_outMapping);
  /* skip box _simCode; SimCode.SimCode */
  /* skip box _outMapping; tuple<#Integer, list<tuple<#Integer, #Integer>>> */
  return _simCode;
}

DLLDirection
modelica_boolean omc_SimCodeUtil_compareEqSystemsEquality(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _eq1;
    tmp4_2 = _eq2;
    {
      modelica_metatype _stmt1 = NULL;
      modelica_metatype _stmt2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stmt1 has no default value.
      // _stmt2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = ((((modelica_integer) 0) == omc_ComponentReferenceBasics_crefCompareGeneric(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq1), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq2), 3)))))?omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq1), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq2), 4)))):0 /* false */);
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = (omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq1), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq2), 3))))?omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq1), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq2), 4)))):0 /* false */);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,8,4) == 0) goto tmp3_end;
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,3) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (listEmpty(tmpMeta9)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmpMeta9);
          tmpMeta11 = MMC_CDR(tmpMeta9);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,8,4) == 0) goto tmp3_end;
          if (!listEmpty(tmpMeta11)) goto tmp3_end;
          
          _stmt1 = tmpMeta7;
          _stmt2 = tmpMeta10;
          /* Pattern matching succeeded */
          tmp1 = (omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt1), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt2), 2))))?(omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt1), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt2), 3))))?omc_ExpressionBasics_expEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt1), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt2), 4)))):0 /* false */):0 /* false */);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_SimCodeUtil_compareEqSystemsEquality(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_compareEqSystemsEquality(threadData, _eq1, _eq2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_integer omc_SimCodeUtil_hashEqSystem(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _hash;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _hash has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _stmt = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stmt has no default value.
      tmp4 = 0;
      for (; tmp4 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))));
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 5))));
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,7) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 6))));
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ComponentReferenceBasics_hashComponentRef(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3)))) + (((modelica_integer) 7)) * (omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4)))));
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,6) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ComponentReferenceBasics_hashComponentRef(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3)))) + (((modelica_integer) 7)) * (omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4)))));
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3)))) + (((modelica_integer) 7)) * (omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4)))));
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,8,4) == 0) goto tmp3_end;
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          
          _stmt = tmpMeta7;
          /* Pattern matching succeeded */
          tmp1 = omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt), 2)))) + (((modelica_integer) 7)) * (omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt), 3))))) + (((modelica_integer) 49)) * (omc_ExpressionBasics_hashExp(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt), 4)))));
          goto tmp3_done;
        }
        case 7: {
          
          /* Pattern matching succeeded */
          tmp1 = valueConstructor(_eq);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _hash = tmp1;
  _return: OMC_LABEL_UNUSED
  return _hash;
}
modelica_metatype boxptr_SimCodeUtil_hashEqSystem(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _hash;
  modelica_metatype out_hash;
  _hash = omc_SimCodeUtil_hashEqSystem(threadData, _eq);
  out_hash = mmc_mk_icon(_hash);
  return out_hash;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_SimCodeUtil_expandEntwined(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _eqs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta6 = mmc_mk_cons(_eq, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))));
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_cons(_eq, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _eqs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _eqs;
}

DLLDirection
modelica_metatype omc_SimCodeUtil_sortEqSystems(threadData_t *threadData, modelica_metatype _eqs)
{
  modelica_metatype _outEqs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqs has no default value.
  {
    modelica_metatype __omcQ_24tmpVar75;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar74;
    modelica_integer tmp4;
    modelica_metatype _eq_loopVar = 0;
    modelica_metatype _eq;
    _eq_loopVar = _eqs;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar75 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar75;
    while(1) {
      tmp4 = 1;
      if (!listEmpty(_eq_loopVar)) {
        _eq = MMC_CAR(_eq_loopVar);
        _eq_loopVar = MMC_CDR(_eq_loopVar);
        tmp4--;
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar74 = omc_SimCodeUtil_expandEntwined(threadData, _eq);
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar74,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar75;
  }
  _outEqs = omc_List_flatten(threadData, tmpMeta1);

  _outEqs = omc_List_sort(threadData, _outEqs, boxvar_SimCodeUtil_compareEqSystems);
  _return: OMC_LABEL_UNUSED
  return _outEqs;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_SimCodeUtil_compareEqSystems(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  _b = (omc_SimCodeUtil_simEqSystemIndex(threadData, _eq1) > omc_SimCodeUtil_simEqSystemIndex(threadData, _eq2));
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_SimCodeUtil_compareEqSystems(threadData_t *threadData, modelica_metatype _eq1, modelica_metatype _eq2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_SimCodeUtil_compareEqSystems(threadData, _eq1, _eq2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

