#include "omc_simulation_settings.h"
#include "BackendEquation.h"
#define _OMC_LIT0_data "BackendEquation.addOperation failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT0,35,_OMC_LIT0_data);
#define _OMC_LIT0 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT0)
#define _OMC_LIT1_data "/home/per/workspace/OpenModelica/OMCompiler/Compiler/BackEnd/BackendEquation.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT1,79,_OMC_LIT1_data);
#define _OMC_LIT1 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT1)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT2_6,1.770032059e9);
#define _OMC_LIT2_6 MMC_REFREALLIT(_OMC_LIT_STRUCT2_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT2,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3008)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(3008)),MMC_IMMEDIATE(MMC_TAGFIXNUM(82)),_OMC_LIT2_6}};
#define _OMC_LIT2 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT2)
#define _OMC_LIT3_data "der"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT3,3,_OMC_LIT3_data);
#define _OMC_LIT3 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT3)
#define _OMC_LIT4_data "function BackendEquation.solveEquation failed w.r.t "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT4,52,_OMC_LIT4_data);
#define _OMC_LIT4 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT4)
#define _OMC_LIT5_data "function solveEquation failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT5,29,_OMC_LIT5_data);
#define _OMC_LIT5 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT5)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT6_6,1.770032059e9);
#define _OMC_LIT6_6 MMC_REFREALLIT(_OMC_LIT_STRUCT6_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT6,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2528)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2528)),MMC_IMMEDIATE(MMC_TAGFIXNUM(76)),_OMC_LIT6_6}};
#define _OMC_LIT6 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT6)
#define _OMC_LIT7_data "__OMC__"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT7,7,_OMC_LIT7_data);
#define _OMC_LIT7 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT7)
#define _OMC_LIT8_data "$"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT8,1,_OMC_LIT8_data);
#define _OMC_LIT8 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT8)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT9,2,4) {&DAE_Type_T__REAL__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT9 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT9)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT10,1,4) {&BackendDAE_TearingSelect_AVOID__desc,}};
#define _OMC_LIT10 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT10)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT11,1,1) {_OMC_LIT10}};
#define _OMC_LIT11 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT11)
#define _OMC_LIT12_data ""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT12,0,_OMC_LIT12_data);
#define _OMC_LIT12 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT12)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT13,0.0);
#define _OMC_LIT13 MMC_REFREALLIT(_OMC_LIT_STRUCT13)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT14,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT12,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_LIT13}};
#define _OMC_LIT14 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT14)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT15,1,4) {&DAE_ComponentPrefix_NOCOMPPRE__desc,}};
#define _OMC_LIT15 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT15)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT16,8,3) {&DAE_ElementSource_SOURCE__desc,_OMC_LIT14,MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT15,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT16 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT16)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT17,1,4) {&BackendDAE_EquationKind_DYNAMIC__EQUATION__desc,}};
#define _OMC_LIT17 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT17)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT18,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_LIT18 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT18)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT19,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT17,_OMC_LIT18}};
#define _OMC_LIT19 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT19)
#define _OMC_LIT20_data " -- new eqn--\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT20,14,_OMC_LIT20_data);
#define _OMC_LIT20 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT20)
#define _OMC_LIT21_data "dumpSimplifyLoops"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT21,17,_OMC_LIT21_data);
#define _OMC_LIT21 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT21)
#define _OMC_LIT22_data "Dump between steps of simplifyLoops"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT22,35,_OMC_LIT22_data);
#define _OMC_LIT22 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT22)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT23,2,3) {&Gettext_TranslatableContent_gettext__desc,_OMC_LIT22}};
#define _OMC_LIT23 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT23)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT24,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(127)),_OMC_LIT21,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT23}};
#define _OMC_LIT24 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT24)
#define _OMC_LIT25_data "time"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT25,4,_OMC_LIT25_data);
#define _OMC_LIT25 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT25)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT26,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT25,_OMC_LIT9,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT26 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT26)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT27,1,10) {&BackendDAE_VarKind_PARAM__desc,}};
#define _OMC_LIT27 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT27)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT28,1,4) {&DAE_VarDirection_OUTPUT__desc,}};
#define _OMC_LIT28 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT28)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT29,1,5) {&DAE_VarParallelism_NON__PARALLEL__desc,}};
#define _OMC_LIT29 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT29)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT30,1,6) {&DAE_ConnectorType_NON__CONNECTOR__desc,}};
#define _OMC_LIT30 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT30)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT31,1,6) {&DAE_VarInnerOuter_NOT__INNER__OUTER__desc,}};
#define _OMC_LIT31 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT31)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT32,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT13}};
#define _OMC_LIT32 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT32)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT33,-1e21);
#define _OMC_LIT33 MMC_REFREALLIT(_OMC_LIT_STRUCT33)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT34,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT33}};
#define _OMC_LIT34 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT34)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT35,1,9) {&BackendDAE_EquationKind_UNKNOWN__EQUATION__KIND__desc,}};
#define _OMC_LIT35 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT35)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT36,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT35,_OMC_LIT18}};
#define _OMC_LIT36 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT36)
#define _OMC_LIT37_data "function setEquationRHS failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT37,30,_OMC_LIT37_data);
#define _OMC_LIT37 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT37)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT38_6,1.770032059e9);
#define _OMC_LIT38_6 MMC_REFREALLIT(_OMC_LIT_STRUCT38_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT38,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2242)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2242)),MMC_IMMEDIATE(MMC_TAGFIXNUM(77)),_OMC_LIT38_6}};
#define _OMC_LIT38 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT38)
#define _OMC_LIT39_data "function setEquationLHS failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT39,30,_OMC_LIT39_data);
#define _OMC_LIT39 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT39)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT40_6,1.770032059e9);
#define _OMC_LIT40_6 MMC_REFREALLIT(_OMC_LIT_STRUCT40_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT40,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2210)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2210)),MMC_IMMEDIATE(MMC_TAGFIXNUM(77)),_OMC_LIT40_6}};
#define _OMC_LIT40 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT40)
#define _OMC_LIT41_data "function setEquationAttributes failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT41,37,_OMC_LIT41_data);
#define _OMC_LIT41 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT41)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT42_6,1.770032059e9);
#define _OMC_LIT42_6 MMC_REFREALLIT(_OMC_LIT_STRUCT42_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT42,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2184)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2184)),MMC_IMMEDIATE(MMC_TAGFIXNUM(84)),_OMC_LIT42_6}};
#define _OMC_LIT42 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT42)
#define _OMC_LIT43_data "function getEquationAttributes failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT43,37,_OMC_LIT43_data);
#define _OMC_LIT43 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT43)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT44_6,1.770032059e9);
#define _OMC_LIT44_6 MMC_REFREALLIT(_OMC_LIT_STRUCT44_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT44,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2130)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2130)),MMC_IMMEDIATE(MMC_TAGFIXNUM(84)),_OMC_LIT44_6}};
#define _OMC_LIT44 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT44)
#define _OMC_LIT45_data "failtrace"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT45,9,_OMC_LIT45_data);
#define _OMC_LIT45 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT45)
#define _OMC_LIT46_data "Sets whether to print a failtrace or not."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT46,41,_OMC_LIT46_data);
#define _OMC_LIT46 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT46)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT47,2,3) {&Gettext_TranslatableContent_gettext__desc,_OMC_LIT46}};
#define _OMC_LIT47 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT47)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT48,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT45,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT47}};
#define _OMC_LIT48 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT48)
#define _OMC_LIT49_data "- BackendEquation.generateEquation failed on: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT49,46,_OMC_LIT49_data);
#define _OMC_LIT49 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT49)
#define _OMC_LIT50_data " = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT50,3,_OMC_LIT50_data);
#define _OMC_LIT50 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT50)
#define _OMC_LIT51_data "\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT51,1,_OMC_LIT51_data);
#define _OMC_LIT51 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT51)
#define _OMC_LIT52_data "BackendEquation.setEquationKind failed!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT52,39,_OMC_LIT52_data);
#define _OMC_LIT52 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT52)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT53_6,1.770032059e9);
#define _OMC_LIT53_6 MMC_REFREALLIT(_OMC_LIT_STRUCT53_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT53,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1956)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1956)),MMC_IMMEDIATE(MMC_TAGFIXNUM(75)),_OMC_LIT53_6}};
#define _OMC_LIT53 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT53)
#define _OMC_LIT54_data "BackendEquation.equationKind failed!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT54,36,_OMC_LIT54_data);
#define _OMC_LIT54 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT54)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT55_6,1.770032059e9);
#define _OMC_LIT55_6 MMC_REFREALLIT(_OMC_LIT_STRUCT55_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT55,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1934)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1934)),MMC_IMMEDIATE(MMC_TAGFIXNUM(75)),_OMC_LIT55_6}};
#define _OMC_LIT55 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT55)
#define _OMC_LIT56_data "BackendEquation.equationSize failed!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT56,36,_OMC_LIT56_data);
#define _OMC_LIT56 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT56)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT57_6,1.770032059e9);
#define _OMC_LIT57_6 MMC_REFREALLIT(_OMC_LIT_STRUCT57_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT57,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1816)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1816)),MMC_IMMEDIATE(MMC_TAGFIXNUM(83)),_OMC_LIT57_6}};
#define _OMC_LIT57 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT57)
#define _OMC_LIT58_data "BackendEquation.equationSource failed!"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT58,38,_OMC_LIT58_data);
#define _OMC_LIT58 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT58)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT59_6,1.770032059e9);
#define _OMC_LIT59_6 MMC_REFREALLIT(_OMC_LIT_STRUCT59_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT59,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1752)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1752)),MMC_IMMEDIATE(MMC_TAGFIXNUM(85)),_OMC_LIT59_6}};
#define _OMC_LIT59 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT59)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT60,1,24) {&BackendDAE_VarKind_DAE__RESIDUAL__VAR__desc,}};
#define _OMC_LIT60 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT60)
#define _OMC_LIT61_data "BackendEquation.convertResidualsIntoSolvedEquations failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT61,58,_OMC_LIT61_data);
#define _OMC_LIT61 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT61)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT62_6,1.770032059e9);
#define _OMC_LIT62_6 MMC_REFREALLIT(_OMC_LIT_STRUCT62_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT62,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1712)),MMC_IMMEDIATE(MMC_TAGFIXNUM(11)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1712)),MMC_IMMEDIATE(MMC_TAGFIXNUM(78)),_OMC_LIT62_6}};
#define _OMC_LIT62 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT62)
#define _OMC_LIT63_data "BackendEquation.traverseEquationToScalarResidualForm failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT63,59,_OMC_LIT63_data);
#define _OMC_LIT63 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT63)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT64_6,1.770032059e9);
#define _OMC_LIT64_6 MMC_REFREALLIT(_OMC_LIT_STRUCT64_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT64,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1668)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1668)),MMC_IMMEDIATE(MMC_TAGFIXNUM(76)),_OMC_LIT64_6}};
#define _OMC_LIT64 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT64)
#define _OMC_LIT65_data "- BackendDAE.equationToResidualForm failed\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT65,43,_OMC_LIT65_data);
#define _OMC_LIT65 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT65)
#define _OMC_LIT66_data "sum"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT66,3,_OMC_LIT66_data);
#define _OMC_LIT66 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT66)
#define _OMC_LIT67_data "BackendEquation.equationTupleToScalarResidualForm failed: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT67,58,_OMC_LIT67_data);
#define _OMC_LIT67 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT67)
#define _OMC_LIT68_data ": "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT68,2,_OMC_LIT68_data);
#define _OMC_LIT68 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT68)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT69,1,5) {&ErrorTypes_MessageType_TRANSLATION__desc,}};
#define _OMC_LIT69 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT69)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT70,1,4) {&ErrorTypes_Severity_ERROR__desc,}};
#define _OMC_LIT70 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT70)
#define _OMC_LIT71_data "Internal error %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT71,17,_OMC_LIT71_data);
#define _OMC_LIT71 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT71)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT72,2,3) {&Gettext_TranslatableContent_gettext__desc,_OMC_LIT71}};
#define _OMC_LIT72 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT72)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT73,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(63)),_OMC_LIT69,_OMC_LIT70,_OMC_LIT72}};
#define _OMC_LIT73 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT73)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT74,2,0) {MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT74 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT74)
#define _OMC_LIT75_data "- BackendDAE.equationToScalarResidualForm failed\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT75,49,_OMC_LIT75_data);
#define _OMC_LIT75 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT75)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT76,1,3) {&BackendDAE_Matching_NO__MATCHING__desc,}};
#define _OMC_LIT76 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT76)
#define _OMC_LIT77_data "not implemented error - BackendDAE.ALGORITHM - BackendEquation.traverseExpsOfEquation_WithStop\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT77,95,_OMC_LIT77_data);
#define _OMC_LIT77 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT77)
#define _OMC_LIT78_data "pre"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT78,3,_OMC_LIT78_data);
#define _OMC_LIT78 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT78)
#define _OMC_LIT79_data "previous"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT79,8,_OMC_LIT79_data);
#define _OMC_LIT79 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT79)
#define _OMC_LIT80_data "BackendEquation.getWhenEquationExpr failed\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT80,43,_OMC_LIT80_data);
#define _OMC_LIT80 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT80)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT81_6,1.770032059e9);
#define _OMC_LIT81_6 MMC_REFREALLIT(_OMC_LIT_STRUCT81_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT81,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(330)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(330)),MMC_IMMEDIATE(MMC_TAGFIXNUM(89)),_OMC_LIT81_6}};
#define _OMC_LIT81 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT81)
#define _OMC_LIT82_data "nfScalarize"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT82,11,_OMC_LIT82_data);
#define _OMC_LIT82 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT82)
#define _OMC_LIT83_data "Run scalarization in NF, default true."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT83,38,_OMC_LIT83_data);
#define _OMC_LIT83 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT83)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT84,2,3) {&Gettext_TranslatableContent_gettext__desc,_OMC_LIT83}};
#define _OMC_LIT84 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT84)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT85,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(168)),_OMC_LIT82,MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */)),_OMC_LIT84}};
#define _OMC_LIT85 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT85)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT86,1,12) {&BackendDAE_Equation_DUMMY__EQUATION__desc,}};
#define _OMC_LIT86 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT86)
#include "util/modelica.h"

#include "BackendEquation_includes.h"


/* default, do not make protected functions static */
#if !defined(PROTECTED_FUNCTION_STATIC)
#define PROTECTED_FUNCTION_STATIC
#endif
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_markDifferentiated2(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fattr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_markDifferentiated2,2,0) {(void*) boxptr_BackendEquation_markDifferentiated2,0}};
#define boxvar_BackendEquation_markDifferentiated2 MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_markDifferentiated2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasExpression(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _inTpls);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_aliasExpression,2,0) {(void*) boxptr_BackendEquation_aliasExpression,0}};
#define boxvar_BackendEquation_aliasExpression MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_aliasExpression)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasRecord(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _varLst, modelica_metatype _explst, modelica_metatype _inTpls);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_aliasRecord,2,0) {(void*) boxptr_BackendEquation_aliasRecord,0}};
#define boxvar_BackendEquation_aliasRecord MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_aliasRecord)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquation2(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _inTpls);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquation2,2,0) {(void*) boxptr_BackendEquation_aliasEquation2,0}};
#define boxvar_BackendEquation_aliasEquation2 MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquation2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquationLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _inTpls);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquationLst,2,0) {(void*) boxptr_BackendEquation_aliasEquationLst,0}};
#define boxvar_BackendEquation_aliasEquationLst MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquationLst)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquation1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _inTpls);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquation1,2,0) {(void*) boxptr_BackendEquation_aliasEquation1,0}};
#define boxvar_BackendEquation_aliasEquation1 MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_aliasEquation1)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_makeTmpEqnForExp__rule(threadData_t *threadData, modelica_metatype _inExp);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_makeTmpEqnForExp__rule(threadData_t *threadData, modelica_metatype _inExp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_makeTmpEqnForExp__rule,2,0) {(void*) boxptr_BackendEquation_makeTmpEqnForExp__rule,0}};
#define boxvar_BackendEquation_makeTmpEqnForExp__rule MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_makeTmpEqnForExp__rule)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_equationTupleToScalarResidualForm(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _inSource, modelica_metatype _inEqAttr, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_equationTupleToScalarResidualForm,2,0) {(void*) boxptr_BackendEquation_equationTupleToScalarResidualForm,0}};
#define boxvar_BackendEquation_equationTupleToScalarResidualForm MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_equationTupleToScalarResidualForm)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfExpList__WithStop(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfExpList__WithStop(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfExpList__WithStop,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfExpList__WithStop,0}};
#define boxvar_BackendEquation_traverseExpsOfExpList__WithStop MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfExpList__WithStop)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfExpList(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfExpList,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfExpList,0}};
#define boxvar_BackendEquation_traverseExpsOfExpList MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfExpList)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_boolean _inCont, modelica_metatype *out_outTypeA);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype _inCont, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenOps__WithStop,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfWhenOps__WithStop,0}};
#define boxvar_BackendEquation_traverseExpsOfWhenOps__WithStop MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenOps__WithStop)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenEquation__WithStop,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfWhenEquation__WithStop,0}};
#define boxvar_BackendEquation_traverseExpsOfWhenEquation__WithStop MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenEquation__WithStop)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfWhenOps(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype _inAccum, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenOps,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfWhenOps,0}};
#define boxvar_BackendEquation_traverseExpsOfWhenOps MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenOps)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfWhenEquation(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenEquation,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfWhenEquation,0}};
#define boxvar_BackendEquation_traverseExpsOfWhenEquation MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfWhenEquation)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfEquationListList__WithStop,2,0) {(void*) boxptr_BackendEquation_traverseExpsOfEquationListList__WithStop,0}};
#define boxvar_BackendEquation_traverseExpsOfEquationListList__WithStop MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traverseExpsOfEquationListList__WithStop)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_checkEquationsUnknownCrefsExp(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_metatype *out_outTuple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_checkEquationsUnknownCrefsExp,2,0) {(void*) boxptr_BackendEquation_checkEquationsUnknownCrefsExp,0}};
#define boxvar_BackendEquation_checkEquationsUnknownCrefsExp MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_checkEquationsUnknownCrefsExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingEquationCrefFinder(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inCrefs, modelica_metatype *out_cr_lst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traversingEquationCrefFinder,2,0) {(void*) boxptr_BackendEquation_traversingEquationCrefFinder,0}};
#define boxvar_BackendEquation_traversingEquationCrefFinder MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traversingEquationCrefFinder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingRelationsforIterationVars(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traversingRelationsforIterationVars,2,0) {(void*) boxptr_BackendEquation_traversingRelationsforIterationVars,0}};
#define boxvar_BackendEquation_traversingRelationsforIterationVars MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traversingRelationsforIterationVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingParamRefFinder0(threadData_t *threadData, modelica_metatype _iVars, modelica_metatype _iVarIdc, modelica_metatype _iParamVarsList, modelica_metatype _iParamVarsIdc, modelica_metatype *out_oParamVarIdc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traversingParamRefFinder0,2,0) {(void*) boxptr_BackendEquation_traversingParamRefFinder0,0}};
#define boxvar_BackendEquation_traversingParamRefFinder0 MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traversingParamRefFinder0)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingParamRefFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_BackendEquation_traversingParamRefFinder,2,0) {(void*) boxptr_BackendEquation_traversingParamRefFinder,0}};
#define boxvar_BackendEquation_traversingParamRefFinder MMC_REFSTRUCTLIT(boxvar_lit_BackendEquation_traversingParamRefFinder)

DLLDirection
modelica_boolean omc_BackendEquation_hasAnyUnknown(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _vars)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  _b = (!listEmpty(omc_BackendEquation_equationVars(threadData, _eqn, _vars)));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_hasAnyUnknown(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _vars)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_hasAnyUnknown(threadData, _eqn, _vars);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_BackendEquation_createResidualExp(threadData_t *threadData, modelica_metatype _eqn)
{
  modelica_metatype _res = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eqn;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _cr = NULL;
      int tmp4;
      // _e1 has no default value.
      // _e2 has no default value.
      // _cr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,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));
          
          _e1 = tmpMeta5;
          _e2 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_Expression_createResidualExp(threadData, _e1, _e2);
          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), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta7;
          _e2 = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_Expression_createResidualExp(threadData, _e1, _e2);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cr = tmpMeta9;
          _e2 = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta11 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr, omc_ComponentReference_crefTypeFull(threadData, _cr));
          tmpMeta1 = omc_Expression_createResidualExp(threadData, tmpMeta11, _e2);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _e1 = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta1 = _e1;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta13;
          _e2 = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_Expression_createResidualExp(threadData, _e1, _e2);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _res = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _res;
}

DLLDirection
modelica_boolean omc_BackendEquation_allAlgorithmsLst(threadData_t *threadData, modelica_metatype _eqn_lst)
{
  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 = _eqn_lst;
    {
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest 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 */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          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;
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmp4_1);
          tmpMeta9 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,4,5) == 0) goto tmp3_end;
          
          _rest = tmpMeta9;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _eqn_lst = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          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_BackendEquation_allAlgorithmsLst(threadData_t *threadData, modelica_metatype _eqn_lst)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_allAlgorithmsLst(threadData, _eqn_lst);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_BackendEquation_scalarComplexEquations(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _funcTree)
{
  modelica_metatype _outEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _explst = NULL;
      modelica_metatype _explst2 = NULL;
      modelica_metatype _attr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _source has no default value.
      // _explst has no default value.
      // _explst2 has no default value.
      // _attr has no default value.
      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;
          modelica_boolean tmp12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,19,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,19,1) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _explst = tmpMeta7;
          _explst2 = tmpMeta9;
          _source = tmpMeta10;
          _attr = tmpMeta11;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp12 = (listLength(_explst) == listLength(_explst2));
          if (1 /* true */ != tmp12) goto goto_2;
          tmpMeta1 = omc_List_threadMap2(threadData, _explst, _explst2, boxvar_BackendEquation_generateEquation, _source, _attr);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_boolean tmp17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          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), 5));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta13;
          _e2 = tmpMeta14;
          _source = tmpMeta15;
          _attr = tmpMeta16;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((omc_Expression_isRecordCall(threadData, _e1, _funcTree) || omc_Expression_isRecord(threadData, _e1)) && (omc_Expression_isRecordCall(threadData, _e2, _funcTree) || omc_Expression_isRecord(threadData, _e2)))) goto tmp3_end;
          _explst = omc_Expression_splitRecord(threadData, _e1, omc_Expression_typeof(threadData, _e1));

          _explst2 = omc_Expression_splitRecord(threadData, _e2, omc_Expression_typeof(threadData, _e2));

          /* Pattern-matching assignment */
          tmp17 = (listLength(_explst) == listLength(_explst2));
          if (1 /* true */ != tmp17) goto goto_2;
          tmpMeta1 = omc_List_threadMap2(threadData, _explst, _explst2, boxvar_BackendEquation_generateEquation, _source, _attr);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta18;
          
          /* Pattern matching succeeded */
          tmpMeta18 = mmc_mk_cons(_inEquation, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta18;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEquations;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEquationLHS(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _lhs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lhs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _exp1 = NULL;
      modelica_metatype _cref = NULL;
      int tmp4;
      // _exp1 has no default value.
      // _cref 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,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _exp1 = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          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), 3));
          
          _exp1 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cref = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_Expression_crefExp(threadData, _cref);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _exp1 = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          if (1 /* true */ != tmp12) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          if (listEmpty(tmpMeta13)) goto tmp3_end;
          tmpMeta14 = MMC_CAR(tmpMeta13);
          tmpMeta15 = MMC_CDR(tmpMeta13);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,0,3) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          if (!listEmpty(tmpMeta15)) goto tmp3_end;
          
          _exp1 = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _lhs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _lhs;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEquationRHS(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _rhs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _rhs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _exp1 = NULL;
      int tmp4;
      // _exp1 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,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _exp1 = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          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), 4));
          
          _exp1 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _exp1 = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _exp1 = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          if (1 /* true */ != tmp12) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          if (listEmpty(tmpMeta13)) goto tmp3_end;
          tmpMeta14 = MMC_CAR(tmpMeta13);
          tmpMeta15 = MMC_CDR(tmpMeta13);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,0,3) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          if (!listEmpty(tmpMeta15)) goto tmp3_end;
          
          _exp1 = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta1 = _exp1;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _rhs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _rhs;
}

DLLDirection
modelica_metatype omc_BackendEquation_replaceDerOpInEquationList(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_metatype _outEqns = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqns has no default value.
  _outEqns = omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEqns, boxvar_Expression_replaceDerOpInExpCond, mmc_mk_none(), NULL);
  _return: OMC_LABEL_UNUSED
  return _outEqns;
}

DLLDirection
modelica_boolean omc_BackendEquation_isDifferentiated(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _diffed;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _diffed has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_boolean _b;
      modelica_metatype _eqn = NULL;
      int tmp4;
      // _b has no default value.
      // _eqn has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          
          _b = tmp7  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          
          _b = tmp10  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          
          _b = tmp13  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          
          _b = tmp16  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          
          _b = tmp19  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          
          _b = tmp22  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          
          _b = tmp25  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmp1 = _b;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (listEmpty(tmpMeta26)) goto tmp3_end;
          tmpMeta27 = MMC_CAR(tmpMeta26);
          tmpMeta28 = MMC_CDR(tmpMeta26);
          
          _eqn = tmpMeta27;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _inEqn = _eqn;
          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:;
    }
  }
  _diffed = tmp1;
  _return: OMC_LABEL_UNUSED
  return _diffed;
}
modelica_metatype boxptr_BackendEquation_isDifferentiated(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _diffed;
  modelica_metatype out_diffed;
  _diffed = omc_BackendEquation_isDifferentiated(threadData, _inEqn);
  out_diffed = mmc_mk_icon(_diffed);
  return out_diffed;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_markDifferentiated2(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fattr)
{
  modelica_metatype _attr = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _attr = __omcQ_24in_5Fattr;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(5));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_attr), 5*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[2] = mmc_mk_boolean(1 /* true */);
  _attr = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _attr;
}

DLLDirection
modelica_metatype omc_BackendEquation_markDifferentiated(threadData_t *threadData, modelica_metatype _inEqn)
{
  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_metatype _eqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn has no default value.
      tmp4 = 0;
      for (; tmp4 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[5] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))));
          _eqn = tmpMeta6;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[6] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 6))));
          _eqn = tmpMeta7;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[5] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))));
          _eqn = tmpMeta8;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_eqn), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[4] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))));
          _eqn = tmpMeta9;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[6] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 6))));
          _eqn = tmpMeta10;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inEqn;
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inEqn;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[6] = omc_BackendEquation_markDifferentiated2(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 6))));
          _eqn = tmpMeta11;

          tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[3] = omc_List_mapList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), boxvar_BackendEquation_markDifferentiated);
          _eqn = tmpMeta12;

          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[4] = omc_List_map(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), boxvar_BackendEquation_markDifferentiated);
          _eqn = tmpMeta13;
          tmpMeta1 = _eqn;
          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;
}

DLLDirection
modelica_boolean omc_BackendEquation_isNotAlgorithm(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  _b = (!omc_BackendEquation_isAlgorithm(threadData, _inEqn));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isNotAlgorithm(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isNotAlgorithm(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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,0,4) == 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isEquation(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isComplexEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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,6,5) == 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isComplexEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isComplexEquation(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isAlgorithm(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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,4,5) == 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isAlgorithm(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isAlgorithm(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isArrayEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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,6) == 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isArrayEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isArrayEquation(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isWhenEquationOrDiscreteAlgorithm(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _vars)
{
  modelica_boolean _b;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_boolean _b1;
      modelica_metatype _stmts = NULL;
      modelica_metatype _lhsCrefs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _b1 has no default value.
      // _stmts has no default value.
      // _lhsCrefs 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 (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          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,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));
          
          _stmts = tmpMeta7;
          /* Pattern matching succeeded */
          _b1 = 1 /* true */;

          {
            modelica_metatype _s;
            for (tmpMeta8 = _stmts; !listEmpty(tmpMeta8); tmpMeta8=MMC_CDR(tmpMeta8))
            {
              _s = MMC_CAR(tmpMeta8);
              _lhsCrefs = omc_Expression_extractCrefsStatment(threadData, _s, NULL);

              {
                modelica_metatype _c;
                for (tmpMeta9 = _lhsCrefs; !listEmpty(tmpMeta9); tmpMeta9=MMC_CDR(tmpMeta9))
                {
                  _c = MMC_CAR(tmpMeta9);
                  _b1 = (_b1 && omc_BackendVariable_isDiscrete(threadData, _c, _vars));
                }
              }
            }
          }
          tmp1 = _b1;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isWhenEquationOrDiscreteAlgorithm(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _vars)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isWhenEquationOrDiscreteAlgorithm(threadData, _inEqn, _vars);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isWhenEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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,5,4) == 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_isWhenEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_isWhenEquation(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_boolean omc_BackendEquation_isTornSystem(threadData_t *threadData, modelica_metatype _comp)
{
  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 = _comp;
    {
      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,7,4) == 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:;
    }
  }
  _res = tmp1;
  _return: OMC_LABEL_UNUSED
  return _res;
}
modelica_metatype boxptr_BackendEquation_isTornSystem(threadData_t *threadData, modelica_metatype _comp)
{
  modelica_boolean _res;
  modelica_metatype out_res;
  _res = omc_BackendEquation_isTornSystem(threadData, _comp);
  out_res = mmc_mk_icon(_res);
  return out_res;
}

DLLDirection
modelica_boolean omc_BackendEquation_isEquationsSystem(threadData_t *threadData, modelica_metatype _comp)
{
  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 = _comp;
    {
      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,5) == 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:;
    }
  }
  _res = tmp1;
  _return: OMC_LABEL_UNUSED
  return _res;
}
modelica_metatype boxptr_BackendEquation_isEquationsSystem(threadData_t *threadData, modelica_metatype _comp)
{
  modelica_boolean _res;
  modelica_metatype out_res;
  _res = omc_BackendEquation_isEquationsSystem(threadData, _comp);
  out_res = mmc_mk_icon(_res);
  return out_res;
}

DLLDirection
modelica_metatype omc_BackendEquation_addOperation(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inSymOp)
{
  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_metatype _eqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn has no default value.
      tmp4 = 0;
      for (; tmp4 < 10; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[4] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _inSymOp);
          _eqn = tmpMeta6;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[5] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))), _inSymOp);
          _eqn = tmpMeta7;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[4] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _inSymOp);
          _eqn = tmpMeta8;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_eqn), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[3] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _inSymOp);
          _eqn = tmpMeta9;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[4] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _inSymOp);
          _eqn = tmpMeta10;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[4] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _inSymOp);
          _eqn = tmpMeta11;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[5] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))), _inSymOp);
          _eqn = tmpMeta12;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[5] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))), _inSymOp);
          _eqn = tmpMeta13;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[6] = omc_ElementSource_addSymbolicTransformation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 6))), _inSymOp);
          _eqn = tmpMeta14;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 9: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT0, _OMC_LIT2);
          goto goto_2;
          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;
}

DLLDirection
modelica_metatype omc_BackendEquation_derivativeEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype *out_dcr, modelica_metatype *out_e, modelica_metatype *out_de, modelica_boolean *out_negate)
{
  modelica_metatype _cr = NULL;
  modelica_metatype _dcr = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _de = NULL;
  modelica_boolean _negate;
  modelica_boolean tmp1_c4 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cr has no default value.
  // _dcr has no default value.
  // _e has no default value.
  // _de has no default value.
  // _negate has no default value.
  
  
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eqn;
    {
      modelica_metatype _ne = NULL;
      modelica_metatype _ne2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ne has no default value.
      // _ne2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 14; 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,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          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), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,13,3) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,1) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          if (3 != MMC_STRLEN(tmpMeta10) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta10)) != 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          if (listEmpty(tmpMeta11)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          if (!listEmpty(tmpMeta13)) goto tmp3_end;
          
          _e = tmpMeta6;
          _dcr = tmpMeta7;
          _de = tmpMeta8;
          _cr = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 1: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,13,3) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,1,1) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          if (3 != MMC_STRLEN(tmpMeta17) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta17)) != 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
          if (listEmpty(tmpMeta18)) goto tmp3_end;
          tmpMeta19 = MMC_CAR(tmpMeta18);
          tmpMeta20 = MMC_CDR(tmpMeta18);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta19,6,2) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          if (!listEmpty(tmpMeta20)) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,6,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          
          _de = tmpMeta15;
          _cr = tmpMeta21;
          _e = tmpMeta22;
          _dcr = tmpMeta23;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 2: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,6,2) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,8,2) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,5,1) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta28,13,3) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,1,1) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          if (3 != MMC_STRLEN(tmpMeta30) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta30)) != 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 3));
          if (listEmpty(tmpMeta31)) goto tmp3_end;
          tmpMeta32 = MMC_CAR(tmpMeta31);
          tmpMeta33 = MMC_CDR(tmpMeta31);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,6,2) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 2));
          if (!listEmpty(tmpMeta33)) goto tmp3_end;
          
          _e = tmpMeta24;
          _dcr = tmpMeta25;
          _de = tmpMeta26;
          _cr = tmpMeta34;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 3: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,6,2) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,8,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,6,1) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,13,3) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,1,1) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 2));
          if (3 != MMC_STRLEN(tmpMeta41) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta41)) != 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 3));
          if (listEmpty(tmpMeta42)) goto tmp3_end;
          tmpMeta43 = MMC_CAR(tmpMeta42);
          tmpMeta44 = MMC_CDR(tmpMeta42);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta43,6,2) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta43), 2));
          if (!listEmpty(tmpMeta44)) goto tmp3_end;
          
          _e = tmpMeta35;
          _dcr = tmpMeta36;
          _de = tmpMeta37;
          _cr = tmpMeta45;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 4: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,8,2) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta47,5,1) == 0) goto tmp3_end;
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta48,13,3) == 0) goto tmp3_end;
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta49,1,1) == 0) goto tmp3_end;
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          if (3 != MMC_STRLEN(tmpMeta50) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta50)) != 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 3));
          if (listEmpty(tmpMeta51)) goto tmp3_end;
          tmpMeta52 = MMC_CAR(tmpMeta51);
          tmpMeta53 = MMC_CDR(tmpMeta51);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta52,6,2) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          if (!listEmpty(tmpMeta53)) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,6,2) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
          
          _de = tmpMeta46;
          _cr = tmpMeta54;
          _e = tmpMeta55;
          _dcr = tmpMeta56;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 5: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta57,8,2) == 0) goto tmp3_end;
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,6,1) == 0) goto tmp3_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta57), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta59,13,3) == 0) goto tmp3_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta59), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta60,1,1) == 0) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 2));
          if (3 != MMC_STRLEN(tmpMeta61) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta61)) != 0) goto tmp3_end;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta59), 3));
          if (listEmpty(tmpMeta62)) goto tmp3_end;
          tmpMeta63 = MMC_CAR(tmpMeta62);
          tmpMeta64 = MMC_CDR(tmpMeta62);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,6,2) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          if (!listEmpty(tmpMeta64)) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta66,6,2) == 0) goto tmp3_end;
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta66), 2));
          
          _de = tmpMeta57;
          _cr = tmpMeta65;
          _e = tmpMeta66;
          _dcr = tmpMeta67;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _de;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 6: {
          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(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta68,8,2) == 0) goto tmp3_end;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta69,5,1) == 0) goto tmp3_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta70,6,2) == 0) goto tmp3_end;
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta70), 2));
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta72,13,3) == 0) goto tmp3_end;
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta72), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta73,1,1) == 0) goto tmp3_end;
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta73), 2));
          if (3 != MMC_STRLEN(tmpMeta74) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta74)) != 0) goto tmp3_end;
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta72), 3));
          if (listEmpty(tmpMeta75)) goto tmp3_end;
          tmpMeta76 = MMC_CAR(tmpMeta75);
          tmpMeta77 = MMC_CDR(tmpMeta75);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta76,6,2) == 0) goto tmp3_end;
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta76), 2));
          if (!listEmpty(tmpMeta77)) goto tmp3_end;
          
          _e = tmpMeta68;
          _dcr = tmpMeta71;
          _de = tmpMeta72;
          _cr = tmpMeta78;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _ne;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 7: {
          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,0,4) == 0) goto tmp3_end;
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta79,8,2) == 0) goto tmp3_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta79), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta80,6,1) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta79), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta81,6,2) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta81), 2));
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta83,13,3) == 0) goto tmp3_end;
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta83), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta84,1,1) == 0) goto tmp3_end;
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta84), 2));
          if (3 != MMC_STRLEN(tmpMeta85) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta85)) != 0) goto tmp3_end;
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta83), 3));
          if (listEmpty(tmpMeta86)) goto tmp3_end;
          tmpMeta87 = MMC_CAR(tmpMeta86);
          tmpMeta88 = MMC_CDR(tmpMeta86);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta87,6,2) == 0) goto tmp3_end;
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta87), 2));
          if (!listEmpty(tmpMeta88)) goto tmp3_end;
          
          _e = tmpMeta79;
          _dcr = tmpMeta82;
          _de = tmpMeta83;
          _cr = tmpMeta89;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _ne;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta90,13,3) == 0) goto tmp3_end;
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta90), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta91,1,1) == 0) goto tmp3_end;
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 2));
          if (3 != MMC_STRLEN(tmpMeta92) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta92)) != 0) goto tmp3_end;
          tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta90), 3));
          if (listEmpty(tmpMeta93)) goto tmp3_end;
          tmpMeta94 = MMC_CAR(tmpMeta93);
          tmpMeta95 = MMC_CDR(tmpMeta93);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta94,6,2) == 0) goto tmp3_end;
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta94), 2));
          if (!listEmpty(tmpMeta95)) goto tmp3_end;
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta97,8,2) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta97), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta98,5,1) == 0) goto tmp3_end;
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta97), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta99,6,2) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta99), 2));
          
          _de = tmpMeta90;
          _cr = tmpMeta96;
          _e = tmpMeta97;
          _dcr = tmpMeta100;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _ne;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 9: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta101,13,3) == 0) goto tmp3_end;
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta101), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta102,1,1) == 0) goto tmp3_end;
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta102), 2));
          if (3 != MMC_STRLEN(tmpMeta103) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta103)) != 0) goto tmp3_end;
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta101), 3));
          if (listEmpty(tmpMeta104)) goto tmp3_end;
          tmpMeta105 = MMC_CAR(tmpMeta104);
          tmpMeta106 = MMC_CDR(tmpMeta104);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta105,6,2) == 0) goto tmp3_end;
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta105), 2));
          if (!listEmpty(tmpMeta106)) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta108,8,2) == 0) goto tmp3_end;
          tmpMeta109 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta108), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta109,6,1) == 0) goto tmp3_end;
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta108), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta110,6,2) == 0) goto tmp3_end;
          tmpMeta111 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta110), 2));
          
          _de = tmpMeta101;
          _cr = tmpMeta107;
          _e = tmpMeta108;
          _dcr = tmpMeta111;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _e;
          tmpMeta[0+3] = _ne;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 10: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta112 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta112,8,2) == 0) goto tmp3_end;
          tmpMeta113 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta113,5,1) == 0) goto tmp3_end;
          tmpMeta114 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta114,6,2) == 0) goto tmp3_end;
          tmpMeta115 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta114), 2));
          tmpMeta116 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta116,8,2) == 0) goto tmp3_end;
          tmpMeta117 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta116), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta117,5,1) == 0) goto tmp3_end;
          tmpMeta118 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta116), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta118,13,3) == 0) goto tmp3_end;
          tmpMeta119 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta118), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta119,1,1) == 0) goto tmp3_end;
          tmpMeta120 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta119), 2));
          if (3 != MMC_STRLEN(tmpMeta120) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta120)) != 0) goto tmp3_end;
          tmpMeta121 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta118), 3));
          if (listEmpty(tmpMeta121)) goto tmp3_end;
          tmpMeta122 = MMC_CAR(tmpMeta121);
          tmpMeta123 = MMC_CDR(tmpMeta121);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta122,6,2) == 0) goto tmp3_end;
          tmpMeta124 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta122), 2));
          if (!listEmpty(tmpMeta123)) goto tmp3_end;
          
          _e = tmpMeta112;
          _dcr = tmpMeta115;
          _de = tmpMeta116;
          _cr = tmpMeta124;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);

          _ne2 = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _ne2;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 11: {
          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_metatype tmpMeta137;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta125 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta125,8,2) == 0) goto tmp3_end;
          tmpMeta126 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta125), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta126,6,1) == 0) goto tmp3_end;
          tmpMeta127 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta125), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta127,6,2) == 0) goto tmp3_end;
          tmpMeta128 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta127), 2));
          tmpMeta129 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta129,8,2) == 0) goto tmp3_end;
          tmpMeta130 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta129), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta130,6,1) == 0) goto tmp3_end;
          tmpMeta131 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta129), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta131,13,3) == 0) goto tmp3_end;
          tmpMeta132 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta131), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta132,1,1) == 0) goto tmp3_end;
          tmpMeta133 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta132), 2));
          if (3 != MMC_STRLEN(tmpMeta133) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta133)) != 0) goto tmp3_end;
          tmpMeta134 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta131), 3));
          if (listEmpty(tmpMeta134)) goto tmp3_end;
          tmpMeta135 = MMC_CAR(tmpMeta134);
          tmpMeta136 = MMC_CDR(tmpMeta134);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta135,6,2) == 0) goto tmp3_end;
          tmpMeta137 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta135), 2));
          if (!listEmpty(tmpMeta136)) goto tmp3_end;
          
          _e = tmpMeta125;
          _dcr = tmpMeta128;
          _de = tmpMeta129;
          _cr = tmpMeta137;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);

          _ne2 = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _ne2;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 12: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta138 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta138,8,2) == 0) goto tmp3_end;
          tmpMeta139 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta138), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta139,5,1) == 0) goto tmp3_end;
          tmpMeta140 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta138), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta140,13,3) == 0) goto tmp3_end;
          tmpMeta141 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta140), 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_LIT3), MMC_STRINGDATA(tmpMeta142)) != 0) goto tmp3_end;
          tmpMeta143 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta140), 3));
          if (listEmpty(tmpMeta143)) goto tmp3_end;
          tmpMeta144 = MMC_CAR(tmpMeta143);
          tmpMeta145 = MMC_CDR(tmpMeta143);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta144,6,2) == 0) goto tmp3_end;
          tmpMeta146 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta144), 2));
          if (!listEmpty(tmpMeta145)) goto tmp3_end;
          tmpMeta147 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta147,8,2) == 0) goto tmp3_end;
          tmpMeta148 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta147), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta148,5,1) == 0) goto tmp3_end;
          tmpMeta149 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta147), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta149,6,2) == 0) goto tmp3_end;
          tmpMeta150 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta149), 2));
          
          _de = tmpMeta138;
          _cr = tmpMeta146;
          _e = tmpMeta147;
          _dcr = tmpMeta150;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);

          _ne2 = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _ne2;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 13: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta151 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta151,8,2) == 0) goto tmp3_end;
          tmpMeta152 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta151), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta152,6,1) == 0) goto tmp3_end;
          tmpMeta153 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta151), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta153,13,3) == 0) goto tmp3_end;
          tmpMeta154 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta153), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta154,1,1) == 0) goto tmp3_end;
          tmpMeta155 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta154), 2));
          if (3 != MMC_STRLEN(tmpMeta155) || strcmp(MMC_STRINGDATA(_OMC_LIT3), MMC_STRINGDATA(tmpMeta155)) != 0) goto tmp3_end;
          tmpMeta156 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta153), 3));
          if (listEmpty(tmpMeta156)) goto tmp3_end;
          tmpMeta157 = MMC_CAR(tmpMeta156);
          tmpMeta158 = MMC_CDR(tmpMeta156);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta157,6,2) == 0) goto tmp3_end;
          tmpMeta159 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta157), 2));
          if (!listEmpty(tmpMeta158)) goto tmp3_end;
          tmpMeta160 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta160,8,2) == 0) goto tmp3_end;
          tmpMeta161 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta160), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta161,6,1) == 0) goto tmp3_end;
          tmpMeta162 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta160), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta162,6,2) == 0) goto tmp3_end;
          tmpMeta163 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta162), 2));
          
          _de = tmpMeta151;
          _cr = tmpMeta159;
          _e = tmpMeta160;
          _dcr = tmpMeta163;
          /* Pattern matching succeeded */
          _ne = omc_Expression_negate(threadData, _e);

          _ne2 = omc_Expression_negate(threadData, _de);
          tmpMeta[0+0] = _cr;
          tmpMeta[0+1] = _dcr;
          tmpMeta[0+2] = _ne;
          tmpMeta[0+3] = _ne2;
          tmp1_c4 = 0 /* false */;
          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];
  _dcr = tmpMeta[0+1];
  _e = tmpMeta[0+2];
  _de = tmpMeta[0+3];
  _negate = tmp1_c4;
  _return: OMC_LABEL_UNUSED
  if (out_dcr) { *out_dcr = _dcr; }
  if (out_e) { *out_e = _e; }
  if (out_de) { *out_de = _de; }
  if (out_negate) { *out_negate = _negate; }
  return _cr;
}
modelica_metatype boxptr_BackendEquation_derivativeEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype *out_dcr, modelica_metatype *out_e, modelica_metatype *out_de, modelica_metatype *out_negate)
{
  modelica_boolean _negate;
  modelica_metatype _cr = NULL;
  _cr = omc_BackendEquation_derivativeEquation(threadData, _eqn, out_dcr, out_e, out_de, &_negate);
  /* skip box _cr; DAE.ComponentRef */
  /* skip box _dcr; DAE.ComponentRef */
  /* skip box _e; DAE.Exp */
  /* skip box _de; DAE.Exp */
  if (out_negate) { *out_negate = mmc_mk_icon(_negate); }
  return _cr;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasExpression(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _inTpls)
{
  modelica_metatype _outTpls = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = 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.
      // _ty has no default value.
      tmp4 = 0;
      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;
          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,7,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          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), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,0,1) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,6,2) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _e1 = tmpMeta6;
          _cr1 = tmpMeta7;
          _ty = tmpMeta9;
          _e2 = tmpMeta10;
          _cr2 = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_box2(8, &DAE_Operator_UMINUS__desc, _ty);
          tmpMeta14 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta13, _e1);
          tmpMeta15 = mmc_mk_box2(8, &DAE_Operator_UMINUS__desc, _ty);
          tmpMeta16 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta15, _e2);
          tmpMeta17 = mmc_mk_box5(0, _cr1, _cr2, tmpMeta14, tmpMeta16, mmc_mk_boolean(1 /* true */));
          tmpMeta12 = mmc_mk_cons(tmpMeta17, _inTpls);
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        case 1: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,6,2) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,7,1) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,6,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          
          _e1 = tmpMeta18;
          _cr1 = tmpMeta19;
          _ty = tmpMeta21;
          _e2 = tmpMeta22;
          _cr2 = tmpMeta23;
          /* Pattern matching succeeded */
          tmpMeta25 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta26 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta25, _e1);
          tmpMeta27 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta28 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta27, _e2);
          tmpMeta29 = mmc_mk_box5(0, _cr1, _cr2, tmpMeta26, tmpMeta28, mmc_mk_boolean(1 /* true */));
          tmpMeta24 = mmc_mk_cons(tmpMeta29, _inTpls);
          tmpMeta1 = tmpMeta24;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,6,2) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,1,1) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta33,6,2) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          
          _e1 = tmpMeta30;
          _cr1 = tmpMeta31;
          _e2 = tmpMeta33;
          _cr2 = tmpMeta34;
          /* Pattern matching succeeded */
          tmpMeta36 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta35 = mmc_mk_cons(tmpMeta36, _inTpls);
          tmpMeta1 = tmpMeta35;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta37;
          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,7,3) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,6,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,8,1) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,6,2) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 2));
          
          _e1 = tmpMeta37;
          _cr1 = tmpMeta38;
          _e2 = tmpMeta40;
          _cr2 = tmpMeta41;
          /* Pattern matching succeeded */
          tmpMeta43 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta42 = mmc_mk_cons(tmpMeta43, _inTpls);
          tmpMeta1 = tmpMeta42;
          goto tmp3_done;
        }
        case 4: {
          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 (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta44,8,2) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta44), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta45,5,1) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta44), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,6,2) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 2));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta48,0,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));
          
          _e1 = tmpMeta46;
          _cr1 = tmpMeta47;
          _e2 = tmpMeta49;
          _cr2 = tmpMeta50;
          /* Pattern matching succeeded */
          tmpMeta52 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta51 = mmc_mk_cons(tmpMeta52, _inTpls);
          tmpMeta1 = tmpMeta51;
          goto tmp3_done;
        }
        case 5: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta53,8,2) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta53), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta54,6,1) == 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta53), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,6,2) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 2));
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta57,7,1) == 0) goto tmp3_end;
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,6,2) == 0) goto tmp3_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          
          _e1 = tmpMeta55;
          _cr1 = tmpMeta56;
          _e2 = tmpMeta58;
          _cr2 = tmpMeta59;
          /* Pattern matching succeeded */
          tmpMeta61 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta60 = mmc_mk_cons(tmpMeta61, _inTpls);
          tmpMeta1 = tmpMeta60;
          goto tmp3_done;
        }
        case 6: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta62,8,2) == 0) goto tmp3_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,5,1) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta64,6,2) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 2));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta66,1,1) == 0) goto tmp3_end;
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta66), 2));
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta68,6,2) == 0) goto tmp3_end;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 2));
          
          _e1 = tmpMeta62;
          _cr1 = tmpMeta65;
          _ty = tmpMeta67;
          _e2 = tmpMeta68;
          _cr2 = tmpMeta69;
          /* Pattern matching succeeded */
          tmpMeta71 = mmc_mk_box2(8, &DAE_Operator_UMINUS__desc, _ty);
          tmpMeta72 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta71, _e2);
          tmpMeta73 = mmc_mk_box5(0, _cr1, _cr2, _e1, tmpMeta72, mmc_mk_boolean(1 /* true */));
          tmpMeta70 = mmc_mk_cons(tmpMeta73, _inTpls);
          tmpMeta1 = tmpMeta70;
          goto tmp3_done;
        }
        case 7: {
          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(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta74,8,2) == 0) goto tmp3_end;
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta74), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta75,6,1) == 0) goto tmp3_end;
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta74), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta76,6,2) == 0) goto tmp3_end;
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta76), 2));
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta78,8,1) == 0) goto tmp3_end;
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta78), 2));
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta80,6,2) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta80), 2));
          
          _e1 = tmpMeta74;
          _cr1 = tmpMeta77;
          _ty = tmpMeta79;
          _e2 = tmpMeta80;
          _cr2 = tmpMeta81;
          /* Pattern matching succeeded */
          tmpMeta83 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta84 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta83, _e2);
          tmpMeta85 = mmc_mk_box5(0, _cr1, _cr2, _e1, tmpMeta84, mmc_mk_boolean(1 /* true */));
          tmpMeta82 = mmc_mk_cons(tmpMeta85, _inTpls);
          tmpMeta1 = tmpMeta82;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpls = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasRecord(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _varLst, modelica_metatype _explst, modelica_metatype _inTpls)
{
  modelica_metatype _outTpls = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _varLst;
    tmp4_2 = _explst;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _op = NULL;
      modelica_metatype _elst = NULL;
      modelica_metatype _vlst = NULL;
      modelica_string _ident = 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.
      // _ty has no default value.
      // _op has no default value.
      // _elst has no default value.
      // _vlst has no default value.
      // _ident has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; 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 = _inTpls;
          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;
          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 (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_2);
          tmpMeta11 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,6,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _ident = tmpMeta8;
          _ty = tmpMeta9;
          _vlst = tmpMeta7;
          _e2 = tmpMeta10;
          _cr2 = tmpMeta12;
          _elst = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReference_crefPrependIdent(threadData, _cr, _ident, tmpMeta13, _ty);

          tmpMeta14 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr1, _ty);
          _e1 = tmpMeta14;
          tmpMeta16 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta15 = mmc_mk_cons(tmpMeta16, _inTpls);
          /* Tail recursive call */
          _varLst = _vlst;
          _explst = _elst;
          _inTpls = tmpMeta15;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          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;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta17 = MMC_CAR(tmp4_1);
          tmpMeta18 = MMC_CDR(tmp4_1);
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 4));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta21 = MMC_CAR(tmp4_2);
          tmpMeta22 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta21,8,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,5,1) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,6,2) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          
          _ident = tmpMeta19;
          _ty = tmpMeta20;
          _vlst = tmpMeta18;
          _e2 = tmpMeta21;
          _op = tmpMeta23;
          _cr2 = tmpMeta25;
          _elst = tmpMeta22;
          /* Pattern matching succeeded */
          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReference_crefPrependIdent(threadData, _cr, _ident, tmpMeta26, _ty);

          tmpMeta27 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr1, _ty);
          tmpMeta28 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, tmpMeta27);
          _e1 = tmpMeta28;
          tmpMeta30 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(1 /* true */));
          tmpMeta29 = mmc_mk_cons(tmpMeta30, _inTpls);
          /* Tail recursive call */
          _varLst = _vlst;
          _explst = _elst;
          _inTpls = tmpMeta29;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_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_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta31 = MMC_CAR(tmp4_1);
          tmpMeta32 = MMC_CDR(tmp4_1);
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 2));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 4));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta35 = MMC_CAR(tmp4_2);
          tmpMeta36 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,8,2) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,6,1) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,6,2) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          
          _ident = tmpMeta33;
          _ty = tmpMeta34;
          _vlst = tmpMeta32;
          _e2 = tmpMeta35;
          _op = tmpMeta37;
          _cr2 = tmpMeta39;
          _elst = tmpMeta36;
          /* Pattern matching succeeded */
          tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReference_crefPrependIdent(threadData, _cr, _ident, tmpMeta40, _ty);

          tmpMeta41 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr1, _ty);
          tmpMeta42 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, tmpMeta41);
          _e1 = tmpMeta42;
          tmpMeta44 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(1 /* true */));
          tmpMeta43 = mmc_mk_cons(tmpMeta44, _inTpls);
          /* Tail recursive call */
          _varLst = _vlst;
          _explst = _elst;
          _inTpls = tmpMeta43;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          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;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta45 = MMC_CAR(tmp4_1);
          tmpMeta46 = MMC_CDR(tmp4_1);
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 2));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 4));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta49 = MMC_CAR(tmp4_2);
          tmpMeta50 = MMC_CDR(tmp4_2);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta49,10,2) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta51,24,1) == 0) goto tmp3_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta52,6,2) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          
          _ident = tmpMeta47;
          _ty = tmpMeta48;
          _vlst = tmpMeta46;
          _e2 = tmpMeta49;
          _op = tmpMeta51;
          _cr2 = tmpMeta53;
          _elst = tmpMeta50;
          /* Pattern matching succeeded */
          tmpMeta54 = MMC_REFSTRUCTLIT(mmc_nil);
          _cr1 = omc_ComponentReference_crefPrependIdent(threadData, _cr, _ident, tmpMeta54, _ty);

          tmpMeta55 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, _cr1, _ty);
          tmpMeta56 = mmc_mk_box3(13, &DAE_Exp_LUNARY__desc, _op, tmpMeta55);
          _e1 = tmpMeta56;
          tmpMeta58 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(1 /* true */));
          tmpMeta57 = mmc_mk_cons(tmpMeta58, _inTpls);
          /* Tail recursive call */
          _varLst = _vlst;
          _explst = _elst;
          _inTpls = tmpMeta57;
          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:;
    }
  }
  _outTpls = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquation2(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _inTpls)
{
  modelica_metatype _outTpls = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _lhs;
    tmp4_2 = _rhs;
    {
      modelica_metatype _elst1 = NULL;
      modelica_metatype _elst2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _elst1 has no default value.
      // _elst2 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,16,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _elst1 = tmpMeta6;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _rhs)) goto tmp3_end;
          tmpMeta1 = omc_List_fold(threadData, _elst1, boxvar_BackendEquation_aliasExpression, _inTpls);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          
          _elst2 = tmpMeta7;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _lhs)) goto tmp3_end;
          tmpMeta1 = omc_List_fold(threadData, _elst2, boxvar_BackendEquation_aliasExpression, _inTpls);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _rhs)) goto tmp3_end;
          tmpMeta1 = omc_BackendEquation_aliasExpression(threadData, _lhs, _inTpls);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _lhs)) goto tmp3_end;
          tmpMeta1 = omc_BackendEquation_aliasExpression(threadData, _rhs, _inTpls);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpls = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquationLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _inTpls)
{
  modelica_metatype _outTpls = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  _outTpls = omc_List_threadFold(threadData, _elst1, _elst2, boxvar_BackendEquation_aliasEquation1, _inTpls);
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_aliasEquation1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _inTpls)
{
  modelica_metatype _outTpls = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _lhs;
    tmp4_2 = _rhs;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _op = NULL;
      modelica_metatype _elst1 = NULL;
      modelica_metatype _elst2 = NULL;
      modelica_metatype _elstlst1 = NULL;
      modelica_metatype _elstlst2 = NULL;
      modelica_metatype _varLst1 = NULL;
      modelica_metatype _varLst2 = NULL;
      modelica_metatype _patha = NULL;
      modelica_metatype _patha1 = NULL;
      modelica_metatype _pathb = NULL;
      modelica_metatype _pathb1 = 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.
      // _op has no default value.
      // _elst1 has no default value.
      // _elst2 has no default value.
      // _elstlst1 has no default value.
      // _elstlst2 has no default value.
      // _varLst1 has no default value.
      // _varLst2 has no default value.
      // _patha has no default value.
      // _patha1 has no default value.
      // _pathb has no default value.
      // _pathb1 has no default value.
      tmp4 = 0;
      for (; tmp4 < 16; 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,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _cr1 = tmpMeta6;
          _cr2 = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta9 = mmc_mk_box5(0, _cr1, _cr2, _lhs, _rhs, mmc_mk_boolean(0 /* false */));
          tmpMeta8 = mmc_mk_cons(tmpMeta9, _inTpls);
          tmpMeta1 = tmpMeta8;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          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_1,6,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,5,1) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          
          _cr1 = tmpMeta10;
          _op = tmpMeta11;
          _cr2 = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta15 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _lhs);
          tmpMeta16 = mmc_mk_box5(0, _cr1, _cr2, tmpMeta15, _rhs, mmc_mk_boolean(1 /* true */));
          tmpMeta14 = mmc_mk_cons(tmpMeta16, _inTpls);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 2: {
          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(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,6,1) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta19,6,2) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          
          _cr1 = tmpMeta17;
          _op = tmpMeta18;
          _cr2 = tmpMeta20;
          /* Pattern matching succeeded */
          tmpMeta22 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _lhs);
          tmpMeta23 = mmc_mk_box5(0, _cr1, _cr2, tmpMeta22, _rhs, mmc_mk_boolean(1 /* true */));
          tmpMeta21 = mmc_mk_cons(tmpMeta23, _inTpls);
          tmpMeta1 = tmpMeta21;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,5,1) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,6,2) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          
          _cr2 = tmpMeta24;
          _op = tmpMeta25;
          _cr1 = tmpMeta27;
          /* Pattern matching succeeded */
          tmpMeta29 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _rhs);
          tmpMeta30 = mmc_mk_box5(0, _cr1, _cr2, _lhs, tmpMeta29, mmc_mk_boolean(1 /* true */));
          tmpMeta28 = mmc_mk_cons(tmpMeta30, _inTpls);
          tmpMeta1 = tmpMeta28;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,6,1) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta33,6,2) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          
          _cr2 = tmpMeta31;
          _op = tmpMeta32;
          _cr1 = tmpMeta34;
          /* Pattern matching succeeded */
          tmpMeta36 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _rhs);
          tmpMeta37 = mmc_mk_box5(0, _cr1, _cr2, _lhs, tmpMeta36, mmc_mk_boolean(1 /* true */));
          tmpMeta35 = mmc_mk_cons(tmpMeta37, _inTpls);
          tmpMeta1 = tmpMeta35;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,5,1) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,6,2) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta41,5,1) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta42,6,2) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          
          _e1 = tmpMeta39;
          _cr1 = tmpMeta40;
          _e2 = tmpMeta42;
          _cr2 = tmpMeta43;
          /* Pattern matching succeeded */
          tmpMeta45 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta44 = mmc_mk_cons(tmpMeta45, _inTpls);
          tmpMeta1 = tmpMeta44;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,6,1) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta47,6,2) == 0) goto tmp3_end;
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta47), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta49,6,1) == 0) goto tmp3_end;
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta50,6,2) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta50), 2));
          
          _e1 = tmpMeta47;
          _cr1 = tmpMeta48;
          _e2 = tmpMeta50;
          _cr2 = tmpMeta51;
          /* Pattern matching succeeded */
          tmpMeta53 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta52 = mmc_mk_cons(tmpMeta53, _inTpls);
          tmpMeta1 = tmpMeta52;
          goto tmp3_done;
        }
        case 7: {
          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,6,2) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,24,1) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta56,6,2) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 2));
          
          _cr1 = tmpMeta54;
          _op = tmpMeta55;
          _cr2 = tmpMeta57;
          /* Pattern matching succeeded */
          tmpMeta59 = mmc_mk_box3(13, &DAE_Exp_LUNARY__desc, _op, _lhs);
          tmpMeta60 = mmc_mk_box5(0, _cr1, _cr2, tmpMeta59, _rhs, mmc_mk_boolean(1 /* true */));
          tmpMeta58 = mmc_mk_cons(tmpMeta60, _inTpls);
          tmpMeta1 = tmpMeta58;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta62,24,1) == 0) goto tmp3_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,6,2) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          
          _cr2 = tmpMeta61;
          _op = tmpMeta62;
          _cr1 = tmpMeta64;
          /* Pattern matching succeeded */
          tmpMeta66 = mmc_mk_box3(13, &DAE_Exp_LUNARY__desc, _op, _rhs);
          tmpMeta67 = mmc_mk_box5(0, _cr1, _cr2, _lhs, tmpMeta66, mmc_mk_boolean(1 /* true */));
          tmpMeta65 = mmc_mk_cons(tmpMeta67, _inTpls);
          tmpMeta1 = tmpMeta65;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta68,24,1) == 0) goto tmp3_end;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta69,6,2) == 0) goto tmp3_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta71,24,1) == 0) goto tmp3_end;
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta72,6,2) == 0) goto tmp3_end;
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta72), 2));
          
          _e1 = tmpMeta69;
          _cr1 = tmpMeta70;
          _e2 = tmpMeta72;
          _cr2 = tmpMeta73;
          /* Pattern matching succeeded */
          tmpMeta75 = mmc_mk_box5(0, _cr1, _cr2, _e1, _e2, mmc_mk_boolean(0 /* false */));
          tmpMeta74 = mmc_mk_cons(tmpMeta75, _inTpls);
          tmpMeta1 = tmpMeta74;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _elst1 = tmpMeta76;
          _elst2 = tmpMeta77;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_threadFold(threadData, _elst1, _elst2, boxvar_BackendEquation_aliasEquation1, _inTpls);
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,3) == 0) goto tmp3_end;
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,17,3) == 0) goto tmp3_end;
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _elstlst1 = tmpMeta78;
          _elstlst2 = tmpMeta79;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_threadFold(threadData, _elstlst1, _elstlst2, boxvar_BackendEquation_aliasEquationLst, _inTpls);
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,13,3) == 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), 4));
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta83), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta84,9,4) == 0) goto tmp3_end;
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta84), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta85,3,1) == 0) goto tmp3_end;
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta85), 2));
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta84), 3));
          
          _cr1 = tmpMeta80;
          _pathb = tmpMeta81;
          _elst2 = tmpMeta82;
          _pathb1 = tmpMeta86;
          _varLst2 = tmpMeta87;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_AbsynUtil_pathEqual(threadData, _pathb, _pathb1)) goto tmp3_end;
          tmpMeta1 = omc_BackendEquation_aliasRecord(threadData, _cr1, _varLst2, _elst2, _inTpls);
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta88 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta92,9,4) == 0) goto tmp3_end;
          tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta93,3,1) == 0) goto tmp3_end;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta93), 2));
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 3));
          
          _cr2 = tmpMeta88;
          _patha = tmpMeta89;
          _elst1 = tmpMeta90;
          _patha1 = tmpMeta94;
          _varLst1 = tmpMeta95;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_AbsynUtil_pathEqual(threadData, _patha, _patha1)) goto tmp3_end;
          tmpMeta1 = omc_BackendEquation_aliasRecord(threadData, _cr2, _varLst1, _elst1, _inTpls);
          goto tmp3_done;
        }
        case 14: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta99,9,4) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta99), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta100,3,1) == 0) goto tmp3_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta100), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,13,3) == 0) goto tmp3_end;
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta105,9,4) == 0) goto tmp3_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta105), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta106,3,1) == 0) goto tmp3_end;
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta106), 2));
          
          _patha = tmpMeta96;
          _elst1 = tmpMeta97;
          _patha1 = tmpMeta101;
          _pathb = tmpMeta102;
          _elst2 = tmpMeta103;
          _pathb1 = tmpMeta107;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_AbsynUtil_pathEqual(threadData, _patha, _patha1) && omc_AbsynUtil_pathEqual(threadData, _pathb, _pathb1))) goto tmp3_end;
          tmpMeta1 = omc_List_threadFold(threadData, _elst1, _elst2, boxvar_BackendEquation_aliasEquation1, _inTpls);
          goto tmp3_done;
        }
        case 15: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendEquation_aliasEquation2(threadData, _lhs, _rhs, _inTpls);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpls = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

DLLDirection
modelica_metatype omc_BackendEquation_aliasEquation(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_metatype _outTpls = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpls has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _cr = NULL;
      int tmp4;
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _cr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,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));
          
          _e1 = tmpMeta5;
          _e2 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_BackendEquation_aliasEquation1(threadData, _e1, _e2, tmpMeta7);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta8;
          _e2 = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_BackendEquation_aliasEquation1(threadData, _e1, _e2, tmpMeta10);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cr = tmpMeta11;
          _e2 = tmpMeta12;
          /* Pattern matching succeeded */
          _e = omc_Expression_crefExp(threadData, _cr);
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_BackendEquation_aliasEquation1(threadData, _e, _e2, tmpMeta13);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _e1 = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_BackendEquation_aliasExpression(threadData, _e1, tmpMeta15);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta16;
          _e2 = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_BackendEquation_aliasEquation1(threadData, _e1, _e2, tmpMeta18);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpls = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpls;
}

DLLDirection
modelica_metatype omc_BackendEquation_getInitialEqnsFromShared(threadData_t *threadData, modelica_metatype _inShared)
{
  modelica_metatype _outInitialEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outInitialEqs = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inShared), 6)));
  _return: OMC_LABEL_UNUSED
  return _outInitialEqs;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEqnsFromEqSystem(threadData_t *threadData, modelica_metatype _inEqSystem)
{
  modelica_metatype _outOrderedEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outOrderedEqs = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqSystem), 3)));
  _return: OMC_LABEL_UNUSED
  return _outOrderedEqs;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEqnsFromEqSystems(threadData_t *threadData, modelica_metatype _inEqSystems)
{
  modelica_metatype _outOrderedEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outOrderedEqs has no default value.
  _outOrderedEqs = omc_BackendEquation_listEquation(threadData, omc_BackendEquation_equationSystemsEqnsLst(threadData, _inEqSystems));
  _return: OMC_LABEL_UNUSED
  return _outOrderedEqs;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationSystemsEqnsLst(threadData_t *threadData, modelica_metatype _systs)
{
  modelica_metatype _outEqns = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _eqns = NULL;
  modelica_metatype _eq = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEqns = tmpMeta1;
  // _eqns has no default value.
  // _eq has no default value.
  {
    modelica_metatype _es;
    for (tmpMeta2 = _systs; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _es = MMC_CAR(tmpMeta2);
      /* Pattern-matching assignment */
      tmpMeta3 = _es;
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 3));
      _eq = tmpMeta4;

      _eqns = omc_BackendEquation_equationList(threadData, _eq);

      _outEqns = omc_List_append__reverse(threadData, _eqns, _outEqns);
    }
  }

  _outEqns = listReverseInPlace(_outEqns);
  _return: OMC_LABEL_UNUSED
  return _outEqns;
}

DLLDirection
modelica_metatype omc_BackendEquation_generateRESIDUAL__EQUATION1(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _source, modelica_metatype _inEqAttr)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype _e1 = NULL;
  modelica_metatype _e2 = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  // _e1 has no default value.
  // _e2 has no default value.
  // _e 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;

  _e = omc_Expression_createResidualExp(threadData, _e1, _e2);

  tmpMeta4 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _inEqAttr);
  _outEqn = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  return _outEqn;
}

DLLDirection
modelica_metatype omc_BackendEquation_generateRESIDUAL__EQUATION(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inSource, modelica_metatype _inEqAttr)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  tmpMeta1 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _inExp, _inSource, _inEqAttr);
  _outEqn = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEqn;
}

DLLDirection
modelica_metatype omc_BackendEquation_solveEquation(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _crefExp, modelica_metatype _functions)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _eqn;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _res has no default value.
      // _cref has no default value.
      // _cr has no default value.
      // _source 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 < 7; 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,0,4) == 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));
          _e1 = tmpMeta6;
          _e2 = tmpMeta7;
          _source = tmpMeta8;
          _eqAttr = tmpMeta9;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta12 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _crefExp, _functions, mmc_mk_none(), 1 /* true */, 0 /* false */, NULL, &tmpMeta10, &tmpMeta11);
          _res = tmpMeta12;
          if (!listEmpty(tmpMeta10)) goto goto_2;
          if (!listEmpty(tmpMeta11)) goto goto_2;
          tmpMeta13 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _res, _source, _eqAttr);
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _e1 = tmpMeta14;
          _e2 = tmpMeta15;
          _source = tmpMeta16;
          _eqAttr = tmpMeta17;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta20 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _crefExp, _functions, mmc_mk_none(), 1 /* true */, 0 /* false */, NULL, &tmpMeta18, &tmpMeta19);
          _res = tmpMeta20;
          if (!listEmpty(tmpMeta18)) goto goto_2;
          if (!listEmpty(tmpMeta19)) goto goto_2;
          tmpMeta21 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _res, _source, _eqAttr);
          tmpMeta1 = tmpMeta21;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_boolean tmp26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 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(tmp4_1), 5));
          _cref = tmpMeta22;
          _e2 = tmpMeta23;
          _source = tmpMeta24;
          _eqAttr = tmpMeta25;
          /* Pattern matching succeeded */
          _cr = omc_Expression_expCref(threadData, _crefExp);

          /* Pattern-matching assignment */
          tmp26 = omc_ComponentReference_crefEqual(threadData, _cref, _cr);
          if (1 /* true */ != tmp26) goto goto_2;
          tmpMeta27 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _e2, _source, _eqAttr);
          tmpMeta1 = tmpMeta27;
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _cref = tmpMeta28;
          _e2 = tmpMeta29;
          _source = tmpMeta30;
          _eqAttr = tmpMeta31;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e1 = omc_Expression_crefExp(threadData, _cref);

          /* Pattern-matching tuple assignment */
          tmpMeta34 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _crefExp, _functions, mmc_mk_none(), 1 /* true */, 0 /* false */, NULL, &tmpMeta32, &tmpMeta33);
          _res = tmpMeta34;
          if (!listEmpty(tmpMeta32)) goto goto_2;
          if (!listEmpty(tmpMeta33)) goto goto_2;
          tmpMeta35 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _res, _source, _eqAttr);
          tmpMeta1 = tmpMeta35;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _e2 = tmpMeta36;
          _source = tmpMeta37;
          _eqAttr = tmpMeta38;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e1 = omc_Expression_makeConstZero(threadData, omc_Expression_typeof(threadData, _e2));

          /* Pattern-matching tuple assignment */
          tmpMeta41 = omc_ExpressionSolve_solve2(threadData, _e2, _e1, _crefExp, _functions, mmc_mk_none(), 1 /* true */, 0 /* false */, NULL, &tmpMeta39, &tmpMeta40);
          _res = tmpMeta41;
          if (!listEmpty(tmpMeta39)) goto goto_2;
          if (!listEmpty(tmpMeta40)) goto goto_2;
          tmpMeta42 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _res, _source, _eqAttr);
          tmpMeta1 = tmpMeta42;
          goto tmp3_done;
        }
        case 5: {
          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(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta43;
          _e2 = tmpMeta44;
          _source = tmpMeta45;
          _eqAttr = tmpMeta46;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta49 = omc_ExpressionSolve_solve2(threadData, _e1, _e2, _crefExp, _functions, mmc_mk_none(), 1 /* true */, 0 /* false */, NULL, &tmpMeta47, &tmpMeta48);
          _res = tmpMeta49;
          if (!listEmpty(tmpMeta47)) goto goto_2;
          if (!listEmpty(tmpMeta48)) goto goto_2;
          tmpMeta50 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _crefExp, _res, _source, _eqAttr);
          tmpMeta1 = tmpMeta50;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          
          /* Pattern matching succeeded */
          tmpMeta51 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta52 = stringAppend(_OMC_LIT4,omc_ExpressionDump_printExpStr(threadData, _crefExp));
          omc_BackendDump_dumpBackendDAEEqnList(threadData, tmpMeta51, tmpMeta52, 1 /* true */);

          omc_Error_addInternalError(threadData, _OMC_LIT5, _OMC_LIT6);
          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:;
    }
  }
  _outEqn = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEqn;
}

DLLDirection
modelica_metatype omc_BackendEquation_normalizationVec(threadData_t *threadData, modelica_metatype _vec, modelica_string _name, modelica_integer _offset, modelica_metatype _ieqns, modelica_metatype _ivars, modelica_metatype _ishared, modelica_metatype *out_oeqns, modelica_metatype *out_ovars, modelica_metatype *out_oshared)
{
  modelica_metatype _nvec = NULL;
  modelica_metatype _oeqns = NULL;
  modelica_metatype _ovars = NULL;
  modelica_metatype _oshared = NULL;
  modelica_metatype _len = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _nvec has no default value.
  // _oeqns has no default value.
  // _ovars has no default value.
  // _oshared has no default value.
  _len = omc_Expression_lenVec(threadData, _vec);
  _len = omc_BackendEquation_makeTmpEqnForExp(threadData, _len, _name, _offset, _ieqns, _ivars, _ishared, 0 /* false */ ,&_oeqns ,&_ovars ,&_oshared, NULL, NULL);

  if(omc_Expression_isZero(threadData, _len))
  {
    MMC_THROW_INTERNAL();
  }

  _nvec = omc_Array_map1(threadData, _vec, boxvar_Expression_makeDiv, _len);
  _return: OMC_LABEL_UNUSED
  if (out_oeqns) { *out_oeqns = _oeqns; }
  if (out_ovars) { *out_ovars = _ovars; }
  if (out_oshared) { *out_oshared = _oshared; }
  return _nvec;
}
modelica_metatype boxptr_BackendEquation_normalizationVec(threadData_t *threadData, modelica_metatype _vec, modelica_metatype _name, modelica_metatype _offset, modelica_metatype _ieqns, modelica_metatype _ivars, modelica_metatype _ishared, modelica_metatype *out_oeqns, modelica_metatype *out_ovars, modelica_metatype *out_oshared)
{
  modelica_integer tmp1;
  modelica_metatype _nvec = NULL;
  tmp1 = mmc_unbox_integer(_offset);
  _nvec = omc_BackendEquation_normalizationVec(threadData, _vec, _name, tmp1, _ieqns, _ivars, _ishared, out_oeqns, out_ovars, out_oshared);
  /* skip box _nvec; array<DAE.Exp> */
  /* skip box _oeqns; ExpandableArray<BackendDAE.Equation> */
  /* skip box _ovars; BackendDAE.Variables */
  /* skip box _oshared; BackendDAE.Shared */
  return _nvec;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_makeTmpEqnForExp__rule(threadData_t *threadData, modelica_metatype _inExp)
{
  modelica_boolean _allowed;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _allowed has no default value.
  if(((omc_Expression_isCref(threadData, _inExp) || omc_Expression_isConst(threadData, _inExp)) || omc_Expression_isUnaryCref(threadData, _inExp)))
  {
    _allowed = 0 /* false */;

    goto _return;
  }

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inExp;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; 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,7,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));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,3,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _e1 = tmpMeta6;
          _e2 = tmpMeta8;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((omc_Expression_isOne(threadData, _e1) || omc_Expression_isConstMinusOne(threadData, _e1)) && (omc_Expression_isCref(threadData, _e2) || omc_Expression_isUnaryCref(threadData, _e2)))) goto tmp3_end;
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,20,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          _e1 = tmpMeta9;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _inExp = _e1;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          
          /* 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:;
    }
  }
  _allowed = tmp1;
  _return: OMC_LABEL_UNUSED
  return _allowed;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_makeTmpEqnForExp__rule(threadData_t *threadData, modelica_metatype _inExp)
{
  modelica_boolean _allowed;
  modelica_metatype out_allowed;
  _allowed = omc_BackendEquation_makeTmpEqnForExp__rule(threadData, _inExp);
  out_allowed = mmc_mk_icon(_allowed);
  return out_allowed;
}

DLLDirection
modelica_metatype omc_BackendEquation_makeTmpEqnForExp(threadData_t *threadData, modelica_metatype _iExp, modelica_string _name, modelica_integer _offset, modelica_metatype _ieqns, modelica_metatype _ivars, modelica_metatype _ishared, modelica_boolean _noPara, modelica_metatype *out_oeqns, modelica_metatype *out_ovars, modelica_metatype *out_oshared, modelica_boolean *out_update, modelica_boolean *out_para)
{
  modelica_metatype _oExp = NULL;
  modelica_metatype _oeqns = NULL;
  modelica_metatype _ovars = NULL;
  modelica_metatype _oshared = NULL;
  modelica_boolean _update;
  modelica_boolean _para;
  modelica_metatype _cr = NULL;
  modelica_metatype _tmpvar = NULL;
  modelica_string _name_ = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype _y = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _eqnVars = NULL;
  modelica_metatype _eqnKnVars = NULL;
  modelica_metatype _inputsKnVars = NULL;
  modelica_metatype _knowVars = NULL;
  modelica_boolean _b;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oExp has no default value.
  _oeqns = _ieqns;
  _ovars = _ivars;
  _oshared = _ishared;
  // _update has no default value.
  _para = 0 /* false */;
  // _cr has no default value.
  // _tmpvar has no default value.
  tmpMeta1 = stringAppend(_OMC_LIT7,intString(_offset));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT8);
  tmpMeta3 = stringAppend(tmpMeta2,_name);
  _name_ = tmpMeta3;
  // _y has no default value.
  // _eqn has no default value.
  // _eqnVars has no default value.
  // _eqnKnVars has no default value.
  // _inputsKnVars has no default value.
  // _knowVars has no default value.
  // _b has no default value.
  _y = omc_ExpressionSimplify_simplify(threadData, _iExp, NULL);

  if(omc_BackendEquation_makeTmpEqnForExp__rule(threadData, _y))
  {
    _update = 1 /* true */;

    tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
    _cr = omc_ComponentReference_makeCrefIdent(threadData, _name_, _OMC_LIT9, tmpMeta4);

    _oExp = omc_Expression_crefExp(threadData, _cr);

    _tmpvar = omc_BackendVariable_makeVar(threadData, _cr);

    _tmpvar = omc_BackendVariable_setVarTS(threadData, _tmpvar, _OMC_LIT11);

    tmpMeta5 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _oExp, _y, _OMC_LIT16, _OMC_LIT19);
    _eqn = tmpMeta5;

    if(omc_Flags_isSet(threadData, _OMC_LIT24))
    {
      tmpMeta6 = stringAppend(omc_BackendDump_equationString(threadData, _eqn),_OMC_LIT20);
      fputs(MMC_STRINGDATA(tmpMeta6),stdout);
    }

    _eqnVars = omc_BackendEquation_equationVars(threadData, _eqn, _ivars);

    _b = (listEmpty(_eqnVars) && (!omc_Expression_expHasCref(threadData, _y, _OMC_LIT26)));

    if(_b)
    {
      _knowVars = omc_BackendVariable_daeGlobalKnownVars(threadData, _oshared);

      _eqnKnVars = omc_BackendEquation_equationVars(threadData, _eqn, _knowVars);

      _inputsKnVars = omc_List_splitOnTrue(threadData, _eqnKnVars, boxvar_BackendVariable_isInput, NULL);

      _b = listEmpty(_inputsKnVars);
    }

    _b = 0 /* false */;

    if(_b)
    {
      if(_noPara)
      {
        _oExp = omc_ExpressionSimplify_simplify(threadData, _iExp, NULL);

        _update = 0 /* false */;
      }
      else
      {
        _tmpvar = omc_BackendVariable_setBindExp(threadData, _tmpvar, mmc_mk_some(_y));

        _tmpvar = omc_BackendVariable_setVarKind(threadData, _tmpvar, _OMC_LIT27);

        _oshared = omc_BackendVariable_addGlobalKnownVarDAE(threadData, _tmpvar, _oshared);

        _para = 1 /* true */;
      }
    }
    else
    {
      _oeqns = omc_BackendEquation_add(threadData, _eqn, _oeqns);

      _ovars = omc_BackendVariable_addVar(threadData, _tmpvar, _ovars);
    }
  }
  else
  {
    _oExp = _y;

    _update = 0 /* false */;
  }
  _return: OMC_LABEL_UNUSED
  if (out_oeqns) { *out_oeqns = _oeqns; }
  if (out_ovars) { *out_ovars = _ovars; }
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_update) { *out_update = _update; }
  if (out_para) { *out_para = _para; }
  return _oExp;
}
modelica_metatype boxptr_BackendEquation_makeTmpEqnForExp(threadData_t *threadData, modelica_metatype _iExp, modelica_metatype _name, modelica_metatype _offset, modelica_metatype _ieqns, modelica_metatype _ivars, modelica_metatype _ishared, modelica_metatype _noPara, modelica_metatype *out_oeqns, modelica_metatype *out_ovars, modelica_metatype *out_oshared, modelica_metatype *out_update, modelica_metatype *out_para)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_boolean _update;
  modelica_boolean _para;
  modelica_metatype _oExp = NULL;
  tmp1 = mmc_unbox_integer(_offset);
  tmp2 = mmc_unbox_integer(_noPara);
  _oExp = omc_BackendEquation_makeTmpEqnForExp(threadData, _iExp, _name, tmp1, _ieqns, _ivars, _ishared, tmp2, out_oeqns, out_ovars, out_oshared, &_update, &_para);
  /* skip box _oExp; DAE.Exp */
  /* skip box _oeqns; ExpandableArray<BackendDAE.Equation> */
  /* skip box _ovars; BackendDAE.Variables */
  /* skip box _oshared; BackendDAE.Shared */
  if (out_update) { *out_update = mmc_mk_icon(_update); }
  if (out_para) { *out_para = mmc_mk_icon(_para); }
  return _oExp;
}

DLLDirection
modelica_metatype omc_BackendEquation_generateResidualFromRelation(threadData_t *threadData, modelica_string _conCrefName, modelica_metatype _iRhs, modelica_metatype _Source, modelica_metatype _inVars, modelica_metatype _knvars, modelica_metatype _conKind, modelica_metatype *out_vout)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype _vout = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  // _vout has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iRhs;
    {
      modelica_metatype _rhs = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _expNull = NULL;
      modelica_metatype _lowBound = NULL;
      modelica_metatype _lhs = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _dummyVar = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _eqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rhs has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _expNull has no default value.
      // _lowBound has no default value.
      // _lhs has no default value.
      // _cr has no default value.
      // _dummyVar has no default value.
      // _v has no default value.
      // _eqn has no default value.
      tmp4 = 0;
      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_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,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));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,25,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta6;
          _e2 = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta9);

          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta11 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta10, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta11;

          _rhs = omc_Expression_expSub(threadData, _e1, _e2);

          _rhs = omc_ExpressionSimplify_simplify1(threadData, _rhs, NULL);

          _expNull = _OMC_LIT32;

          _lowBound = _OMC_LIT34;

          _dummyVar = omc_BackendVariable_setVarMinMax(threadData, _dummyVar, mmc_mk_some(_lowBound), mmc_mk_some(_expNull));
          tmpMeta13 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _rhs, _Source, _OMC_LIT36);
          tmpMeta12 = mmc_mk_cons(tmpMeta13, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta12;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,26,1) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta14;
          _e2 = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta17);

          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta19 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta18, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta19;

          _rhs = omc_Expression_expSub(threadData, _e1, _e2);

          _rhs = omc_ExpressionSimplify_simplify1(threadData, _rhs, NULL);

          _expNull = _OMC_LIT32;

          _lowBound = _OMC_LIT34;

          _dummyVar = omc_BackendVariable_setVarMinMax(threadData, _dummyVar, mmc_mk_some(_lowBound), mmc_mk_some(_expNull));
          tmpMeta21 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _rhs, _Source, _OMC_LIT36);
          tmpMeta20 = mmc_mk_cons(tmpMeta21, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta20;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        case 2: {
          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,11,5) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,27,1) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta22;
          _e2 = tmpMeta24;
          /* Pattern matching succeeded */
          tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta25);

          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta27 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta26, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta27;

          _rhs = omc_Expression_expSub(threadData, _e2, _e1);

          _rhs = omc_ExpressionSimplify_simplify1(threadData, _rhs, NULL);

          _expNull = _OMC_LIT32;

          _lowBound = _OMC_LIT34;

          _dummyVar = omc_BackendVariable_setVarMinMax(threadData, _dummyVar, mmc_mk_some(_lowBound), mmc_mk_some(_expNull));
          tmpMeta29 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _rhs, _Source, _OMC_LIT36);
          tmpMeta28 = mmc_mk_cons(tmpMeta29, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta28;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta31,28,1) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta30;
          _e2 = tmpMeta32;
          /* Pattern matching succeeded */
          tmpMeta33 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta33);

          tmpMeta34 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta35 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta34, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta35;

          _rhs = omc_Expression_expSub(threadData, _e2, _e1);

          _rhs = omc_ExpressionSimplify_simplify(threadData, _rhs, NULL);

          _expNull = _OMC_LIT32;

          _lowBound = _OMC_LIT34;

          _dummyVar = omc_BackendVariable_setVarMinMax(threadData, _dummyVar, mmc_mk_some(_lowBound), mmc_mk_some(_expNull));
          tmpMeta37 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _rhs, _Source, _OMC_LIT36);
          tmpMeta36 = mmc_mk_cons(tmpMeta37, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta36;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,29,1) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta38;
          _e2 = tmpMeta40;
          /* Pattern matching succeeded */
          tmpMeta41 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta41);

          tmpMeta42 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta43 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta42, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta43;

          _rhs = omc_Expression_expSub(threadData, _e2, _e1);

          _rhs = omc_ExpressionSimplify_simplify(threadData, _rhs, NULL);

          _expNull = _OMC_LIT32;

          _dummyVar = omc_BackendVariable_setVarMinMax(threadData, _dummyVar, mmc_mk_some(_expNull), mmc_mk_some(_expNull));
          tmpMeta45 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _rhs, _Source, _OMC_LIT36);
          tmpMeta44 = mmc_mk_cons(tmpMeta45, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta44;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _e1 = tmp4_1;
          _cr = tmpMeta46;
          /* Pattern matching succeeded */
          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp49;
              int tmp50;
              tmp49 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp48_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp49 < 2; tmp49++) {
                switch (MMC_SWITCH_CAST(tmp49)) {
                case 0: {
                  /* Pattern matching succeeded */
                  _v = omc_BackendVariable_getVarSingle(threadData, _cr, _inVars, NULL);
                  goto tmp48_done;
                }
                case 1: {
                  /* Pattern matching succeeded */
                  _v = omc_BackendVariable_getVarSingle(threadData, _cr, _knvars, NULL);
                  goto tmp48_done;
                }
                }
                goto tmp48_end;
                tmp48_end: ;
              }
              goto goto_47;
              tmp48_done:
              (void)tmp49;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp48_done2;
              goto_47:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp49 < 2) {
                goto tmp48_top;
              }
              goto goto_2;
              tmp48_done2:;
            }
          }
          ;

          tmpMeta51 = MMC_REFSTRUCTLIT(mmc_nil);
          _lhs = omc_ComponentReference_makeCrefIdent(threadData, _conCrefName, _OMC_LIT9, tmpMeta51);

          tmpMeta52 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta53 = mmc_mk_box19(3, &BackendDAE_Var_VAR__desc, _lhs, _conKind, _OMC_LIT28, _OMC_LIT29, _OMC_LIT9, mmc_mk_none(), mmc_mk_none(), tmpMeta52, _OMC_LIT16, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), _OMC_LIT30, _OMC_LIT31, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
          _dummyVar = tmpMeta53;

          _dummyVar = omc_BackendVariable_mergeAliasVars(threadData, _dummyVar, _v, 0 /* false */, _knvars);

          tmpMeta54 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _lhs, _e1, _Source, _OMC_LIT36);
          _eqn = tmpMeta54;
          tmpMeta55 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta[0+0] = tmpMeta55;
          tmpMeta[0+1] = _dummyVar;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEqn = tmpMeta[0+0];
  _vout = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_vout) { *out_vout = _vout; }
  return _outEqn;
}

DLLDirection
modelica_metatype omc_BackendEquation_generateSolvedEqnsfromOption(threadData_t *threadData, modelica_metatype _inLhs, modelica_metatype _inRhs, modelica_metatype _inSource, modelica_metatype _inEqAttr)
{
  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 = _inRhs;
    {
      modelica_metatype _rhs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rhs 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));
          _rhs = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta8 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _inLhs, _rhs, _inSource, _inEqAttr);
          tmpMeta7 = mmc_mk_cons(tmpMeta8, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta9;
          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;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEquationRHS(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _rhs)
{
  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_metatype _eqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[3] = _rhs;
          _eqn = tmpMeta6;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[4] = _rhs;
          _eqn = tmpMeta7;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[3] = _rhs;
          _eqn = tmpMeta8;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_eqn), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[2] = _rhs;
          _eqn = tmpMeta9;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT37, _OMC_LIT38);
          goto goto_2;
          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;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEquationLHS(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _lhs)
{
  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_metatype _eqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = _lhs;
          _eqn = tmpMeta6;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[3] = _lhs;
          _eqn = tmpMeta7;
          tmpMeta1 = _eqn;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT39, _OMC_LIT40);
          goto goto_2;
          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;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEquationAttributes(threadData_t *threadData, modelica_metatype _inEqn, modelica_metatype _inAttr)
{
  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_metatype _source = NULL;
      modelica_metatype _dimSize = NULL;
      modelica_metatype _lhs = NULL;
      modelica_metatype _rhs = NULL;
      modelica_metatype _componentRef = NULL;
      modelica_integer _size;
      modelica_metatype _recordSize = NULL;
      modelica_metatype _alg = NULL;
      modelica_metatype _expand = NULL;
      modelica_metatype _whenEquation = NULL;
      modelica_metatype _conditions = NULL;
      modelica_metatype _eqnstrue = NULL;
      modelica_metatype _eqnsfalse = NULL;
      int tmp4;
      // _source has no default value.
      // _dimSize has no default value.
      // _lhs has no default value.
      // _rhs has no default value.
      // _componentRef has no default value.
      // _size has no default value.
      // _recordSize has no default value.
      // _alg has no default value.
      // _expand has no default value.
      // _whenEquation has no default value.
      // _conditions has no default value.
      // _eqnstrue has no default value.
      // _eqnsfalse has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,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));
          
          _lhs = tmpMeta5;
          _rhs = tmpMeta6;
          _source = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta8 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _lhs, _rhs, _source, _inAttr);
          tmpMeta1 = tmpMeta8;
          goto tmp3_done;
        }
        case 4: {
          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,1,6) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          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), 7));
          _dimSize = tmpMeta9;
          _lhs = tmpMeta10;
          _rhs = tmpMeta11;
          _source = tmpMeta12;
          _recordSize = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta14 = mmc_mk_box7(4, &BackendDAE_Equation_ARRAY__EQUATION__desc, _dimSize, _lhs, _rhs, _source, _inAttr, _recordSize);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta15;
          
          /* Pattern matching succeeded */
          tmpMeta15 = mmc_mk_box7(11, &BackendDAE_Equation_FOR__EQUATION__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqn), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqn), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqn), 4))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqn), 5))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqn), 6))), _inAttr);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _componentRef = tmpMeta16;
          _rhs = tmpMeta17;
          _source = tmpMeta18;
          /* Pattern matching succeeded */
          tmpMeta19 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _componentRef, _rhs, _source, _inAttr);
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,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));
          
          _rhs = tmpMeta20;
          _source = tmpMeta21;
          /* Pattern matching succeeded */
          tmpMeta22 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _rhs, _source, _inAttr);
          tmpMeta1 = tmpMeta22;
          goto tmp3_done;
        }
        case 7: {
          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,4,5) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _size = tmp24  /* pattern as ty=Integer */;
          _alg = tmpMeta25;
          _source = tmpMeta26;
          _expand = tmpMeta27;
          /* Pattern matching succeeded */
          tmpMeta28 = mmc_mk_box6(7, &BackendDAE_Equation_ALGORITHM__desc, mmc_mk_integer(_size), _alg, _source, _expand, _inAttr);
          tmpMeta1 = tmpMeta28;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 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));
          
          _size = tmp30  /* pattern as ty=Integer */;
          _whenEquation = tmpMeta31;
          _source = tmpMeta32;
          /* Pattern matching succeeded */
          tmpMeta33 = mmc_mk_box5(8, &BackendDAE_Equation_WHEN__EQUATION__desc, mmc_mk_integer(_size), _whenEquation, _source, _inAttr);
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _size = tmp35  /* pattern as ty=Integer */;
          _lhs = tmpMeta36;
          _rhs = tmpMeta37;
          _source = tmpMeta38;
          /* Pattern matching succeeded */
          tmpMeta39 = mmc_mk_box6(9, &BackendDAE_Equation_COMPLEX__EQUATION__desc, mmc_mk_integer(_size), _lhs, _rhs, _source, _inAttr);
          tmpMeta1 = tmpMeta39;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _conditions = tmpMeta40;
          _eqnstrue = tmpMeta41;
          _eqnsfalse = tmpMeta42;
          _source = tmpMeta43;
          /* Pattern matching succeeded */
          tmpMeta44 = mmc_mk_box6(10, &BackendDAE_Equation_IF__EQUATION__desc, _conditions, _eqnstrue, _eqnsfalse, _source, _inAttr);
          tmpMeta1 = tmpMeta44;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT41, _OMC_LIT42);
          goto goto_2;
          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;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEquationAttributes(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_metatype _outAttr = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outAttr has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqn;
    {
      modelica_metatype _attr = NULL;
      int tmp4;
      // _attr 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,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _attr = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          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));
          
          _attr = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _attr = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _attr = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          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), 6));
          _attr = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _attr = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _attr = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _attr = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          _attr = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta1 = _attr;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT43, _OMC_LIT44);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outAttr = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outAttr;
}

DLLDirection
modelica_metatype omc_BackendEquation_getEquationArraySubsetLst(threadData_t *threadData, modelica_metatype _eqnArr, modelica_metatype _iLst)
{
  modelica_metatype _subset = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _subset = tmpMeta1;
  {
    modelica_metatype _i;
    for (tmpMeta2 = _iLst; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _i = MMC_CAR(tmpMeta2);
      tmpMeta3 = mmc_mk_cons(omc_ExpandableArray_get(threadData, mmc_unbox_integer(_i), _eqnArr), _subset);
      _subset = tmpMeta3;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _subset;
}

DLLDirection
modelica_metatype omc_BackendEquation_generateEquation(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _source, modelica_metatype _inEqAttr)
{
  modelica_metatype _outEqn = NULL;
  modelica_metatype _ty = NULL;
  modelica_metatype _tp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqn has no default value.
  // _ty has no default value.
  // _tp has no default value.
  _ty = omc_Expression_typeof(threadData, _lhs);

  { /* match expression */
    {
      modelica_integer _size;
      modelica_metatype _recordSize = NULL;
      modelica_metatype _dims = NULL;
      modelica_metatype _ds = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _size has no default value.
      // _recordSize has no default value.
      // _dims has no default value.
      // _ds has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_DAEUtil_expTypeComplex(threadData, _ty) || omc_DAEUtil_expTypeTuple(threadData, _ty))) goto tmp3_end;
          _size = omc_Expression_sizeOf(threadData, _ty);
          tmpMeta6 = mmc_mk_box6(9, &BackendDAE_Equation_COMPLEX__EQUATION__desc, mmc_mk_integer(_size), _lhs, _rhs, _source, _inEqAttr);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_DAEUtil_expTypeArray(threadData, _ty)) goto tmp3_end;
          _tp = omc_Expression_typeof(threadData, _lhs);

          _tp = omc_DAEUtil_expTypeElementType(threadData, _tp);

          if(omc_DAEUtil_expTypeComplex(threadData, _tp))
          {
            _recordSize = mmc_mk_some(mmc_mk_integer(omc_Expression_sizeOf(threadData, _tp)));
          }
          else
          {
            _recordSize = mmc_mk_none();
          }

          _dims = omc_Expression_arrayDimension(threadData, _ty);

          _ds = omc_Expression_dimensionsSizes(threadData, _dims);
          tmpMeta7 = mmc_mk_box7(4, &BackendDAE_Equation_ARRAY__EQUATION__desc, _ds, _lhs, _rhs, _source, _inEqAttr, _recordSize);
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((!omc_DAEUtil_expTypeComplex(threadData, _ty)) && (!omc_DAEUtil_expTypeArray(threadData, _ty)))) goto tmp3_end;
          tmpMeta8 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _lhs, _rhs, _source, _inEqAttr);
          tmpMeta1 = tmpMeta8;
          goto tmp3_done;
        }
        case 3: {
          modelica_boolean tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp9 = omc_Flags_isSet(threadData, _OMC_LIT48);
          if (1 /* true */ != tmp9) goto goto_2;

          tmpMeta10 = stringAppend(_OMC_LIT49,omc_ExpressionDump_printExpStr(threadData, _lhs));
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT50);
          tmpMeta12 = stringAppend(tmpMeta11,omc_ExpressionDump_printExpStr(threadData, _rhs));
          tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT51);
          omc_Debug_traceln(threadData, tmpMeta13);
          goto goto_2;
          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;
}

DLLDirection
modelica_integer omc_BackendEquation_equationLstSizeKeepAlgorithmAsOne(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_integer _size;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _size = ((modelica_integer) 0);
  {
    modelica_metatype _eqn;
    for (tmpMeta1 = _inEqns; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqn = MMC_CAR(tmpMeta1);
      _size = _size + omc_BackendEquation_equationSizeKeepAlgorithmAsOne(threadData, _eqn);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _size;
}
modelica_metatype boxptr_BackendEquation_equationLstSizeKeepAlgorithmAsOne(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_integer _size;
  modelica_metatype out_size;
  _size = omc_BackendEquation_equationLstSizeKeepAlgorithmAsOne(threadData, _inEqns);
  out_size = mmc_mk_icon(_size);
  return out_size;
}

DLLDirection
modelica_integer omc_BackendEquation_equationLstSize(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_integer _size;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _size = ((modelica_integer) 0);
  {
    modelica_metatype _eqn;
    for (tmpMeta1 = _inEqns; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqn = MMC_CAR(tmpMeta1);
      _size = _size + omc_BackendEquation_equationSize(threadData, _eqn);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _size;
}
modelica_metatype boxptr_BackendEquation_equationLstSize(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_integer _size;
  modelica_metatype out_size;
  _size = omc_BackendEquation_equationLstSize(threadData, _inEqns);
  out_size = mmc_mk_icon(_size);
  return out_size;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEquationEvalStage(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqn, modelica_fnptr _func)
{
  modelica_metatype _eqn = NULL;
  modelica_metatype _attr = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqn = __omcQ_24in_5Feqn;
  // _attr has no default value.
  _attr = omc_BackendEquation_getEquationAttributes(threadData, _eqn);

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(5));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_attr), 5*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[4] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_attr), 4)))) : ((modelica_metatype(*)(threadData_t*, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_attr), 4))));
  _attr = tmpMeta1;

  _eqn = omc_BackendEquation_setEquationAttributes(threadData, _eqn, _attr);
  _return: OMC_LABEL_UNUSED
  return _eqn;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStage(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage, modelica_boolean _dynamicEval, modelica_boolean _algebraicEval, modelica_boolean _zerocrossEval, modelica_boolean _discreteEval)
{
  modelica_metatype _evalStage = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[2] = mmc_mk_boolean(_dynamicEval);
  _evalStage = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[3] = mmc_mk_boolean(_algebraicEval);
  _evalStage = tmpMeta2;

  tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[4] = mmc_mk_boolean(_zerocrossEval);
  _evalStage = tmpMeta3;

  tmpMeta4 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta4), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta4))[5] = mmc_mk_boolean(_discreteEval);
  _evalStage = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}
modelica_metatype boxptr_BackendEquation_setEvalStage(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage, modelica_metatype _dynamicEval, modelica_metatype _algebraicEval, modelica_metatype _zerocrossEval, modelica_metatype _discreteEval)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_metatype _evalStage = NULL;
  tmp1 = mmc_unbox_integer(_dynamicEval);
  tmp2 = mmc_unbox_integer(_algebraicEval);
  tmp3 = mmc_unbox_integer(_zerocrossEval);
  tmp4 = mmc_unbox_integer(_discreteEval);
  _evalStage = omc_BackendEquation_setEvalStage(threadData, __omcQ_24in_5FevalStage, tmp1, tmp2, tmp3, tmp4);
  /* skip box _evalStage; BackendDAE.EvaluationStages */
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageAll(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  _evalStage = omc_BackendEquation_setEvalStage(threadData, _evalStage, 1 /* true */, 1 /* true */, 1 /* true */, 1 /* true */);
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageOnlyDiscrete(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  _evalStage = omc_BackendEquation_setEvalStage(threadData, _evalStage, 0 /* false */, 0 /* false */, 0 /* false */, 1 /* true */);
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageDiscrete(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[5] = mmc_mk_boolean(1 /* true */);
  _evalStage = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageZeroCross(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[4] = mmc_mk_boolean(1 /* true */);
  _evalStage = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageAlgebraic(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[3] = mmc_mk_boolean(1 /* true */);
  _evalStage = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEvalStageDynamic(threadData_t *threadData, modelica_metatype __omcQ_24in_5FevalStage)
{
  modelica_metatype _evalStage = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _evalStage = __omcQ_24in_5FevalStage;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(6));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_evalStage), 6*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[2] = mmc_mk_boolean(1 /* true */);
  _evalStage = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _evalStage;
}

DLLDirection
modelica_metatype omc_BackendEquation_setEquationKind(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feq, modelica_metatype __omcQ_24in_5Fk, modelica_metatype *out_k)
{
  modelica_metatype _eq = NULL;
  modelica_metatype _k = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eq = __omcQ_24in_5Feq;
  _k = __omcQ_24in_5Fk;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _a = NULL;
      int tmp4;
      // _a has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _a = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[3] = _k;
          _a = tmpMeta6;

          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eq), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[5] = _a;
          _eq = tmpMeta7;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _a = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[3] = _k;
          _a = tmpMeta9;

          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_eq), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[6] = _a;
          _eq = tmpMeta10;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          _a = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[3] = _k;
          _a = tmpMeta12;

          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_eq), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[7] = _a;
          _eq = tmpMeta13;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _a = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[3] = _k;
          _a = tmpMeta15;

          tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_eq), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[5] = _a;
          _eq = tmpMeta16;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _a = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[3] = _k;
          _a = tmpMeta18;

          tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_eq), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[4] = _a;
          _eq = tmpMeta19;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _a = tmpMeta20;
          /* Pattern matching succeeded */
          tmpMeta21 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta21), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta21))[3] = _k;
          _a = tmpMeta21;

          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_eq), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[5] = _a;
          _eq = tmpMeta22;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _a = tmpMeta23;
          /* Pattern matching succeeded */
          tmpMeta24 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta24), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta24))[3] = _k;
          _a = tmpMeta24;

          tmpMeta25 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta25), MMC_UNTAGPTR(_eq), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta25))[6] = _a;
          _eq = tmpMeta25;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _a = tmpMeta26;
          /* Pattern matching succeeded */
          tmpMeta27 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta27), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta27))[3] = _k;
          _a = tmpMeta27;

          tmpMeta28 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta28), MMC_UNTAGPTR(_eq), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta28))[6] = _a;
          _eq = tmpMeta28;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _a = tmpMeta29;
          /* Pattern matching succeeded */
          tmpMeta30 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta30), MMC_UNTAGPTR(_a), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta30))[3] = _k;
          _a = tmpMeta30;

          tmpMeta31 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta31), MMC_UNTAGPTR(_eq), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta31))[6] = _a;
          _eq = tmpMeta31;
          tmpMeta1 = _eq;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT52, _OMC_LIT53);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _eq = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_k) { *out_k = _k; }
  return _eq;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationKind(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_metatype _outEqKind = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqKind has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _kind = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _kind has no default value.
      tmp4 = 0;
      for (; tmp4 < 10; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          
          _kind = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          
          _kind = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
          
          _kind = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          
          _kind = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          
          _kind = tmpMeta15;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
          
          _kind = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 3));
          
          _kind = tmpMeta19;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 3));
          
          _kind = tmpMeta21;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 3));
          
          _kind = tmpMeta23;
          /* Pattern matching succeeded */
          tmpMeta1 = _kind;
          goto tmp3_done;
        }
        case 9: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT54, _OMC_LIT55);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEqKind = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEqKind;
}

DLLDirection
modelica_metatype omc_BackendEquation_defaultClockedEqAttr(threadData_t *threadData, modelica_integer _clockIndex)
{
  modelica_metatype _outEqAttr = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqAttr has no default value.
  tmpMeta1 = mmc_mk_box2(6, &BackendDAE_EquationKind_CLOCKED__EQUATION__desc, mmc_mk_integer(_clockIndex));
  tmpMeta2 = mmc_mk_box4(3, &BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc, mmc_mk_boolean(0 /* false */), tmpMeta1, _OMC_LIT18);
  _outEqAttr = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outEqAttr;
}
modelica_metatype boxptr_BackendEquation_defaultClockedEqAttr(threadData_t *threadData, modelica_metatype _clockIndex)
{
  modelica_integer tmp1;
  modelica_metatype _outEqAttr = NULL;
  tmp1 = mmc_unbox_integer(_clockIndex);
  _outEqAttr = omc_BackendEquation_defaultClockedEqAttr(threadData, tmp1);
  /* skip box _outEqAttr; BackendDAE.EquationAttributes */
  return _outEqAttr;
}

DLLDirection
modelica_boolean omc_BackendEquation_isAuxEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqKind;
    {
      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,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:;
    }
  }
  _outBool = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isAuxEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isAuxEqKind(threadData, _inEqKind);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isAuxEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  _outBool = omc_BackendEquation_isAuxEqKind(threadData, omc_BackendEquation_equationKind(threadData, _inEquation));
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isAuxEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isAuxEquation(threadData, _inEquation);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isDiscreteEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqKind;
    {
      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,4,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:;
    }
  }
  _outBool = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isDiscreteEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isDiscreteEqKind(threadData, _inEqKind);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isDiscreteEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  _outBool = omc_BackendEquation_isDiscreteEqKind(threadData, omc_BackendEquation_equationKind(threadData, _inEquation));
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isDiscreteEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isDiscreteEquation(threadData, _inEquation);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isBindingEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqKind;
    {
      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,0,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:;
    }
  }
  _outBool = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isBindingEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isBindingEqKind(threadData, _inEqKind);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isBindingEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  _outBool = omc_BackendEquation_isBindingEqKind(threadData, omc_BackendEquation_equationKind(threadData, _inEquation));
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isBindingEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isBindingEquation(threadData, _inEquation);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isDynamicEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqKind;
    {
      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:;
    }
  }
  _outBool = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isDynamicEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isDynamicEqKind(threadData, _inEqKind);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isDynamicEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  _outBool = omc_BackendEquation_isDynamicEqKind(threadData, omc_BackendEquation_equationKind(threadData, _inEquation));
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isDynamicEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isDynamicEquation(threadData, _inEquation);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isInitialEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEqKind;
    {
      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:;
    }
  }
  _outBool = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isInitialEqKind(threadData_t *threadData, modelica_metatype _inEqKind)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isInitialEqKind(threadData, _inEqKind);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_boolean omc_BackendEquation_isInitialEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype _eqKind = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBool has no default value.
  // _eqKind has no default value.
  _eqKind = omc_BackendEquation_equationKind(threadData, _inEquation);

  _outBool = omc_BackendEquation_isInitialEqKind(threadData, _eqKind);
  _return: OMC_LABEL_UNUSED
  return _outBool;
}
modelica_metatype boxptr_BackendEquation_isInitialEquation(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_boolean _outBool;
  modelica_metatype out_outBool;
  _outBool = omc_BackendEquation_isInitialEquation(threadData, _inEquation);
  out_outBool = mmc_mk_icon(_outBool);
  return out_outBool;
}

DLLDirection
modelica_integer omc_BackendEquation_equationSize(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _osize;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _osize has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eq;
    {
      modelica_metatype _ds = NULL;
      modelica_integer _size;
      modelica_integer _start;
      modelica_integer _stop;
      modelica_integer _recordSize;
      modelica_metatype _eqnsfalse = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ds has no default value.
      // _size has no default value.
      // _start has no default value.
      // _stop has no default value.
      // _recordSize has no default value.
      // _eqnsfalse has no default value.
      tmp4 = 0;
      for (; tmp4 < 11; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          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));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          _ds = tmpMeta6;
          _recordSize = tmp9  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = (mmc_unbox_integer(omc_List_fold(threadData, _ds, boxvar_intMul, mmc_mk_integer(((modelica_integer) 1))))) * (_recordSize);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (!optionNone(tmpMeta11)) goto tmp3_end;
          _ds = tmpMeta10;
          /* Pattern matching succeeded */
          tmp1 = mmc_unbox_integer(omc_List_fold(threadData, _ds, boxvar_intMul, mmc_mk_integer(((modelica_integer) 1))));
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1);
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          
          _size = tmp13  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _size;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          
          _size = tmp15  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _size;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          
          _size = tmp17  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _size;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _eqnsfalse = tmpMeta18;
          /* Pattern matching succeeded */
          tmp1 = omc_BackendEquation_equationLstSize(threadData, _eqnsfalse);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta19,0,1) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,0,1) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          
          _start = tmp21  /* pattern as ty=Integer */;
          _stop = tmp24  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = (((modelica_integer) 1) + _stop - _start) * (omc_BackendEquation_equationSize(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 5)))));
          goto tmp3_done;
        }
        case 10: {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT56, _OMC_LIT57);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _osize = tmp1;
  _return: OMC_LABEL_UNUSED
  return _osize;
}
modelica_metatype boxptr_BackendEquation_equationSize(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _osize;
  modelica_metatype out_osize;
  _osize = omc_BackendEquation_equationSize(threadData, _eq);
  out_osize = mmc_mk_icon(_osize);
  return out_osize;
}

DLLDirection
modelica_integer omc_BackendEquation_equationSizeKeepAlgorithmAsOne(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _osize;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _osize 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,4,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = ((modelica_integer) 1);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = omc_BackendEquation_equationSize(threadData, _eq);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _osize = tmp1;
  _return: OMC_LABEL_UNUSED
  return _osize;
}
modelica_metatype boxptr_BackendEquation_equationSizeKeepAlgorithmAsOne(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_integer _osize;
  modelica_metatype out_osize;
  _osize = omc_BackendEquation_equationSizeKeepAlgorithmAsOne(threadData, _eq);
  out_osize = mmc_mk_icon(_osize);
  return out_osize;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationSource(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _source = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _source 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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _source = tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          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), 5));
          
          _source = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _source = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _source = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _source = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _source = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _source = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _source = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta1 = _source;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT58, _OMC_LIT59);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _source = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _source;
}

DLLDirection
modelica_metatype omc_BackendEquation_markedEquationSource(threadData_t *threadData, modelica_metatype _inEqSystem, modelica_integer _inPos)
{
  modelica_metatype _outSource = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSource has no default value.
  _outSource = omc_BackendEquation_equationSource(threadData, omc_BackendEquation_get(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqSystem), 3))), _inPos));
  _return: OMC_LABEL_UNUSED
  return _outSource;
}
modelica_metatype boxptr_BackendEquation_markedEquationSource(threadData_t *threadData, modelica_metatype _inEqSystem, modelica_metatype _inPos)
{
  modelica_integer tmp1;
  modelica_metatype _outSource = NULL;
  tmp1 = mmc_unbox_integer(_inPos);
  _outSource = omc_BackendEquation_markedEquationSource(threadData, _inEqSystem, tmp1);
  /* skip box _outSource; DAE.ElementSource */
  return _outSource;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationInfo(threadData_t *threadData, modelica_metatype _eq)
{
  modelica_metatype _info = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _info has no default value.
  _info = omc_ElementSource_getElementSourceFileInfo(threadData, omc_BackendEquation_equationSource(threadData, _eq));
  _return: OMC_LABEL_UNUSED
  return _info;
}

DLLDirection
modelica_metatype omc_BackendEquation_convertResidualsIntoSolvedEquations(threadData_t *threadData, modelica_metatype _inResidualList, modelica_string _inName, modelica_integer _inIndex, modelica_boolean _isResidual, modelica_metatype *out_outVariableList, modelica_integer *out_outVarIndex)
{
  modelica_metatype _outEquationList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outVariableList = NULL;
  modelica_metatype tmpMeta2;
  modelica_integer _outVarIndex;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta18;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEquationList = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _outVariableList = tmpMeta2;
  _outVarIndex = _inIndex;
  {
    modelica_metatype _eq;
    for (tmpMeta3 = _inResidualList; !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _eq = MMC_CAR(tmpMeta3);
      { /* match expression */
        modelica_metatype tmp6_1;
        tmp6_1 = _eq;
        {
          modelica_metatype _exp = NULL;
          modelica_metatype _source = NULL;
          modelica_metatype _eqAttr = NULL;
          modelica_metatype _componentRef = NULL;
          modelica_metatype _currEquation = NULL;
          modelica_metatype _currVariable = NULL;
          volatile mmc_switch_type tmp6;
          int tmp7;
          // _exp has no default value.
          // _source has no default value.
          // _eqAttr has no default value.
          // _componentRef has no default value.
          // _currEquation has no default value.
          // _currVariable 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;
              modelica_metatype tmpMeta15;
              modelica_metatype tmpMeta16;
              if (mmc__uniontype__metarecord__typedef__equal(tmp6_1,3,3) == 0) goto tmp5_end;
              tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 2));
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 3));
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp6_1), 4));
              _exp = tmpMeta8;
              _source = tmpMeta9;
              _eqAttr = tmpMeta10;
              /* Pattern matching succeeded */
              tmpMeta11 = stringAppend(_inName,intString(_outVarIndex));
              tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta13 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, tmpMeta11, omc_Expression_typeof(threadData, _exp), tmpMeta12);
              _componentRef = tmpMeta13;

              tmpMeta14 = mmc_mk_box5(5, &BackendDAE_Equation_SOLVED__EQUATION__desc, _componentRef, _exp, _source, _eqAttr);
              _currEquation = tmpMeta14;

              _currVariable = omc_BackendVariable_makeVar(threadData, _componentRef);

              if(_isResidual)
              {
                _currVariable = omc_BackendVariable_setVarKind(threadData, _currVariable, _OMC_LIT60);
              }

              _outVarIndex = ((modelica_integer) 1) + _outVarIndex;

              tmpMeta15 = mmc_mk_cons(_currEquation, _outEquationList);
              _outEquationList = tmpMeta15;

              tmpMeta16 = mmc_mk_cons(_currVariable, _outVariableList);
              _outVariableList = tmpMeta16;
              goto tmp5_done;
            }
            case 1: {
              modelica_boolean tmp17;
              
              /* Pattern matching succeeded */
              /* Pattern-matching assignment */
              tmp17 = omc_Flags_isSet(threadData, _OMC_LIT48);
              if (1 /* true */ != tmp17) goto goto_4;

              omc_Error_addInternalError(threadData, _OMC_LIT61, _OMC_LIT62);
              goto goto_4;
              goto tmp5_done;
            }
            }
            goto tmp5_end;
            tmp5_end: ;
          }
          goto goto_4;
          goto_4:;
          MMC_THROW_INTERNAL();
          goto tmp5_done;
          tmp5_done:;
        }
      }
      ;
    }
  }

  _outEquationList = listReverseInPlace(_outEquationList);

  _outVariableList = listReverseInPlace(_outVariableList);
  _return: OMC_LABEL_UNUSED
  if (out_outVariableList) { *out_outVariableList = _outVariableList; }
  if (out_outVarIndex) { *out_outVarIndex = _outVarIndex; }
  return _outEquationList;
}
modelica_metatype boxptr_BackendEquation_convertResidualsIntoSolvedEquations(threadData_t *threadData, modelica_metatype _inResidualList, modelica_metatype _inName, modelica_metatype _inIndex, modelica_metatype _isResidual, modelica_metatype *out_outVariableList, modelica_metatype *out_outVarIndex)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer _outVarIndex;
  modelica_metatype _outEquationList = NULL;
  modelica_metatype tmpMeta3;
  tmp1 = mmc_unbox_integer(_inIndex);
  tmp2 = mmc_unbox_integer(_isResidual);
  _outEquationList = omc_BackendEquation_convertResidualsIntoSolvedEquations(threadData, _inResidualList, _inName, tmp1, tmp2, out_outVariableList, &_outVarIndex);
  /* skip box _outEquationList; list<BackendDAE.Equation> */
  /* skip box _outVariableList; list<BackendDAE.Var> */
  if (out_outVarIndex) { *out_outVarIndex = mmc_mk_icon(_outVarIndex); }
  return _outEquationList;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseEquationToScalarResidualForm(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inEqs, modelica_metatype *out_outEqs)
{
  modelica_metatype _outEq = NULL;
  modelica_metatype _outEqs = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEq has no default value.
  // _outEqs has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inEq;
    tmp4_2 = _inEqs;
    {
      modelica_metatype _eqns = NULL;
      modelica_metatype _reqn = NULL;
      modelica_metatype _eqn = NULL;
      modelica_metatype _funcs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqns has no default value.
      // _reqn has no default value.
      // _eqn has no default value.
      // _funcs 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_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _eqn = tmp4_1;
          _funcs = tmpMeta6;
          _eqns = tmpMeta7;
          /* Pattern matching succeeded */
          _reqn = omc_BackendEquation_equationToScalarResidualForm(threadData, _eqn, _funcs);

          _eqns = listAppend(_reqn, _eqns);
          tmpMeta8 = mmc_mk_box2(0, _funcs, _eqns);
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = tmpMeta8;
          goto tmp3_done;
        }
        case 1: {
          modelica_boolean tmp9;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp9 = omc_Flags_isSet(threadData, _OMC_LIT48);
          if (1 /* true */ != tmp9) goto goto_2;

          omc_Error_addInternalError(threadData, _OMC_LIT63, _OMC_LIT64);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEq = tmpMeta[0+0];
  _outEqs = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outEqs) { *out_outEqs = _outEqs; }
  return _outEq;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationToResidualForm(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_metatype _outEquation = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquation has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _backendEq = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _exp has no default value.
      // _cr has no default value.
      // _source has no default value.
      // _backendEq 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 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 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));
          _e1 = tmpMeta6;
          _e2 = tmpMeta7;
          _source = tmpMeta8;
          _eqAttr = tmpMeta9;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

          _e = omc_ExpressionSimplify_simplify(threadData, _exp, NULL);
          tmpMeta10 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _eqAttr);
          tmpMeta1 = tmpMeta10;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          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_1), 4));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _cr = tmpMeta11;
          _e2 = tmpMeta12;
          _source = tmpMeta13;
          _eqAttr = tmpMeta14;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e1 = omc_Expression_crefExp(threadData, _cr);

          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

          _e = omc_ExpressionSimplify_simplify(threadData, _exp, NULL);
          tmpMeta15 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _eqAttr);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta16;
          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;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _e1 = tmpMeta16;
          _e2 = tmpMeta17;
          _source = tmpMeta18;
          _eqAttr = tmpMeta19;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

          _e = omc_ExpressionSimplify_simplify(threadData, _exp, NULL);
          tmpMeta20 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _eqAttr);
          tmpMeta1 = tmpMeta20;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta21;
          _e2 = tmpMeta22;
          _source = tmpMeta23;
          _eqAttr = tmpMeta24;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

          _e = omc_ExpressionSimplify_simplify(threadData, _exp, NULL);
          tmpMeta25 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _eqAttr);
          tmpMeta1 = tmpMeta25;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _backendEq;
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _backendEq;
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta1 = _backendEq;
          goto tmp3_done;
        }
        case 7: {
          modelica_boolean tmp26;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp26 = omc_Flags_isSet(threadData, _OMC_LIT48);
          if (1 /* true */ != tmp26) goto goto_2;

          omc_Debug_trace(threadData, _OMC_LIT65);
          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 < 8) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outEquation = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEquation;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_equationTupleToScalarResidualForm(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _inSource, modelica_metatype _inEqAttr, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _cr;
    tmp4_2 = _inTpl;
    {
      modelica_integer _i;
      modelica_metatype _eqs = NULL;
      modelica_string _str = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _i has no default value.
      // _eqs has no default value.
      // _str has no default value.
      // _e has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          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,3,0) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _i = tmp8  /* pattern as ty=Integer */;
          _eqs = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _i), _eqs);
          tmpMeta1 = tmpMeta10;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (!listEmpty(tmpMeta11)) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _i = tmp13  /* pattern as ty=Integer */;
          _eqs = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta15 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _i), _eqs);
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,1,1) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _i = tmp18  /* pattern as ty=Integer */;
          _eqs = tmpMeta19;
          /* Pattern matching succeeded */
          tmpMeta21 = mmc_mk_box4(25, &DAE_Exp_TSUB__desc, _exp, mmc_mk_integer(_i), _OMC_LIT9);
          tmpMeta22 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, tmpMeta21, _inSource, _inEqAttr);
          tmpMeta20 = mmc_mk_cons(tmpMeta22, _eqs);
          _eqs = tmpMeta20;
          tmpMeta23 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _i), _eqs);
          tmpMeta1 = tmpMeta23;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          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,6,2) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,6,2) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,1,1) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _i = tmp27  /* pattern as ty=Integer */;
          _eqs = tmpMeta28;
          /* Pattern matching succeeded */
          tmpMeta30 = mmc_mk_box4(25, &DAE_Exp_TSUB__desc, _exp, mmc_mk_integer(_i), _OMC_LIT9);
          tmpMeta29 = mmc_mk_cons(tmpMeta30, MMC_REFSTRUCTLIT(mmc_nil));
          _e = omc_Expression_makePureBuiltinCall(threadData, _OMC_LIT66, tmpMeta29, _OMC_LIT9);

          tmpMeta32 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _inSource, _inEqAttr);
          tmpMeta31 = mmc_mk_cons(tmpMeta32, _eqs);
          _eqs = tmpMeta31;
          tmpMeta33 = mmc_mk_box2(0, mmc_mk_integer(((modelica_integer) 1) + _i), _eqs);
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          
          _i = tmp35  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmpMeta36 = stringAppend(_OMC_LIT67,intString(_i));
          tmpMeta37 = stringAppend(tmpMeta36,_OMC_LIT68);
          tmpMeta38 = stringAppend(tmpMeta37,omc_ExpressionDump_printExpStr(threadData, _cr));
          _str = tmpMeta38;

          tmpMeta39 = mmc_mk_cons(_str, MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addSourceMessage(threadData, _OMC_LIT73, tmpMeta39, omc_ElementSource_getElementSourceFileInfo(threadData, _inSource));
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationToScalarResidualForm(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _funcTree)
{
  modelica_metatype _outEquations = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquations has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _backendEq = NULL;
      modelica_metatype _ds = NULL;
      modelica_integer _i;
      modelica_integer _branches;
      modelica_metatype _explst = NULL;
      modelica_metatype _explst2 = NULL;
      modelica_metatype _condExps = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqnsfalse = NULL;
      modelica_metatype _eqnstrue = NULL;
      modelica_metatype _subslst = NULL;
      modelica_metatype _attr = NULL;
      modelica_metatype _crlst = NULL;
      modelica_metatype _crlst2 = NULL;
      modelica_metatype _expA = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _exp has no default value.
      // _cond has no default value.
      // _cr has no default value.
      // _source has no default value.
      // _backendEq has no default value.
      // _ds has no default value.
      // _i has no default value.
      // _branches has no default value.
      // _explst has no default value.
      // _explst2 has no default value.
      // _condExps has no default value.
      // _eqns has no default value.
      // _eqnsfalse has no default value.
      // _eqnstrue has no default value.
      // _subslst has no default value.
      // _attr has no default value.
      // _crlst has no default value.
      // _crlst2 has no default value.
      // _expA has no default value.
      tmp4 = 0;
      for (; tmp4 < 15; 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,0,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,19,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _explst = tmpMeta7;
          _e2 = tmpMeta8;
          _source = tmpMeta9;
          _attr = tmpMeta10;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta11 = omc_List_fold3(threadData, _explst, boxvar_BackendEquation_equationTupleToScalarResidualForm, _e2, _source, _attr, _OMC_LIT74);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          _eqns = tmpMeta12;
          tmpMeta1 = _eqns;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_real tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,1,1) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmp15 = mmc_unbox_real(tmpMeta14);
          if (0.0 != tmp15) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _e2 = tmpMeta16;
          _source = tmpMeta17;
          _attr = tmpMeta18;
          /* Pattern matching succeeded */
          _e = omc_ExpressionSimplify_simplify(threadData, _e2, NULL);
          tmpMeta20 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _attr);
          tmpMeta19 = mmc_mk_cons(tmpMeta20, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_real tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,1,1) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          tmp24 = mmc_unbox_real(tmpMeta23);
          if (0.0 != tmp24) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _e1 = tmpMeta21;
          _source = tmpMeta25;
          _attr = tmpMeta26;
          /* Pattern matching succeeded */
          _e = omc_ExpressionSimplify_simplify(threadData, _e1, NULL);
          tmpMeta28 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e, _source, _attr);
          tmpMeta27 = mmc_mk_cons(tmpMeta28, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta27;
          goto tmp3_done;
        }
        case 3: {
          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,0,4) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _e1 = tmpMeta29;
          _e2 = tmpMeta30;
          _source = tmpMeta31;
          _attr = tmpMeta32;
          /* Pattern matching succeeded */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);
          tmpMeta34 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _exp, _source, _attr);
          tmpMeta33 = mmc_mk_cons(tmpMeta34, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          _cr = tmpMeta35;
          _e2 = tmpMeta36;
          _source = tmpMeta37;
          _attr = tmpMeta38;
          /* Pattern matching succeeded */
          _e1 = omc_Expression_crefExp(threadData, _cr);

          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);
          tmpMeta40 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _exp, _source, _attr);
          tmpMeta39 = mmc_mk_cons(tmpMeta40, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta39;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _ds = tmpMeta41;
          _e1 = tmpMeta42;
          _e2 = tmpMeta43;
          _source = tmpMeta44;
          _attr = tmpMeta45;
          /* Pattern matching succeeded */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);

          _subslst = omc_Expression_dimensionSizesSubscripts(threadData, _ds);

          _subslst = omc_Expression_rangesToSubscripts(threadData, _subslst);

          _explst = omc_List_map1r(threadData, _subslst, boxvar_Expression_applyExpSubscripts, _exp);

          _explst = omc_ExpressionSimplify_simplifyList(threadData, _explst);
          tmpMeta1 = omc_List_map2(threadData, _explst, boxvar_BackendEquation_generateRESIDUAL__EQUATION, _source, _attr);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,13,3) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 3));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta46;
          _explst = tmpMeta47;
          _e2 = tmpMeta48;
          _source = tmpMeta49;
          _attr = tmpMeta50;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_Expression_isRecordCall(threadData, _e1, _funcTree) && omc_Expression_isCref(threadData, _e2))) goto tmp3_end;
          _crlst = omc_ComponentReference_expandCref(threadData, omc_Expression_expCref(threadData, _e2), 1 /* true */);

          {
            modelica_metatype __omcQ_24tmpVar3;
            modelica_metatype* tmp52;
            modelica_metatype tmpMeta53;
            modelica_metatype __omcQ_24tmpVar2;
            modelica_integer tmp54;
            modelica_metatype _c_loopVar = 0;
            modelica_metatype _c;
            _c_loopVar = _crlst;
            tmpMeta53 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar3 = tmpMeta53; /* defaultValue */
            tmp52 = &__omcQ_24tmpVar3;
            while(1) {
              tmp54 = 1;
              if (!listEmpty(_c_loopVar)) {
                _c = MMC_CAR(_c_loopVar);
                _c_loopVar = MMC_CDR(_c_loopVar);
                tmp54--;
              }
              if (tmp54 == 0) {
                __omcQ_24tmpVar2 = omc_Expression_crefExp(threadData, _c);
                *tmp52 = mmc_mk_cons(__omcQ_24tmpVar2,0);
                tmp52 = &MMC_CDR(*tmp52);
              } else if (tmp54 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp52 = mmc_mk_nil();
            tmpMeta51 = __omcQ_24tmpVar3;
          }
          _explst2 = tmpMeta51;

          _explst = omc_List_threadMap(threadData, _explst, _explst2, boxvar_Expression_createResidualExp);
          tmpMeta1 = omc_List_map2(threadData, _explst, boxvar_BackendEquation_generateRESIDUAL__EQUATION, _source, _attr);
          goto tmp3_done;
        }
        case 7: {
          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,6,5) == 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta56,13,3) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 3));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e2 = tmpMeta55;
          _e1 = tmpMeta56;
          _explst = tmpMeta57;
          _source = tmpMeta58;
          _attr = tmpMeta59;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_Expression_isRecordCall(threadData, _e1, _funcTree) && omc_Expression_isCref(threadData, _e2))) goto tmp3_end;
          _crlst = omc_ComponentReference_expandCref(threadData, omc_Expression_expCref(threadData, _e2), 1 /* true */);

          {
            modelica_metatype __omcQ_24tmpVar5;
            modelica_metatype* tmp61;
            modelica_metatype tmpMeta62;
            modelica_metatype __omcQ_24tmpVar4;
            modelica_integer tmp63;
            modelica_metatype _c_loopVar = 0;
            modelica_metatype _c;
            _c_loopVar = _crlst;
            tmpMeta62 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar5 = tmpMeta62; /* defaultValue */
            tmp61 = &__omcQ_24tmpVar5;
            while(1) {
              tmp63 = 1;
              if (!listEmpty(_c_loopVar)) {
                _c = MMC_CAR(_c_loopVar);
                _c_loopVar = MMC_CDR(_c_loopVar);
                tmp63--;
              }
              if (tmp63 == 0) {
                __omcQ_24tmpVar4 = omc_Expression_crefExp(threadData, _c);
                *tmp61 = mmc_mk_cons(__omcQ_24tmpVar4,0);
                tmp61 = &MMC_CDR(*tmp61);
              } else if (tmp63 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp61 = mmc_mk_nil();
            tmpMeta60 = __omcQ_24tmpVar5;
          }
          _explst2 = tmpMeta60;

          _explst = omc_List_threadMap(threadData, _explst, _explst2, boxvar_Expression_createResidualExp);
          tmpMeta1 = omc_List_map2(threadData, _explst, boxvar_BackendEquation_generateRESIDUAL__EQUATION, _source, _attr);
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta72;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta64;
          _e2 = tmpMeta65;
          _source = tmpMeta66;
          _attr = tmpMeta67;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_Expression_isCref(threadData, _e1) && omc_Expression_isCref(threadData, _e2))) goto tmp3_end;
          _crlst = omc_ComponentReference_expandCref(threadData, omc_Expression_expCref(threadData, _e1), 1 /* true */);

          _crlst2 = omc_ComponentReference_expandCref(threadData, omc_Expression_expCref(threadData, _e2), 1 /* true */);

          {
            modelica_metatype __omcQ_24tmpVar7;
            modelica_metatype* tmp69;
            modelica_metatype tmpMeta70;
            modelica_metatype __omcQ_24tmpVar6;
            modelica_integer tmp71;
            modelica_metatype _c_loopVar = 0;
            modelica_metatype _c;
            _c_loopVar = _crlst;
            tmpMeta70 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar7 = tmpMeta70; /* defaultValue */
            tmp69 = &__omcQ_24tmpVar7;
            while(1) {
              tmp71 = 1;
              if (!listEmpty(_c_loopVar)) {
                _c = MMC_CAR(_c_loopVar);
                _c_loopVar = MMC_CDR(_c_loopVar);
                tmp71--;
              }
              if (tmp71 == 0) {
                __omcQ_24tmpVar6 = omc_Expression_crefExp(threadData, _c);
                *tmp69 = mmc_mk_cons(__omcQ_24tmpVar6,0);
                tmp69 = &MMC_CDR(*tmp69);
              } else if (tmp71 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp69 = mmc_mk_nil();
            tmpMeta68 = __omcQ_24tmpVar7;
          }
          _explst = tmpMeta68;

          {
            modelica_metatype __omcQ_24tmpVar9;
            modelica_metatype* tmp73;
            modelica_metatype tmpMeta74;
            modelica_metatype __omcQ_24tmpVar8;
            modelica_integer tmp75;
            modelica_metatype _c_loopVar = 0;
            modelica_metatype _c;
            _c_loopVar = _crlst2;
            tmpMeta74 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar9 = tmpMeta74; /* defaultValue */
            tmp73 = &__omcQ_24tmpVar9;
            while(1) {
              tmp75 = 1;
              if (!listEmpty(_c_loopVar)) {
                _c = MMC_CAR(_c_loopVar);
                _c_loopVar = MMC_CDR(_c_loopVar);
                tmp75--;
              }
              if (tmp75 == 0) {
                __omcQ_24tmpVar8 = omc_Expression_crefExp(threadData, _c);
                *tmp73 = mmc_mk_cons(__omcQ_24tmpVar8,0);
                tmp73 = &MMC_CDR(*tmp73);
              } else if (tmp75 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp73 = mmc_mk_nil();
            tmpMeta72 = __omcQ_24tmpVar9;
          }
          _explst2 = tmpMeta72;

          _explst = omc_List_threadMap(threadData, _explst, _explst2, boxvar_Expression_createResidualExp);
          tmpMeta1 = omc_List_map2(threadData, _explst, boxvar_BackendEquation_generateRESIDUAL__EQUATION, _source, _attr);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _e1 = tmpMeta76;
          _e2 = tmpMeta77;
          _source = tmpMeta78;
          _attr = tmpMeta79;
          /* Pattern matching succeeded */
          _exp = omc_Expression_createResidualExp(threadData, _e1, _e2);
          tmpMeta81 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _exp, _source, _attr);
          tmpMeta80 = mmc_mk_cons(tmpMeta81, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta80;
          goto tmp3_done;
        }
        case 10: {
          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;
          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_integer tmp114;
          modelica_integer tmp115;
          modelica_integer tmp116;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          _condExps = tmpMeta82;
          _eqnstrue = tmpMeta83;
          _eqnsfalse = tmpMeta84;
          _source = tmpMeta85;
          _attr = tmpMeta86;
          /* Pattern matching succeeded */
          _branches = listLength(_condExps);

          tmpMeta87 = MMC_REFSTRUCTLIT(mmc_nil);
          _expA = arrayCreate(_branches, tmpMeta87);

          {
            modelica_metatype _eqLst;
            for (tmpMeta88 = _eqnstrue; !listEmpty(tmpMeta88); tmpMeta88=MMC_CDR(tmpMeta88))
            {
              _eqLst = MMC_CAR(tmpMeta88);
              _i = ((modelica_integer) 1);

              {
                modelica_metatype _eq;
                for (tmpMeta89 = _eqLst; !listEmpty(tmpMeta89); tmpMeta89=MMC_CDR(tmpMeta89))
                {
                  _eq = MMC_CAR(tmpMeta89);
                  /* Pattern-matching assignment */
                  tmpMeta90 = omc_BackendEquation_equationToScalarResidualForm(threadData, _eq, _funcTree);
                  if (listEmpty(tmpMeta90)) goto goto_2;
                  tmpMeta91 = MMC_CAR(tmpMeta90);
                  tmpMeta92 = MMC_CDR(tmpMeta90);
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta91,3,3) == 0) goto goto_2;
                  tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta91), 2));
                  if (!listEmpty(tmpMeta92)) goto goto_2;
                  _e1 = tmpMeta93;

                  _expA = omc_Array_consToElement(threadData, _i, _e1, _expA);

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

          _i = ((modelica_integer) 1);

          {
            modelica_metatype _eq;
            for (tmpMeta96 = _eqnsfalse; !listEmpty(tmpMeta96); tmpMeta96=MMC_CDR(tmpMeta96))
            {
              _eq = MMC_CAR(tmpMeta96);
              /* Pattern-matching assignment */
              tmpMeta97 = omc_BackendEquation_equationToScalarResidualForm(threadData, _eq, _funcTree);
              if (listEmpty(tmpMeta97)) goto goto_2;
              tmpMeta98 = MMC_CAR(tmpMeta97);
              tmpMeta99 = MMC_CDR(tmpMeta97);
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta98,3,3) == 0) goto goto_2;
              tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 2));
              if (!listEmpty(tmpMeta99)) goto goto_2;
              _e1 = tmpMeta100;

              _expA = omc_Array_consToElement(threadData, _i, _e1, _expA);

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

          tmpMeta102 = MMC_REFSTRUCTLIT(mmc_nil);
          _eqns = tmpMeta102;

          tmp114 = ((modelica_integer) 1); tmp115 = 1; tmp116 = _branches;
          if(!(((tmp115 > 0) && (tmp114 > tmp116)) || ((tmp115 < 0) && (tmp114 < tmp116))))
          {
            modelica_integer _i;
            for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp114, tmp116); _i += tmp115)
            {
              _explst = arrayGet(_expA, _i);

              /* Pattern-matching assignment */
              tmpMeta103 = _explst;
              if (listEmpty(tmpMeta103)) goto goto_2;
              tmpMeta104 = MMC_CAR(tmpMeta103);
              tmpMeta105 = MMC_CDR(tmpMeta103);
              _e2 = tmpMeta104;
              _explst = tmpMeta105;

              _explst2 = _condExps;

              {
                modelica_metatype _e1;
                for (tmpMeta106 = _explst; !listEmpty(tmpMeta106); tmpMeta106=MMC_CDR(tmpMeta106))
                {
                  _e1 = MMC_CAR(tmpMeta106);
                  /* Pattern-matching assignment */
                  tmpMeta107 = _explst2;
                  if (listEmpty(tmpMeta107)) goto goto_2;
                  tmpMeta108 = MMC_CAR(tmpMeta107);
                  tmpMeta109 = MMC_CDR(tmpMeta107);
                  _cond = tmpMeta108;
                  _explst2 = tmpMeta109;

                  tmpMeta110 = mmc_mk_box4(15, &DAE_Exp_IFEXP__desc, _cond, _e1, _e2);
                  _e2 = tmpMeta110;
                }
              }

              tmpMeta113 = mmc_mk_box4(6, &BackendDAE_Equation_RESIDUAL__EQUATION__desc, _e2, _source, _attr);
              tmpMeta112 = mmc_mk_cons(tmpMeta113, _eqns);
              _eqns = tmpMeta112;
            }
          }
          tmpMeta1 = _eqns;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta117;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta117 = mmc_mk_cons(_backendEq, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta117;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta118;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta118 = mmc_mk_cons(_backendEq, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta118;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta119;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          _backendEq = tmp4_1;
          /* Pattern matching succeeded */
          tmpMeta119 = mmc_mk_cons(_backendEq, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta119;
          goto tmp3_done;
        }
        case 14: {
          modelica_boolean tmp120;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp120 = omc_Flags_isSet(threadData, _OMC_LIT48);
          if (1 /* true */ != tmp120) goto goto_2;

          omc_BackendDump_printEquation(threadData, _inEquation);

          omc_Debug_trace(threadData, _OMC_LIT75);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outEquations = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEquations;
}

DLLDirection
modelica_metatype omc_BackendEquation_removeRemovedEqs(threadData_t *threadData, modelica_metatype __omcQ_24in_5FeqSystem)
{
  modelica_metatype _eqSystem = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqSystem = __omcQ_24in_5FeqSystem;
  omc_ExpandableArray_clear(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqSystem), 10))));
  _return: OMC_LABEL_UNUSED
  return _eqSystem;
}

DLLDirection
modelica_metatype omc_BackendEquation_requationsAddDAE(threadData_t *threadData, modelica_metatype _inEquations, modelica_metatype _inSyst)
{
  modelica_metatype _outSyst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSyst has no default value.
  _outSyst = (listEmpty(_inEquations)?_inSyst:omc_BackendDAEUtil_setEqSystRemovedEqns(threadData, _inSyst, omc_BackendEquation_addList(threadData, _inEquations, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inSyst), 10))))));
  _return: OMC_LABEL_UNUSED
  return _outSyst;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationsAddDAE(threadData_t *threadData, modelica_metatype _inEquations, modelica_metatype _inEqSystem)
{
  modelica_metatype _outEqSystem = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEqSystem = _inEqSystem;
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(11));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_outEqSystem), 11*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[3] = omc_BackendEquation_addList(threadData, _inEquations, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_outEqSystem), 3))));
  _outEqSystem = tmpMeta1;

  tmpMeta2 = MMC_TAGPTR(mmc_alloc_words(11));
  memcpy(MMC_UNTAGPTR(tmpMeta2), MMC_UNTAGPTR(_outEqSystem), 11*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta2))[7] = _OMC_LIT76;
  _outEqSystem = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outEqSystem;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationAddDAE(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inEqSystem)
{
  modelica_metatype _outEqSystem = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqSystem has no default value.
  _outEqSystem = omc_BackendDAEUtil_setEqSystEqs(threadData, _inEqSystem, omc_BackendEquation_add(threadData, _inEquation, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inEqSystem), 3)))));

  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(11));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_outEqSystem), 11*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[7] = _OMC_LIT76;
  _outEqSystem = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outEqSystem;
}

DLLDirection
modelica_boolean omc_BackendEquation_equationEqual(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2)
{
  modelica_boolean _res;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _res = 1 /* true */;
  if(referenceEq(_e1, _e2))
  {
    goto _return;
  }

  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _e1;
    tmp4_2 = _e2;
    {
      modelica_metatype _e11 = NULL;
      modelica_metatype _e12 = NULL;
      modelica_metatype _e21 = NULL;
      modelica_metatype _e22 = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _alg1 = NULL;
      modelica_metatype _alg2 = NULL;
      modelica_metatype _explst1 = NULL;
      modelica_metatype _explst2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e11 has no default value.
      // _e12 has no default value.
      // _e21 has no default value.
      // _e22 has no default value.
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _alg1 has no default value.
      // _alg2 has no default value.
      // _explst1 has no default value.
      // _explst2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 8; 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,0,4) == 0) goto tmp3_end;
          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(tmp4_2,0,4) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _e11 = tmpMeta6;
          _e12 = tmpMeta7;
          _e21 = tmpMeta8;
          _e22 = tmpMeta9;
          /* Pattern matching succeeded */
          tmp1 = (omc_Expression_expEqual(threadData, _e11, _e21) && omc_Expression_expEqual(threadData, _e12, _e22));
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,6) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          
          _e11 = tmpMeta10;
          _e12 = tmpMeta11;
          _e21 = tmpMeta12;
          _e22 = tmpMeta13;
          /* Pattern matching succeeded */
          tmp1 = (omc_Expression_expEqual(threadData, _e11, _e21) && omc_Expression_expEqual(threadData, _e12, _e22));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,5) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          
          _e11 = tmpMeta14;
          _e12 = tmpMeta15;
          _e21 = tmpMeta16;
          _e22 = tmpMeta17;
          /* Pattern matching succeeded */
          tmp1 = (omc_Expression_expEqual(threadData, _e11, _e21) && omc_Expression_expEqual(threadData, _e12, _e22));
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,2,4) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _cr1 = tmpMeta18;
          _exp1 = tmpMeta19;
          _cr2 = tmpMeta20;
          _exp2 = tmpMeta21;
          /* Pattern matching succeeded */
          tmp1 = (omc_ComponentReference_crefEqualNoStringCompare(threadData, _cr1, _cr2) && omc_Expression_expEqual(threadData, _exp1, _exp2));
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,3,3) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _exp1 = tmpMeta22;
          _exp2 = tmpMeta23;
          /* Pattern matching succeeded */
          tmp1 = omc_Expression_expEqual(threadData, _exp1, _exp2);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,4,5) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _alg1 = tmpMeta24;
          _alg2 = tmpMeta25;
          /* Pattern matching succeeded */
          _explst1 = omc_Algorithm_getAllExps(threadData, _alg1);

          _explst2 = omc_Algorithm_getAllExps(threadData, _alg2);
          tmp1 = omc_List_isEqualOnTrue(threadData, _explst1, _explst2, boxvar_Expression_expEqual);
          goto tmp3_done;
        }
        case 6: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 3));
          if (listEmpty(tmpMeta27)) goto tmp3_end;
          tmpMeta28 = MMC_CAR(tmpMeta27);
          tmpMeta29 = MMC_CDR(tmpMeta27);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta28,0,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 3));
          if (!listEmpty(tmpMeta29)) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,5,4) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 3));
          if (listEmpty(tmpMeta33)) goto tmp3_end;
          tmpMeta34 = MMC_CAR(tmpMeta33);
          tmpMeta35 = MMC_CDR(tmpMeta33);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,0,3) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 2));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 3));
          if (!listEmpty(tmpMeta35)) goto tmp3_end;
          
          _e11 = tmpMeta30;
          _e12 = tmpMeta31;
          _e21 = tmpMeta36;
          _e22 = tmpMeta37;
          /* Pattern matching succeeded */
          tmp1 = (omc_Expression_expEqual(threadData, _e11, _e21) && omc_Expression_expEqual(threadData, _e12, _e22));
          goto tmp3_done;
        }
        case 7: {
          
          /* 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:;
    }
  }
  _res = tmp1;
  _return: OMC_LABEL_UNUSED
  return _res;
}
modelica_metatype boxptr_BackendEquation_equationEqual(threadData_t *threadData, modelica_metatype _e1, modelica_metatype _e2)
{
  modelica_boolean _res;
  modelica_metatype out_res;
  _res = omc_BackendEquation_equationEqual(threadData, _e1, _e2);
  out_res = mmc_mk_icon(_res);
  return out_res;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfExpList__WithStop(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outBoolean = 1 /* true */;
  _outTypeA = _inExtArg;
  {
    modelica_metatype _e;
    for (tmpMeta1 = _inExpl; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _e = MMC_CAR(tmpMeta1);
      /* Pattern-matching tuple assignment, wild first pattern */
      (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 2))), _e, _outTypeA, &tmpMeta2, &tmpMeta4) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 1)))) (threadData, _e, _outTypeA, &tmpMeta2, &tmpMeta4);
      tmp3 = mmc_unbox_integer(tmpMeta2);
      _outBoolean = tmp3  /* pattern as ty=Boolean */;
      _outTypeA = tmpMeta4;

      if((!_outBoolean))
      {
        break;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfExpList__WithStop(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_BackendEquation_traverseExpsOfExpList__WithStop(threadData, _inExpl, _rel, _inExtArg, out_outTypeA);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  /* skip box _outTypeA; polymorphic<T> */
  return out_outBoolean;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfExpList(threadData_t *threadData, modelica_metatype _inExpl, modelica_fnptr _rel, modelica_metatype _inExtArg, modelica_metatype *out_outTypeA)
{
  modelica_metatype _outExpl = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outExpl = tmpMeta1;
  _outTypeA = _inExtArg;
  {
    modelica_metatype _e;
    for (tmpMeta2 = _inExpl; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _e = MMC_CAR(tmpMeta2);
      _e = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 2))), _e, _outTypeA ,&_outTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_rel), 1)))) (threadData, _e, _outTypeA ,&_outTypeA);

      tmpMeta3 = mmc_mk_cons(_e, _outExpl);
      _outExpl = tmpMeta3;
    }
  }

  _outExpl = listReverseInPlace(_outExpl);
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outExpl;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_boolean _inCont, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outCont;
  modelica_metatype _outTypeA = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outCont has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenOps;
    {
      modelica_metatype _tp = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _extArg = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _tp has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _cr has no default value.
      // _rest has no default value.
      // _extArg has no default value.
      _b = 0 /* false */;
      tmp4 = 0;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1_c0 = _inCont;
          tmpMeta[0+1] = _inTypeA;
          goto tmp3_done;
        }
        case 1: {
          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_integer tmp14;
          modelica_metatype tmpMeta15;
          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), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          
          _e1 = tmpMeta8;
          _e2 = tmpMeta9;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          omc_Expression_typeof(threadData, _e2);

          if(_inCont)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta10, &tmpMeta12) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta10, &tmpMeta12);
            tmp11 = mmc_unbox_integer(tmpMeta10);
            _b = tmp11  /* pattern as ty=Boolean */;
            _extArg = tmpMeta12;
          }

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg, &tmpMeta13, &tmpMeta15) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg, &tmpMeta13, &tmpMeta15);
            tmp14 = mmc_unbox_integer(tmpMeta13);
            _b = tmp14  /* pattern as ty=Boolean */;
            _extArg = tmpMeta15;
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inCont = _b;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          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_integer tmp24;
          modelica_metatype tmpMeta25;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta16 = MMC_CAR(tmp4_1);
          tmpMeta17 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,1,3) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
          
          _cr = tmpMeta18;
          _e2 = tmpMeta19;
          _rest = tmpMeta17;
          /* Pattern matching succeeded */
          _tp = omc_Expression_typeof(threadData, _e2);

          _e1 = omc_Expression_makeCrefExp(threadData, _cr, _tp);

          if(_inCont)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta20, &tmpMeta22) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta20, &tmpMeta22);
            tmp21 = mmc_unbox_integer(tmpMeta20);
            _b = tmp21  /* pattern as ty=Boolean */;
            _extArg = tmpMeta22;
          }

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg, &tmpMeta23, &tmpMeta25) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg, &tmpMeta23, &tmpMeta25);
            tmp24 = mmc_unbox_integer(tmpMeta23);
            _b = tmp24  /* pattern as ty=Boolean */;
            _extArg = tmpMeta25;
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inCont = _b;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_integer tmp34;
          modelica_metatype tmpMeta35;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta26 = MMC_CAR(tmp4_1);
          tmpMeta27 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,2,4) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 3));
          
          _e1 = tmpMeta28;
          _e2 = tmpMeta29;
          _rest = tmpMeta27;
          /* Pattern matching succeeded */
          if(_inCont)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta30, &tmpMeta32) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta30, &tmpMeta32);
            tmp31 = mmc_unbox_integer(tmpMeta30);
            _b = tmp31  /* pattern as ty=Boolean */;
            _extArg = tmpMeta32;
          }

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg, &tmpMeta33, &tmpMeta35) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg, &tmpMeta33, &tmpMeta35);
            tmp34 = mmc_unbox_integer(tmpMeta33);
            _b = tmp34  /* pattern as ty=Boolean */;
            _extArg = tmpMeta35;
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inCont = _b;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_integer tmp40;
          modelica_metatype tmpMeta41;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta36 = MMC_CAR(tmp4_1);
          tmpMeta37 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta36,3,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 2));
          
          _e1 = tmpMeta38;
          _rest = tmpMeta37;
          /* Pattern matching succeeded */
          if(_inCont)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta39, &tmpMeta41) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta39, &tmpMeta41);
            tmp40 = mmc_unbox_integer(tmpMeta39);
            _b = tmp40  /* pattern as ty=Boolean */;
            _extArg = tmpMeta41;
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inCont = _b;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_integer tmp46;
          modelica_metatype tmpMeta47;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta42 = MMC_CAR(tmp4_1);
          tmpMeta43 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta42,4,2) == 0) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          
          _e1 = tmpMeta44;
          _rest = tmpMeta43;
          /* Pattern matching succeeded */
          if(_inCont)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta45, &tmpMeta47) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta45, &tmpMeta47);
            tmp46 = mmc_unbox_integer(tmpMeta45);
            _b = tmp46  /* pattern as ty=Boolean */;
            _extArg = tmpMeta47;
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inCont = _b;
          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:;
    }
  }
  _outCont = tmp1_c0;
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outCont;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype _inCont, modelica_metatype *out_outTypeA)
{
  modelica_integer tmp1;
  modelica_boolean _outCont;
  modelica_metatype out_outCont;
  tmp1 = mmc_unbox_integer(_inCont);
  _outCont = omc_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData, _inWhenOps, _inFunc, _inTypeA, tmp1, out_outTypeA);
  out_outCont = mmc_mk_icon(_outCont);
  /* skip box _outTypeA; polymorphic<T> */
  return out_outCont;
}

DLLDirection
modelica_metatype omc_BackendEquation_statementEq(threadData_t *threadData, modelica_metatype _iStmts)
{
  modelica_metatype _oEq = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEq has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iStmts;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _explst = NULL;
      int tmp4;
      // _cr has no default value.
      // _exp has no default value.
      // _explst has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 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));
          
          _cr = tmpMeta6;
          _exp = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendEquation_generateEquation(threadData, omc_Expression_crefExp(threadData, _cr), _exp, _OMC_LIT16, _OMC_LIT36);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,6,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _cr = tmpMeta9;
          _exp = tmpMeta10;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendEquation_generateEquation(threadData, omc_Expression_crefExp(threadData, _cr), _exp, _OMC_LIT16, _OMC_LIT36);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _explst = tmpMeta11;
          _exp = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendEquation_generateEquation(threadData, omc_Expression_makeTuple(threadData, _explst), _exp, _OMC_LIT16, _OMC_LIT36);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oEq = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oEq;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outCont;
  modelica_metatype _outTypeA = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outCont has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenEquation;
    {
      modelica_metatype _elsewe = NULL;
      modelica_metatype _oelsewe = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _extArg = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _elsewe has no default value.
      // _oelsewe has no default value.
      // _cond has no default value.
      // _whenStmtLst has no default value.
      // _extArg has no default value.
      // _b 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_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          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;
          _oelsewe = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _cond, _inTypeA, &tmpMeta9, &tmpMeta11) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _cond, _inTypeA, &tmpMeta9, &tmpMeta11);
          tmp10 = mmc_unbox_integer(tmpMeta9);
          _b = tmp10  /* pattern as ty=Boolean */;
          _extArg = tmpMeta11;

          if(_b)
          {
            _b = omc_BackendEquation_traverseExpsOfWhenOps__WithStop(threadData, _whenStmtLst, ((modelica_fnptr) _inFunc), _extArg, _b ,&_extArg);
          }

          if(_b)
          {
            if(isSome(_oelsewe))
            {
              /* Pattern-matching assignment */
              tmpMeta12 = _oelsewe;
              if (optionNone(tmpMeta12)) goto goto_2;
              tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
              _elsewe = tmpMeta13;

              _b = omc_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData, _elsewe, ((modelica_fnptr) _inFunc), _extArg ,&_extArg);
            }
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outCont = tmp1_c0;
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outCont;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outCont;
  modelica_metatype out_outCont;
  _outCont = omc_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData, _inWhenEquation, _inFunc, _inTypeA, out_outTypeA);
  out_outCont = mmc_mk_icon(_outCont);
  /* skip box _outTypeA; polymorphic<T> */
  return out_outCont;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfWhenOps(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype _inAccum, modelica_metatype *out_outTypeA)
{
  modelica_metatype _outWhenOps = NULL;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outWhenOps has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenOps;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _level = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _extArg = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e1 has no default value.
      // _e2 has no default value.
      // _level has no default value.
      // _cr has no default value.
      // _cr1 has no default value.
      // _rest has no default value.
      // _extArg has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 6; 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] = _inTypeA;
          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,0,3) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          _e1 = tmpMeta8;
          _e2 = tmpMeta9;
          _source = tmpMeta10;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          omc_Expression_typeof(threadData, _e2);

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA ,&_extArg);

          _e2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg ,&_extArg);
          tmpMeta12 = mmc_mk_box4(3, &BackendDAE_WhenOperator_ASSIGN__desc, _e1, _e2, _source);
          tmpMeta11 = mmc_mk_cons(tmpMeta12, _inAccum);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inAccum = tmpMeta11;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_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;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmp4_1);
          tmpMeta14 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,1,3) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 3));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 4));
          _cr = tmpMeta15;
          _e2 = tmpMeta16;
          _source = tmpMeta17;
          _rest = tmpMeta14;
          /* Pattern matching succeeded */
          _e1 = omc_Expression_crefExp(threadData, _cr);

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA ,&_extArg);

          if(omc_Expression_isCref(threadData, _e1))
          {
            /* Pattern-matching assignment */
            tmpMeta18 = _e1;
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,6,2) == 0) goto goto_2;
            tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
            _cr1 = tmpMeta19;
          }
          else
          {
            _cr1 = _cr;
          }

          _e2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg ,&_extArg);
          tmpMeta21 = mmc_mk_box4(4, &BackendDAE_WhenOperator_REINIT__desc, _cr1, _e2, _source);
          tmpMeta20 = mmc_mk_cons(tmpMeta21, _inAccum);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inAccum = tmpMeta20;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          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 (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta22 = MMC_CAR(tmp4_1);
          tmpMeta23 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,2,4) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 3));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 4));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 5));
          _e1 = tmpMeta24;
          _e2 = tmpMeta25;
          _level = tmpMeta26;
          _source = tmpMeta27;
          _rest = tmpMeta23;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA ,&_extArg);

          _e2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e2, _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e2, _extArg ,&_extArg);
          tmpMeta29 = mmc_mk_box5(5, &BackendDAE_WhenOperator_ASSERT__desc, _e1, _e2, _level, _source);
          tmpMeta28 = mmc_mk_cons(tmpMeta29, _inAccum);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inAccum = tmpMeta28;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta30 = MMC_CAR(tmp4_1);
          tmpMeta31 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,3,2) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 3));
          _e1 = tmpMeta32;
          _source = tmpMeta33;
          _rest = tmpMeta31;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA ,&_extArg);
          tmpMeta35 = mmc_mk_box3(6, &BackendDAE_WhenOperator_TERMINATE__desc, _e1, _source);
          tmpMeta34 = mmc_mk_cons(tmpMeta35, _inAccum);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inAccum = tmpMeta34;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          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,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 2));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 3));
          _e1 = tmpMeta38;
          _source = tmpMeta39;
          _rest = tmpMeta37;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA ,&_extArg);
          tmpMeta41 = mmc_mk_box3(7, &BackendDAE_WhenOperator_NORETCALL__desc, _e1, _source);
          tmpMeta40 = mmc_mk_cons(tmpMeta41, _inAccum);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _inTypeA = _extArg;
          _inAccum = tmpMeta40;
          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:;
    }
  }
  _outWhenOps = tmpMeta[0+0];
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outWhenOps;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traverseExpsOfWhenEquation(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_metatype _outWhenEquation = NULL;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outWhenEquation has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenEquation;
    {
      modelica_metatype _elsewe = NULL;
      modelica_metatype _oelsewe = NULL;
      modelica_metatype _cond = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _extArg = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _elsewe has no default value.
      // _oelsewe has no default value.
      // _cond has no default value.
      // _whenStmtLst has no default value.
      // _extArg 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;
          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;
          _oelsewe = tmpMeta8;
          /* Pattern matching succeeded */
          _cond = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _cond, _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _cond, _inTypeA ,&_extArg);

          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          _whenStmtLst = omc_BackendEquation_traverseExpsOfWhenOps(threadData, _whenStmtLst, ((modelica_fnptr) _inFunc), _extArg, tmpMeta9 ,&_extArg);

          if(isSome(_oelsewe))
          {
            /* Pattern-matching assignment */
            tmpMeta10 = _oelsewe;
            if (optionNone(tmpMeta10)) goto goto_2;
            tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
            _elsewe = tmpMeta11;

            _elsewe = omc_BackendEquation_traverseExpsOfWhenEquation(threadData, _elsewe, ((modelica_fnptr) _inFunc), _extArg ,&_extArg);

            _oelsewe = mmc_mk_some(_elsewe);
          }
          else
          {
            _oelsewe = mmc_mk_none();
          }
          tmpMeta12 = mmc_mk_box4(3, &BackendDAE_WhenEquation_WHEN__STMTS__desc, _cond, _whenStmtLst, _oelsewe);
          tmpMeta[0+0] = tmpMeta12;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outWhenEquation = tmpMeta[0+0];
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outWhenEquation;
}

DLLDirection
modelica_boolean omc_BackendEquation_traverseExpsOfEquation__WithStop(threadData_t *threadData, modelica_metatype _inEquation, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype _outTypeA = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outBoolean has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _tp = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _we = NULL;
      modelica_metatype _ext_arg = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_boolean _b;
      int tmp4;
      // _e1 has no default value.
      // _e2 has no default value.
      // _expl has no default value.
      // _tp has no default value.
      // _cr has no default value.
      // _we has no default value.
      // _ext_arg has no default value.
      // _eqns has no default value.
      // _eqnslst has no default value.
      // _b has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,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));
          
          _e1 = tmpMeta5;
          _e2 = tmpMeta6;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e1, _inTypeA, &tmpMeta7, &tmpMeta9) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e1, _inTypeA, &tmpMeta7, &tmpMeta9);
          tmp8 = mmc_unbox_integer(tmpMeta7);
          _b = tmp8  /* pattern as ty=Boolean */;
          _ext_arg = tmpMeta9;

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e2, _ext_arg, &tmpMeta10, &tmpMeta12) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e2, _ext_arg, &tmpMeta10, &tmpMeta12);
            tmp11 = mmc_unbox_integer(tmpMeta10);
            _b = tmp11  /* pattern as ty=Boolean */;
            _ext_arg = tmpMeta12;
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          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), 3));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta13;
          _e2 = tmpMeta14;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e1, _inTypeA, &tmpMeta15, &tmpMeta17) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e1, _inTypeA, &tmpMeta15, &tmpMeta17);
          tmp16 = mmc_unbox_integer(tmpMeta15);
          _b = tmp16  /* pattern as ty=Boolean */;
          _ext_arg = tmpMeta17;

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e2, _ext_arg, &tmpMeta18, &tmpMeta20) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e2, _ext_arg, &tmpMeta18, &tmpMeta20);
            tmp19 = mmc_unbox_integer(tmpMeta18);
            _b = tmp19  /* pattern as ty=Boolean */;
            _ext_arg = tmpMeta20;
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cr = tmpMeta21;
          _e2 = tmpMeta22;
          /* Pattern matching succeeded */
          _tp = omc_Expression_typeof(threadData, _e2);

          _e1 = omc_Expression_makeCrefExp(threadData, _cr, _tp);

          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e1, _inTypeA, &tmpMeta23, &tmpMeta25) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e1, _inTypeA, &tmpMeta23, &tmpMeta25);
          tmp24 = mmc_unbox_integer(tmpMeta23);
          _b = tmp24  /* pattern as ty=Boolean */;
          _ext_arg = tmpMeta25;

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e2, _ext_arg, &tmpMeta26, &tmpMeta28) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e2, _ext_arg, &tmpMeta26, &tmpMeta28);
            tmp27 = mmc_unbox_integer(tmpMeta26);
            _b = tmp27  /* pattern as ty=Boolean */;
            _ext_arg = tmpMeta28;
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _e1 = tmpMeta29;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e1, _inTypeA, &tmpMeta30, &tmpMeta32) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e1, _inTypeA, &tmpMeta30, &tmpMeta32);
          tmp31 = mmc_unbox_integer(tmpMeta30);
          _b = tmp31  /* pattern as ty=Boolean */;
          _ext_arg = tmpMeta32;
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _we = tmpMeta33;
          /* Pattern matching succeeded */
          tmp1_c0 = omc_BackendEquation_traverseExpsOfWhenEquation__WithStop(threadData, _we, ((modelica_fnptr) _func), _inTypeA, &tmpMeta[0+1]);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta34;
          modelica_boolean tmp35;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp35 = omc_Flags_isSet(threadData, _OMC_LIT48);
          if (1 /* true */ != tmp35) goto goto_2;

          omc_Debug_traceln(threadData, _OMC_LIT77);
          goto goto_2;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_integer tmp42;
          modelica_metatype tmpMeta43;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta36;
          _e2 = tmpMeta37;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e1, _inTypeA, &tmpMeta38, &tmpMeta40) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e1, _inTypeA, &tmpMeta38, &tmpMeta40);
          tmp39 = mmc_unbox_integer(tmpMeta38);
          _b = tmp39  /* pattern as ty=Boolean */;
          _ext_arg = tmpMeta40;

          if(_b)
          {
            /* Pattern-matching tuple assignment, wild first pattern */
            (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, 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))), _e2, _ext_arg, &tmpMeta41, &tmpMeta43) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _e2, _ext_arg, &tmpMeta41, &tmpMeta43);
            tmp42 = mmc_unbox_integer(tmpMeta41);
            _b = tmp42  /* pattern as ty=Boolean */;
            _ext_arg = tmpMeta43;
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          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), 4));
          
          _expl = tmpMeta44;
          _eqnslst = tmpMeta45;
          _eqns = tmpMeta46;
          /* Pattern matching succeeded */
          _b = omc_BackendEquation_traverseExpsOfExpList__WithStop(threadData, _expl, ((modelica_fnptr) _func), _inTypeA ,&_ext_arg);

          if(_b)
          {
            _b = omc_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData, _eqnslst, ((modelica_fnptr) _func), _ext_arg ,&_ext_arg);
          }

          if(_b)
          {
            _b = omc_BackendEquation_traverseExpsOfEquationList__WithStop(threadData, _eqns, ((modelica_fnptr) _func), _ext_arg ,&_ext_arg);
          }
          tmp1_c0 = _b;
          tmpMeta[0+1] = _ext_arg;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outBoolean = tmp1_c0;
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outBoolean;
}
modelica_metatype boxptr_BackendEquation_traverseExpsOfEquation__WithStop(threadData_t *threadData, modelica_metatype _inEquation, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_BackendEquation_traverseExpsOfEquation__WithStop(threadData, _inEquation, _func, _inTypeA, out_outTypeA);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  /* skip box _outTypeA; polymorphic<T> */
  return out_outBoolean;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseExpsOfEquation(threadData_t *threadData, modelica_metatype _inEquation, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_metatype _outEquation = NULL;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquation has no default value.
  // _outTypeA has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_metatype _eqn = NULL;
      modelica_metatype _eqn1 = NULL;
      modelica_metatype _whenEquation = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _extArg = NULL;
      modelica_metatype _stmts = NULL;
      modelica_metatype _conditions = NULL;
      modelica_metatype _eqnstrue = NULL;
      modelica_metatype _eqnsfalse = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eqn has no default value.
      // _eqn1 has no default value.
      // _whenEquation has no default value.
      // _e1 has no default value.
      // _cr has no default value.
      // _cr1 has no default value.
      // _extArg has no default value.
      // _stmts has no default value.
      // _conditions has no default value.
      // _eqnstrue has no default value.
      // _eqnsfalse has no default value.
      tmp4 = 0;
      for (; tmp4 < 9; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 2))), _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 2))), _inTypeA ,&_extArg);

          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = _e1;
          _eqn = tmpMeta6;

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _extArg ,&_extArg);

          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[3] = _e1;
          _eqn = tmpMeta7;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _inTypeA ,&_extArg);

          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[3] = _e1;
          _eqn = tmpMeta8;

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _extArg ,&_extArg);

          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[4] = _e1;
          _eqn = tmpMeta9;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _eqn = tmp4_1;
          _cr = tmpMeta10;
          /* Pattern matching succeeded */
          _e1 = omc_Expression_makeCrefExp(threadData, _cr, omc_Expression_typeof(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3)))));

          /* Pattern-matching tuple assignment */
          tmpMeta12 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _e1, _inTypeA, &tmpMeta11) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _e1, _inTypeA, &tmpMeta11);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto goto_2;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          _cr1 = tmpMeta13;
          _extArg = tmpMeta11;

          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[2] = _cr1;
          _eqn = tmpMeta14;

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _extArg ,&_extArg);

          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[3] = _e1;
          _eqn = tmpMeta15;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 2))), _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 2))), _inTypeA ,&_extArg);

          tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_eqn), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[2] = _e1;
          _eqn = tmpMeta16;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,4) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _whenEquation = omc_BackendEquation_traverseExpsOfWhenEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), ((modelica_fnptr) _inFunc), _inTypeA ,&_extArg);

          tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[3] = _whenEquation;
          _eqn = tmpMeta17;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          
          _eqn = tmp4_1;
          _stmts = tmpMeta19;
          /* Pattern matching succeeded */
          _stmts = omc_DAEUtil_traverseDAEEquationsStmts(threadData, _stmts, ((modelica_fnptr) _inFunc), _inTypeA ,&_extArg);

          tmpMeta21 = mmc_mk_box2(3, &DAE_Algorithm_ALGORITHM__STMTS__desc, _stmts);
          tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[3] = tmpMeta21;
          _eqn = tmpMeta20;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _inTypeA ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), _inTypeA ,&_extArg);

          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[3] = _e1;
          _eqn = tmpMeta22;

          _e1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _extArg ,&_extArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), _extArg ,&_extArg);

          tmpMeta23 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta23), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta23))[4] = _e1;
          _eqn = tmpMeta23;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,5) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _conditions = omc_BackendEquation_traverseExpsOfExpList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 2))), ((modelica_fnptr) _inFunc), _inTypeA ,&_extArg);

          tmpMeta24 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta24), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta24))[2] = _conditions;
          _eqn = tmpMeta24;

          _eqnstrue = omc_List_map1Fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), boxvar_BackendEquation_traverseExpsOfEquationList, ((modelica_fnptr) _inFunc), _extArg ,&_extArg);

          tmpMeta25 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta25), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta25))[3] = _eqnstrue;
          _eqn = tmpMeta25;

          _eqnsfalse = omc_List_map1Fold(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 4))), boxvar_BackendEquation_traverseExpsOfEquation, ((modelica_fnptr) _inFunc), _extArg ,&_extArg);

          tmpMeta26 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta26), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta26))[4] = _eqnsfalse;
          _eqn = tmpMeta26;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          
          _eqn = tmp4_1;
          /* Pattern matching succeeded */
          _eqn1 = omc_BackendEquation_traverseExpsOfEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 5))), ((modelica_fnptr) _inFunc), _inTypeA ,&_extArg);

          tmpMeta27 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta27), MMC_UNTAGPTR(_eqn), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta27))[5] = _eqn1;
          _eqn = tmpMeta27;
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _extArg;
          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];
  _outTypeA = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outEquation;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outBoolean = 1 /* true */;
  _outTypeA = _inTypeA;
  {
    modelica_metatype _eqn;
    for (tmpMeta1 = _inEquations; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqn = MMC_CAR(tmpMeta1);
      _outBoolean = omc_BackendEquation_traverseExpsOfEquationList__WithStop(threadData, _eqn, ((modelica_fnptr) _func), _outTypeA ,&_outTypeA);

      if((!_outBoolean))
      {
        break;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outBoolean;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _func, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_BackendEquation_traverseExpsOfEquationListList__WithStop(threadData, _inEquations, _func, _inTypeA, out_outTypeA);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  /* skip box _outTypeA; polymorphic<T> */
  return out_outBoolean;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseExpsOfEquationList__WithoutChange(threadData_t *threadData, modelica_metatype _inEquation, modelica_fnptr _func, modelica_metatype _inArg)
{
  modelica_metatype _outArg = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outArg = _inArg;
  omc_BackendEquation_traverseExpsOfEquation(threadData, _inEquation, ((modelica_fnptr) _func), _outArg ,&_outArg);
  _return: OMC_LABEL_UNUSED
  return _outArg;
}

DLLDirection
modelica_boolean omc_BackendEquation_traverseExpsOfEquationList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outBoolean = 1 /* true */;
  _outTypeA = _inTypeA;
  {
    modelica_metatype _eqn;
    for (tmpMeta1 = _inEquations; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eqn = MMC_CAR(tmpMeta1);
      _outBoolean = omc_BackendEquation_traverseExpsOfEquation__WithStop(threadData, _eqn, ((modelica_fnptr) _inFunc), _outTypeA ,&_outTypeA);

      if((!_outBoolean))
      {
        break;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outTypeA) { *out_outTypeA = _outTypeA; }
  return _outBoolean;
}
modelica_metatype boxptr_BackendEquation_traverseExpsOfEquationList__WithStop(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _inFunc, modelica_metatype _inTypeA, modelica_metatype *out_outTypeA)
{
  modelica_boolean _outBoolean;
  modelica_metatype out_outBoolean;
  _outBoolean = omc_BackendEquation_traverseExpsOfEquationList__WithStop(threadData, _inEquations, _inFunc, _inTypeA, out_outTypeA);
  out_outBoolean = mmc_mk_icon(_outBoolean);
  /* skip box _outTypeA; polymorphic<Type_a> */
  return out_outBoolean;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseExpsOfEquationList(threadData_t *threadData, modelica_metatype _inEquations, modelica_fnptr _func, modelica_metatype _inArg, modelica_metatype *out_outArg)
{
  modelica_metatype _outEquations = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _outArg = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEquations = tmpMeta1;
  _outArg = _inArg;
  {
    modelica_metatype _eq;
    for (tmpMeta2 = _inEquations; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _eq = MMC_CAR(tmpMeta2);
      _eq = omc_BackendEquation_traverseExpsOfEquation(threadData, _eq, ((modelica_fnptr) _func), _outArg ,&_outArg);

      tmpMeta3 = mmc_mk_cons(_eq, _outEquations);
      _outEquations = tmpMeta3;
    }
  }

  _outEquations = listReverseInPlace(_outEquations);
  _return: OMC_LABEL_UNUSED
  if (out_outArg) { *out_outArg = _outArg; }
  return _outEquations;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_checkEquationsUnknownCrefsExp(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_metatype *out_outTuple)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outTuple = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outTuple has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inExp;
    tmp4_2 = _inTuple;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _knvars = NULL;
      modelica_metatype _ht = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _expl = NULL;
      modelica_metatype _varLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _e1 has no default value.
      // _vars has no default value.
      // _knvars has no default value.
      // _ht has no default value.
      // _cr has no default value.
      // _expl has no default value.
      // _varLst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 9; 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_LIT25), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          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,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));
          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;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          
          _e = tmp4_1;
          _cr = tmpMeta8;
          _varLst = tmpMeta11;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _expl = omc_List_map1(threadData, _varLst, boxvar_Expression_generateCrefsExpFromExpVar, _cr);

          omc_Expression_traverseExpList(threadData, _expl, boxvar_BackendEquation_checkEquationsUnknownCrefsExp, _inTuple ,&_outTuple);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _outTuple;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_boolean tmp13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto tmp3_end;
          
          _e = tmp4_1;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta14 = omc_Expression_extendArrExp(threadData, _e, 0 /* false */, &tmp13);
          _e1 = tmpMeta14;
          if (1 /* true */ != tmp13) goto goto_2;

          omc_Expression_traverseExpBottomUp(threadData, _e1, boxvar_BackendEquation_checkEquationsUnknownCrefsExp, _inTuple ,&_outTuple);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _outTuple;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,13,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta16;
          _ht = tmpMeta17;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_BaseHashTable_hasKey(threadData, _cr, _ht)) goto tmp3_end;
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          
          _cr = tmpMeta18;
          _vars = tmpMeta19;
          /* Pattern matching succeeded */
          omc_BackendVariable_getVar(threadData, _cr, _vars, NULL);
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _cr = tmpMeta20;
          _knvars = tmpMeta21;
          /* Pattern matching succeeded */
          omc_BackendVariable_getVar(threadData, _cr, _knvars, NULL);
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta22;
          _vars = tmpMeta23;
          _knvars = tmpMeta24;
          _ht = tmpMeta25;
          /* Pattern matching succeeded */
          tmpMeta26 = mmc_mk_box2(0, _cr, mmc_mk_integer(((modelica_integer) 0)));
          _ht = omc_BaseHashTable_add(threadData, tmpMeta26, _ht);
          tmpMeta27 = mmc_mk_box3(0, _vars, _knvars, _ht);
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = tmpMeta27;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmpMeta[0+1] = _inTuple;
          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 < 9) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outExp = tmpMeta[0+0];
  _outTuple = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTuple) { *out_outTuple = _outTuple; }
  return _outExp;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationUnknownCrefs(threadData_t *threadData, modelica_metatype _inEquationLst, modelica_metatype _inVars, modelica_metatype _inKnVars)
{
  modelica_metatype _cr_lst = NULL;
  modelica_metatype _ht = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cr_lst has no default value.
  // _ht has no default value.
  _ht = omc_HashTable_emptyHashTable(threadData);

  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta4 = mmc_mk_box3(0, _inVars, _inKnVars, _ht);
  tmpMeta5 = mmc_mk_box2(0, boxvar_BackendEquation_checkEquationsUnknownCrefsExp, tmpMeta4);
  omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEquationLst, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta5, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  _ht = tmpMeta3;

  _cr_lst = omc_BaseHashTable_hashTableKeyList(threadData, _ht);
  _return: OMC_LABEL_UNUSED
  return _cr_lst;
}

DLLDirection
modelica_metatype omc_BackendEquation_findUnknownCrefs(threadData_t *threadData, modelica_metatype __omcQ_24in_5FinEq, modelica_metatype __omcQ_24in_5FextraArgs, modelica_metatype *out_extraArgs)
{
  modelica_metatype _inEq = NULL;
  modelica_metatype _extraArgs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _inEq = __omcQ_24in_5FinEq;
  _extraArgs = __omcQ_24in_5FextraArgs;
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = mmc_mk_box2(0, boxvar_BackendEquation_checkEquationsUnknownCrefsExp, _extraArgs);
  omc_BackendEquation_traverseExpsOfEquation(threadData, _inEq, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta3, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _extraArgs = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  if (out_extraArgs) { *out_extraArgs = _extraArgs; }
  return _inEq;
}

DLLDirection
modelica_metatype omc_BackendEquation_getCrefsFromEquations(threadData_t *threadData, modelica_metatype _inEqns, modelica_metatype _inVars, modelica_metatype _inKnVars)
{
  modelica_metatype _cr_lst = NULL;
  modelica_metatype _ht = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _knownVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cr_lst has no default value.
  // _ht has no default value.
  // _vars has no default value.
  // _knownVars has no default value.
  _ht = omc_HashTable_emptyHashTable(threadData);

  /* Pattern-matching assignment */
  tmpMeta1 = mmc_mk_box3(0, _inVars, _inKnVars, _ht);
  tmpMeta2 = omc_BackendEquation_traverseEquationArray(threadData, _inEqns, boxvar_BackendEquation_findUnknownCrefs, tmpMeta1);
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  _ht = tmpMeta3;

  _cr_lst = omc_BaseHashTable_hashTableKeyList(threadData, _ht);
  _return: OMC_LABEL_UNUSED
  return _cr_lst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingEquationCrefFinder(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inCrefs, modelica_metatype *out_cr_lst)
{
  modelica_metatype _e = NULL;
  modelica_metatype _cr_lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _e has no default value.
  // _cr_lst has no default value.
  _e = _inEq;

  _cr_lst = _inCrefs;

  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = mmc_mk_box2(0, boxvar_Expression_traversingComponentRefFinder, _cr_lst);
  omc_BackendEquation_traverseExpsOfEquation(threadData, _e, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta3, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _cr_lst = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  if (out_cr_lst) { *out_cr_lst = _cr_lst; }
  return _e;
}

DLLDirection
modelica_metatype omc_BackendEquation_getAllCrefFromEquations(threadData_t *threadData, modelica_metatype _inEqns)
{
  modelica_metatype _cr_lst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _cr_lst has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _cr_lst = omc_BackendEquation_traverseEquationArray(threadData, _inEqns, boxvar_BackendEquation_traversingEquationCrefFinder, tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return _cr_lst;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationCrefsSolved(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype *out_rhs_lst)
{
  modelica_metatype _lhs_lst = NULL;
  modelica_metatype _rhs_lst = NULL;
  modelica_metatype _lhs = NULL;
  modelica_metatype _rhs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _lhs_lst has no default value.
  // _rhs_lst has no default value.
  // _lhs has no default value.
  // _rhs has no default value.
  _lhs = omc_BackendEquation_getEquationLHS(threadData, _inEquation);

  _rhs = omc_BackendEquation_getEquationRHS(threadData, _inEquation);

  _lhs_lst = omc_Expression_extractCrefsFromExp(threadData, _lhs);

  _rhs_lst = omc_Expression_extractCrefsFromExp(threadData, _rhs);
  _return: OMC_LABEL_UNUSED
  if (out_rhs_lst) { *out_rhs_lst = _rhs_lst; }
  return _lhs_lst;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationCrefs(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_metatype _outExpComponentRefLst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExpComponentRefLst has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta4 = mmc_mk_box2(0, boxvar_Expression_traversingComponentRefFinder, tmpMeta3);
  omc_BackendEquation_traverseExpsOfEquation(threadData, _inEquation, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta4, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _outExpComponentRefLst = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outExpComponentRefLst;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationsCrefs(threadData_t *threadData, modelica_metatype _inEquationLst)
{
  modelica_metatype _outExpComponentRefLst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExpComponentRefLst has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta4 = mmc_mk_box2(0, boxvar_Expression_traversingComponentRefFinder, tmpMeta3);
  omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEquationLst, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta4, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _outExpComponentRefLst = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outExpComponentRefLst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingRelationsforIterationVars(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outTpl has no default value.
  _outExp = _inExp;

  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inExp;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _indexes = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_integer _index;
      modelica_metatype _vlst1 = NULL;
      modelica_metatype _vlst2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _indexes has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _index has no default value.
      // _vlst1 has no default value.
      // _vlst2 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_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _e1 = tmpMeta6;
          _e2 = tmpMeta7;
          _index = tmp9  /* pattern as ty=Integer */;
          _indexes = tmpMeta10;
          _vars = tmpMeta11;
          /* Pattern matching succeeded */
          _vlst1 = omc_BackendEquation_expressionVars(threadData, _e1, _vars);

          _vlst2 = omc_BackendEquation_expressionVars(threadData, _e2, _vars);

          if((!(listEmpty(_vlst1) && listEmpty(_vlst2))))
          {
            tmpMeta12 = mmc_mk_cons(mmc_mk_integer(_index), _indexes);
            tmpMeta13 = mmc_mk_box2(0, tmpMeta12, _vars);
            _outTpl = tmpMeta13;
          }
          else
          {
            _outTpl = _inTpl;
          }
          tmpMeta1 = _outTpl;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outExp;
}

DLLDirection
modelica_boolean omc_BackendEquation_iterationVarsinRelations(threadData_t *threadData, modelica_metatype _inEquationLst, modelica_metatype _inVars, modelica_metatype *out_indexes)
{
  modelica_boolean _mixedSystem;
  modelica_metatype _indexes = 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
  // _mixedSystem has no default value.
  // _indexes has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta5 = mmc_mk_box2(0, tmpMeta4, _inVars);
  tmpMeta6 = mmc_mk_box2(0, boxvar_BackendEquation_traversingRelationsforIterationVars, tmpMeta5);
  omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEquationLst, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta6, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
  _indexes = tmpMeta3;

  _mixedSystem = (!listEmpty(_indexes));
  _return: OMC_LABEL_UNUSED
  if (out_indexes) { *out_indexes = _indexes; }
  return _mixedSystem;
}
modelica_metatype boxptr_BackendEquation_iterationVarsinRelations(threadData_t *threadData, modelica_metatype _inEquationLst, modelica_metatype _inVars, modelica_metatype *out_indexes)
{
  modelica_boolean _mixedSystem;
  modelica_metatype out_mixedSystem;
  _mixedSystem = omc_BackendEquation_iterationVarsinRelations(threadData, _inEquationLst, _inVars, out_indexes);
  out_mixedSystem = mmc_mk_icon(_mixedSystem);
  /* skip box _indexes; list<#Integer> */
  return out_mixedSystem;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingParamRefFinder0(threadData_t *threadData, modelica_metatype _iVars, modelica_metatype _iVarIdc, modelica_metatype _iParamVarsList, modelica_metatype _iParamVarsIdc, modelica_metatype *out_oParamVarIdc)
{
  modelica_metatype _oParamVarsList = NULL;
  modelica_metatype _oParamVarIdc = NULL;
  modelica_metatype _var = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _varIdc = NULL;
  modelica_integer _varIdx;
  modelica_metatype _rest = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oParamVarsList has no default value.
  // _oParamVarIdc has no default value.
  // _var has no default value.
  _vars = _iParamVarsList;
  _varIdc = _iParamVarsIdc;
  // _varIdx has no default value.
  _rest = _iVarIdc;
  {
    modelica_metatype _var;
    for (tmpMeta1 = _iVars; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _var = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _rest;
      if (listEmpty(tmpMeta2)) MMC_THROW_INTERNAL();
      tmpMeta3 = MMC_CAR(tmpMeta2);
      tmpMeta4 = MMC_CDR(tmpMeta2);
      tmp5 = mmc_unbox_integer(tmpMeta3);
      _varIdx = tmp5  /* pattern as ty=Integer */;
      _rest = tmpMeta4;

      if(omc_BackendVariable_isParam(threadData, _var))
      {
        _vars = omc_List_unionEltOnTrue(threadData, _var, _vars, boxvar_BackendVariable_varEqual);

        _varIdc = omc_List_unionEltOnTrue(threadData, mmc_mk_integer(_varIdx), _varIdc, boxvar_intEq);
      }
    }
  }

  _oParamVarsList = _vars;

  _oParamVarIdc = _varIdc;
  _return: OMC_LABEL_UNUSED
  if (out_oParamVarIdc) { *out_oParamVarIdc = _oParamVarIdc; }
  return _oParamVarsList;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_BackendEquation_traversingParamRefFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outTpl has no default value.
  _outExp = _inExp;

  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inExp;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _allVars = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _foundVars = NULL;
      modelica_metatype _varIdc = NULL;
      modelica_metatype _foundVarsIdc = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _allVars has no default value.
      // _vars has no default value.
      // _foundVars has no default value.
      // _varIdc has no default value.
      // _foundVarsIdc has no default value.
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; 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_LIT25), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          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_2), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta8;
          _vars = tmpMeta9;
          _varIdc = tmpMeta10;
          _allVars = tmpMeta11;
          /* Pattern matching succeeded */
          _foundVars = omc_BackendVariable_getVar(threadData, _cr, _allVars ,&_foundVarsIdc);

          _vars = omc_BackendEquation_traversingParamRefFinder0(threadData, _foundVars, _foundVarsIdc, _vars, _varIdc ,&_varIdc);
          tmpMeta12 = mmc_mk_box3(0, _vars, _varIdc, _allVars);
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outExp;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationsParams(threadData_t *threadData, modelica_metatype _inEquationLst, modelica_metatype _inVars, modelica_metatype *out_outParamVarsIdc)
{
  modelica_metatype _outParamVars = NULL;
  modelica_metatype _outParamVarsIdc = 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;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outParamVars has no default value.
  // _outParamVarsIdc has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta7 = mmc_mk_box3(0, tmpMeta5, tmpMeta6, _inVars);
  tmpMeta8 = mmc_mk_box2(0, boxvar_BackendEquation_traversingParamRefFinder, tmpMeta7);
  omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEquationLst, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta8, &tmpMeta1);
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  _outParamVars = tmpMeta3;
  _outParamVarsIdc = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  if (out_outParamVarsIdc) { *out_outParamVarsIdc = _outParamVarsIdc; }
  return _outParamVars;
}

DLLDirection
modelica_boolean omc_BackendEquation_assertWithCondTrue(threadData_t *threadData, modelica_metatype _inEqn)
{
  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 = _inEqn;
    {
      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;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          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));
          if (listEmpty(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmpMeta7);
          tmpMeta9 = MMC_CDR(tmpMeta7);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,8,4) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,3,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          if (1 /* true */ != tmp12) goto tmp3_end;
          if (!listEmpty(tmpMeta9)) 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:;
    }
  }
  _b = tmp1;
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_assertWithCondTrue(threadData_t *threadData, modelica_metatype _inEqn)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_BackendEquation_assertWithCondTrue(threadData, _inEqn);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_BackendEquation_checkEquationsVarsExpTopDown(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype _vars, modelica_boolean *out_cont, modelica_metatype *out_tree)
{
  modelica_metatype _exp = NULL;
  modelica_boolean _cont;
  modelica_metatype _tree = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  // _cont has no default value.
  _tree = __omcQ_24in_5Ftree;
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _ilst = NULL;
      modelica_string _idn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _ilst has no default value.
      // _idn has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; 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_LIT25), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _tree;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,13,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _tree;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,1,1) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          
          _idn = tmpMeta10;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((stringEqual(_idn, _OMC_LIT78)) || (stringEqual(_idn, _OMC_LIT79)))) goto tmp3_end;
          tmp1_c0 = 0 /* false */;
          tmpMeta[0+1] = _tree;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta11;
          /* Pattern matching succeeded */
          { /* 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: {
                  /* Pattern matching succeeded */
                  omc_BackendVariable_getVar(threadData, _cr, _vars ,&_ilst);

                  _tree = omc_AvlSetInt_addList(threadData, _tree, _ilst);
                  goto tmp13_done;
                }
                case 1: {
                  /* Pattern matching succeeded */
                  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_2;
              tmp13_done2:;
            }
          }
          ;
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _tree;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _tree;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _cont = tmp1_c0;
  _tree = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_tree) { *out_tree = _tree; }
  return _exp;
}
modelica_metatype boxptr_BackendEquation_checkEquationsVarsExpTopDown(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype _vars, modelica_metatype *out_cont, modelica_metatype *out_tree)
{
  modelica_boolean _cont;
  modelica_metatype _exp = NULL;
  _exp = omc_BackendEquation_checkEquationsVarsExpTopDown(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Ftree, _vars, &_cont, out_tree);
  /* skip box _exp; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  /* skip box _tree; AvlSetInt.Tree */
  return _exp;
}

static modelica_metatype closure0_BackendEquation_checkEquationsVarsExpTopDown(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_tree, modelica_metatype tmp1, modelica_metatype tmp2)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_BackendEquation_checkEquationsVarsExpTopDown(thData, $in_exp, $in_tree, vars, tmp1, tmp2);
}
DLLDirection
modelica_metatype omc_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Ftree, modelica_metatype _vars, modelica_metatype *out_tree)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _tree = NULL;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _tree = __omcQ_24in_5Ftree;
  tmpMeta3 = mmc_mk_box1(0, _vars);
  _exp = omc_Expression_traverseExpTopDown(threadData, _exp, (modelica_fnptr) mmc_mk_box2(0,closure0_BackendEquation_checkEquationsVarsExpTopDown,tmpMeta3), _tree ,&_tree);
  _return: OMC_LABEL_UNUSED
  if (out_tree) { *out_tree = _tree; }
  return _exp;
}

DLLDirection
modelica_metatype omc_BackendEquation_expressionVarsIndexes(threadData_t *threadData, modelica_metatype _exp, modelica_metatype __omcQ_24in_5Findexes, modelica_fnptr _func)
{
  modelica_metatype _indexes = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _indexes = __omcQ_24in_5Findexes;
  omc_Expression_traverseExpTopDown(threadData, _exp, ((modelica_fnptr) _func), _indexes ,&_indexes);
  _return: OMC_LABEL_UNUSED
  return _indexes;
}

static modelica_metatype closure1_BackendEquation_checkEquationsVarsExpTopDown(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_tree, modelica_metatype tmp1, modelica_metatype tmp2)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_BackendEquation_checkEquationsVarsExpTopDown(thData, $in_exp, $in_tree, vars, tmp1, tmp2);
}
DLLDirection
modelica_metatype omc_BackendEquation_expressionVars(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _vars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _indexes = NULL;
  modelica_metatype _keys = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _indexes has no default value.
  // _keys has no default value.
  tmpMeta3 = mmc_mk_box1(0, _vars);
  omc_Expression_traverseExpTopDown(threadData, _inExp, (modelica_fnptr) mmc_mk_box2(0,closure1_BackendEquation_checkEquationsVarsExpTopDown,tmpMeta3), omc_AvlSetInt_new(threadData) ,&_indexes);

  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _keys = omc_AvlSetInt_listKeys(threadData, _indexes, tmpMeta4);

  _outVars = omc_List_map1r(threadData, _keys, boxvar_BackendVariable_getVarAt, _vars);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

static modelica_metatype closure2_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_tree, modelica_metatype tmp1)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(thData, $in_exp, $in_tree, vars, tmp1);
}
DLLDirection
modelica_metatype omc_BackendEquation_equationVars(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype _inVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _indexes = NULL;
  modelica_metatype _keys = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _indexes has no default value.
  // _keys has no default value.
  tmpMeta2 = mmc_mk_box1(0, _inVars);
  omc_BackendEquation_traverseExpsOfEquation(threadData, _inEquation, (modelica_fnptr) mmc_mk_box2(0,closure2_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper,tmpMeta2), omc_AvlSetInt_new(threadData) ,&_indexes);

  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _keys = omc_AvlSetInt_listKeys(threadData, _indexes, tmpMeta3);

  _outVars = omc_List_map1r(threadData, _keys, boxvar_BackendVariable_getVarAt, _inVars);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

static modelica_metatype closure3_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_tree, modelica_metatype tmp1)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(thData, $in_exp, $in_tree, vars, tmp1);
}
DLLDirection
modelica_metatype omc_BackendEquation_equationsVars(threadData_t *threadData, modelica_metatype _inEquations, modelica_metatype _inVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _indexes = NULL;
  modelica_metatype _keys = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _indexes has no default value.
  // _keys has no default value.
  tmpMeta2 = mmc_mk_box1(0, _inVars);
  _indexes = omc_BackendDAEUtil_traverseBackendDAEExpsEqns(threadData, _inEquations, (modelica_fnptr) mmc_mk_box2(0,closure3_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper,tmpMeta2), omc_AvlSetInt_new(threadData));

  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _keys = omc_AvlSetInt_listKeys(threadData, _indexes, tmpMeta3);

  _outVars = omc_List_map1r(threadData, _keys, boxvar_BackendVariable_getVarAt, _inVars);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

static modelica_metatype closure4_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_tree, modelica_metatype tmp2)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper(thData, $in_exp, $in_tree, vars, tmp2);
}
DLLDirection
modelica_metatype omc_BackendEquation_equationsLstVars(threadData_t *threadData, modelica_metatype _inEquationLst, modelica_metatype _inVars)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _indexes = NULL;
  modelica_metatype _keys = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _indexes has no default value.
  // _keys has no default value.
  if(listEmpty(_inEquationLst))
  {
    tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
    _outVars = tmpMeta1;

    goto _return;
  }

  tmpMeta3 = mmc_mk_box1(0, _inVars);
  omc_BackendEquation_traverseExpsOfEquationList(threadData, _inEquationLst, (modelica_fnptr) mmc_mk_box2(0,closure4_BackendEquation_checkEquationsVarsExpTopDownTraverseHelper,tmpMeta3), omc_AvlSetInt_new(threadData) ,&_indexes);

  tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
  _keys = omc_AvlSetInt_listKeys(threadData, _indexes, tmpMeta4);

  _outVars = omc_List_map1r(threadData, _keys, boxvar_BackendVariable_getVarAt, _inVars);
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

DLLDirection
modelica_metatype omc_BackendEquation_setWhenElsePart(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_metatype _inElseWhenEquation)
{
  modelica_metatype _outWhenEquation = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outWhenEquation has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenEquation;
    {
      modelica_metatype _cond = NULL;
      modelica_metatype _elsewhenPart = NULL;
      modelica_metatype _whenStmtLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cond has no default value.
      // _elsewhenPart has no default value.
      // _whenStmtLst 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;
          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));
          if (!optionNone(tmpMeta8)) goto tmp3_end;
          _cond = tmpMeta6;
          _whenStmtLst = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta9 = mmc_mk_box4(3, &BackendDAE_WhenEquation_WHEN__STMTS__desc, _cond, _whenStmtLst, mmc_mk_some(_inElseWhenEquation));
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          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));
          if (optionNone(tmpMeta12)) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          _cond = tmpMeta10;
          _whenStmtLst = tmpMeta11;
          _elsewhenPart = tmpMeta13;
          /* Pattern matching succeeded */
          tmpMeta14 = mmc_mk_box4(3, &BackendDAE_WhenEquation_WHEN__STMTS__desc, _cond, _whenStmtLst, mmc_mk_some(omc_BackendEquation_setWhenElsePart(threadData, _elsewhenPart, _inElseWhenEquation)));
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outWhenEquation = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outWhenEquation;
}

DLLDirection
modelica_metatype omc_BackendEquation_getWhenEquationExpr(threadData_t *threadData, modelica_metatype _inWhenEquation, modelica_metatype *out_outExp)
{
  modelica_metatype _outComponentRef = NULL;
  modelica_metatype _outExp = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outComponentRef has no default value.
  // _outExp 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;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta5 = _inWhenEquation;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
          if (listEmpty(tmpMeta6)) goto goto_1;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,0,3) == 0) goto goto_1;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,6,2) == 0) goto goto_1;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          if (!listEmpty(tmpMeta8)) goto goto_1;
          _outComponentRef = tmpMeta10;
          _outExp = tmpMeta11;
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT80, _OMC_LIT81);
          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_outExp) { *out_outExp = _outExp; }
  return _outComponentRef;
}

DLLDirection
modelica_metatype omc_BackendEquation_getForEquationIterIdent(threadData_t *threadData, modelica_metatype _inEquation)
{
  modelica_metatype _forIter = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _forIter has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inEquation;
    {
      modelica_string _iter = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _iter 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 (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,6) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,3) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          
          _iter = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_some(_iter);
          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:;
    }
  }
  _forIter = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _forIter;
}

DLLDirection
modelica_metatype omc_BackendEquation_sortInitialEqns(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqns)
{
  modelica_metatype _eqns = NULL;
  modelica_metatype _eqn_lst = NULL;
  modelica_metatype _init_eqns = NULL;
  modelica_metatype _sim_eqns = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqns = __omcQ_24in_5Feqns;
  // _eqn_lst has no default value.
  // _init_eqns has no default value.
  // _sim_eqns has no default value.
  _eqn_lst = omc_BackendEquation_equationList(threadData, _eqns);

  _init_eqns = omc_List_splitOnTrue(threadData, _eqn_lst, boxvar_BackendEquation_isInitialEquation ,&_sim_eqns);

  _eqn_lst = listAppend(_init_eqns, _sim_eqns);

  _eqns = omc_BackendEquation_listEquation(threadData, _eqn_lst);
  _return: OMC_LABEL_UNUSED
  return _eqns;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseEquationArray__WithUpdate(threadData_t *threadData, modelica_metatype __omcQ_24in_5FequationArray, modelica_fnptr _inFuncWithUpdate, modelica_metatype __omcQ_24in_5FextraArg, modelica_metatype *out_extraArg)
{
  modelica_metatype _equationArray = NULL;
  modelica_metatype _extraArg = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _new_e = NULL;
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  _extraArg = __omcQ_24in_5FextraArg;
  // _e has no default value.
  // _new_e has no default value.
  tmp1 = ((modelica_integer) 1); tmp2 = 1; tmp3 = omc_ExpandableArray_getLastUsedIndex(threadData, _equationArray);
  if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp1, tmp3); _i += tmp2)
    {
      if(omc_ExpandableArray_occupied(threadData, _i, _equationArray))
      {
        _e = omc_ExpandableArray_get(threadData, _i, _equationArray);

        _new_e = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithUpdate), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithUpdate), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithUpdate), 2))), _e, _extraArg ,&_extraArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithUpdate), 1)))) (threadData, _e, _extraArg ,&_extraArg);

        if((!referenceEq(_e, _new_e)))
        {
          omc_ExpandableArray_update(threadData, _i, _new_e, _equationArray);
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_extraArg) { *out_extraArg = _extraArg; }
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseEquationArray__WithStop(threadData_t *threadData, modelica_metatype _equationArray, modelica_fnptr _inFuncWithStop, modelica_metatype __omcQ_24in_5FextraArg)
{
  modelica_metatype _extraArg = NULL;
  modelica_boolean _continue_;
  modelica_metatype _eqn = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _extraArg = __omcQ_24in_5FextraArg;
  // _continue_ has no default value.
  // _eqn has no default value.
  tmp4 = ((modelica_integer) 1); tmp5 = 1; tmp6 = omc_ExpandableArray_getLastUsedIndex(threadData, _equationArray);
  if(!(((tmp5 > 0) && (tmp4 > tmp6)) || ((tmp5 < 0) && (tmp4 < tmp6))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp4, tmp6); _i += tmp5)
    {
      if(omc_ExpandableArray_occupied(threadData, _i, _equationArray))
      {
        _eqn = omc_ExpandableArray_get(threadData, _i, _equationArray);

        /* Pattern-matching tuple assignment, wild first pattern */
        (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithStop), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithStop), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithStop), 2))), _eqn, _extraArg, &tmpMeta1, &tmpMeta3) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFuncWithStop), 1)))) (threadData, _eqn, _extraArg, &tmpMeta1, &tmpMeta3);
        tmp2 = mmc_unbox_integer(tmpMeta1);
        _continue_ = tmp2  /* pattern as ty=Boolean */;
        _extraArg = tmpMeta3;

        if((!_continue_))
        {
          break;
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _extraArg;
}

DLLDirection
modelica_metatype omc_BackendEquation_traverseEquationArray(threadData_t *threadData, modelica_metatype _equationArray, modelica_fnptr _inFunc, modelica_metatype __omcQ_24in_5FextraArg)
{
  modelica_metatype _extraArg = NULL;
  modelica_metatype _eqn = NULL;
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _extraArg = __omcQ_24in_5FextraArg;
  // _eqn has no default value.
  tmp1 = ((modelica_integer) 1); tmp2 = 1; tmp3 = omc_ExpandableArray_getLastUsedIndex(threadData, _equationArray);
  if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp1, tmp3); _i += tmp2)
    {
      if(omc_ExpandableArray_occupied(threadData, _i, _equationArray))
      {
        _eqn = omc_ExpandableArray_get(threadData, _i, _equationArray);

        (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))), _eqn, _extraArg ,&_extraArg) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _eqn, _extraArg ,&_extraArg);
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _extraArg;
}

DLLDirection
modelica_integer omc_BackendEquation_getNumberOfEquations(threadData_t *threadData, modelica_metatype _inEquationArray)
{
  modelica_integer _outSize;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSize = omc_ExpandableArray_getNumberOfElements(threadData, _inEquationArray);
  _return: OMC_LABEL_UNUSED
  return _outSize;
}
modelica_metatype boxptr_BackendEquation_getNumberOfEquations(threadData_t *threadData, modelica_metatype _inEquationArray)
{
  modelica_integer _outSize;
  modelica_metatype out_outSize;
  _outSize = omc_BackendEquation_getNumberOfEquations(threadData, _inEquationArray);
  out_outSize = mmc_mk_icon(_outSize);
  return out_outSize;
}

DLLDirection
modelica_integer omc_BackendEquation_equationArraySize(threadData_t *threadData, modelica_metatype _equationArray)
{
  modelica_integer _outSize;
  modelica_boolean _nfScalarize;
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSize has no default value.
  _nfScalarize = omc_Flags_isSet(threadData, _OMC_LIT85);
  _outSize = ((modelica_integer) 0);

  tmp1 = ((modelica_integer) 1); tmp2 = 1; tmp3 = omc_ExpandableArray_getLastUsedIndex(threadData, _equationArray);
  if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp1, tmp3); _i += tmp2)
    {
      if(omc_ExpandableArray_occupied(threadData, _i, _equationArray))
      {
        if(_nfScalarize)
        {
          _outSize = _outSize + omc_BackendEquation_equationSize(threadData, omc_ExpandableArray_get(threadData, _i, _equationArray));
        }
        else
        {
          _outSize = ((modelica_integer) 1) + _outSize;
        }
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outSize;
}
modelica_metatype boxptr_BackendEquation_equationArraySize(threadData_t *threadData, modelica_metatype _equationArray)
{
  modelica_integer _outSize;
  modelica_metatype out_outSize;
  _outSize = omc_BackendEquation_equationArraySize(threadData, _equationArray);
  out_outSize = mmc_mk_icon(_outSize);
  return out_outSize;
}

DLLDirection
modelica_metatype omc_BackendEquation_getList(threadData_t *threadData, modelica_metatype _inIndices, modelica_metatype _inEquationArray)
{
  modelica_metatype _outEqns = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outEqns = tmpMeta1;
  {
    modelica_metatype __omcQ_24tmpVar11;
    modelica_metatype* tmp3;
    modelica_metatype tmpMeta4;
    modelica_metatype __omcQ_24tmpVar10;
    modelica_integer tmp5;
    modelica_metatype _index_loopVar = 0;
    modelica_metatype _index;
    _index_loopVar = _inIndices;
    tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar11 = tmpMeta4; /* defaultValue */
    tmp3 = &__omcQ_24tmpVar11;
    while(1) {
      tmp5 = 1;
      if (!listEmpty(_index_loopVar)) {
        _index = MMC_CAR(_index_loopVar);
        _index_loopVar = MMC_CDR(_index_loopVar);
        tmp5--;
      }
      if (tmp5 == 0) {
        __omcQ_24tmpVar10 = omc_BackendEquation_get(threadData, _inEquationArray, mmc_unbox_integer(_index));
        *tmp3 = mmc_mk_cons(__omcQ_24tmpVar10,0);
        tmp3 = &MMC_CDR(*tmp3);
      } else if (tmp5 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp3 = mmc_mk_nil();
    tmpMeta2 = __omcQ_24tmpVar11;
  }
  _outEqns = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  return _outEqns;
}

DLLDirection
modelica_boolean omc_BackendEquation_has(threadData_t *threadData, modelica_metatype _inEquationArray, modelica_integer _inPos)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _b = omc_ExpandableArray_occupied(threadData, _inPos, _inEquationArray);
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_BackendEquation_has(threadData_t *threadData, modelica_metatype _inEquationArray, modelica_metatype _inPos)
{
  modelica_integer tmp1;
  modelica_boolean _b;
  modelica_metatype out_b;
  tmp1 = mmc_unbox_integer(_inPos);
  _b = omc_BackendEquation_has(threadData, _inEquationArray, tmp1);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_BackendEquation_get(threadData_t *threadData, modelica_metatype _inEquationArray, modelica_integer _inPos)
{
  modelica_metatype _outEquation = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEquation = omc_ExpandableArray_get(threadData, _inPos, _inEquationArray);
  _return: OMC_LABEL_UNUSED
  return _outEquation;
}
modelica_metatype boxptr_BackendEquation_get(threadData_t *threadData, modelica_metatype _inEquationArray, modelica_metatype _inPos)
{
  modelica_integer tmp1;
  modelica_metatype _outEquation = NULL;
  tmp1 = mmc_unbox_integer(_inPos);
  _outEquation = omc_BackendEquation_get(threadData, _inEquationArray, tmp1);
  /* skip box _outEquation; BackendDAE.Equation */
  return _outEquation;
}

DLLDirection
modelica_metatype omc_BackendEquation_setAtIndexFirst(threadData_t *threadData, modelica_integer _inPos, modelica_metatype _inEquation, modelica_metatype _inEquationArray)
{
  modelica_metatype _outEquationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEquationArray = omc_BackendEquation_setAtIndex(threadData, _inEquationArray, _inPos, _inEquation);
  _return: OMC_LABEL_UNUSED
  return _outEquationArray;
}
modelica_metatype boxptr_BackendEquation_setAtIndexFirst(threadData_t *threadData, modelica_metatype _inPos, modelica_metatype _inEquation, modelica_metatype _inEquationArray)
{
  modelica_integer tmp1;
  modelica_metatype _outEquationArray = NULL;
  tmp1 = mmc_unbox_integer(_inPos);
  _outEquationArray = omc_BackendEquation_setAtIndexFirst(threadData, tmp1, _inEquation, _inEquationArray);
  /* skip box _outEquationArray; ExpandableArray<BackendDAE.Equation> */
  return _outEquationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_setAtIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5FequationArray, modelica_integer _inPos, modelica_metatype _inEquation)
{
  modelica_metatype _equationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  if(omc_ExpandableArray_occupied(threadData, _inPos, _equationArray))
  {
    omc_ExpandableArray_update(threadData, _inPos, _inEquation, _equationArray);
  }
  else
  {
    omc_ExpandableArray_set(threadData, _inPos, _inEquation, _equationArray);
  }
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}
modelica_metatype boxptr_BackendEquation_setAtIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5FequationArray, modelica_metatype _inPos, modelica_metatype _inEquation)
{
  modelica_integer tmp1;
  modelica_metatype _equationArray = NULL;
  tmp1 = mmc_unbox_integer(_inPos);
  _equationArray = omc_BackendEquation_setAtIndex(threadData, __omcQ_24in_5FequationArray, tmp1, _inEquation);
  /* skip box _equationArray; ExpandableArray<BackendDAE.Equation> */
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_copyEquationArray(threadData_t *threadData, modelica_metatype _inEquationArray)
{
  modelica_metatype _outEquationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEquationArray = omc_ExpandableArray_copy(threadData, _inEquationArray, _OMC_LIT86);
  _return: OMC_LABEL_UNUSED
  return _outEquationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_equationList(threadData_t *threadData, modelica_metatype _equationArray)
{
  modelica_metatype _outEquationLst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEquationLst = omc_ExpandableArray_toList(threadData, _equationArray);
  _return: OMC_LABEL_UNUSED
  return _outEquationLst;
}

DLLDirection
modelica_metatype omc_BackendEquation_listEquation(threadData_t *threadData, modelica_metatype _inEquationList)
{
  modelica_metatype _outEquationArray = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEquationArray has no default value.
  _outEquationArray = omc_ExpandableArray_new(threadData, listLength(_inEquationList), _OMC_LIT86);

  {
    modelica_metatype _eq;
    for (tmpMeta1 = _inEquationList; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _eq = MMC_CAR(tmpMeta1);
      omc_ExpandableArray_add(threadData, _eq, _outEquationArray, NULL);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outEquationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_merge(threadData_t *threadData, modelica_metatype _inEqns1, modelica_metatype _inEqns2)
{
  modelica_metatype _outEqns = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEqns has no default value.
  _outEqns = omc_BackendEquation_copyEquationArray(threadData, _inEqns2);

  _outEqns = omc_BackendEquation_addList(threadData, omc_BackendEquation_equationList(threadData, _inEqns1), _outEqns);
  _return: OMC_LABEL_UNUSED
  return _outEqns;
}

DLLDirection
modelica_metatype omc_BackendEquation_deleteList(threadData_t *threadData, modelica_metatype __omcQ_24in_5FequationArray, modelica_metatype _inIndices)
{
  modelica_metatype _equationArray = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  {
    modelica_metatype _index;
    for (tmpMeta1 = _inIndices; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _index = MMC_CAR(tmpMeta1);
      omc_ExpandableArray_delete(threadData, mmc_unbox_integer(_index), _equationArray);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_delete(threadData_t *threadData, modelica_integer _inPos, modelica_metatype __omcQ_24in_5FequationArray)
{
  modelica_metatype _equationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  omc_ExpandableArray_delete(threadData, _inPos, _equationArray);
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}
modelica_metatype boxptr_BackendEquation_delete(threadData_t *threadData, modelica_metatype _inPos, modelica_metatype __omcQ_24in_5FequationArray)
{
  modelica_integer tmp1;
  modelica_metatype _equationArray = NULL;
  tmp1 = mmc_unbox_integer(_inPos);
  _equationArray = omc_BackendEquation_delete(threadData, tmp1, __omcQ_24in_5FequationArray);
  /* skip box _equationArray; ExpandableArray<BackendDAE.Equation> */
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_addList(threadData_t *threadData, modelica_metatype _eqnlst, modelica_metatype __omcQ_24in_5FequationArray)
{
  modelica_metatype _equationArray = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  omc_ExpandableArray_expandToSize(threadData, omc_ExpandableArray_getLastUsedIndex(threadData, _equationArray) + listLength(_eqnlst), _equationArray);

  {
    modelica_metatype _e;
    for (tmpMeta1 = _eqnlst; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _e = MMC_CAR(tmpMeta1);
      _equationArray = omc_BackendEquation_add(threadData, _e, _equationArray);
    }
  }
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_add(threadData_t *threadData, modelica_metatype _inEquation, modelica_metatype __omcQ_24in_5FequationArray)
{
  modelica_metatype _equationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = __omcQ_24in_5FequationArray;
  omc_ExpandableArray_add(threadData, _inEquation, _equationArray, NULL);
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_emptyEqnsSized(threadData_t *threadData, modelica_integer _size)
{
  modelica_metatype _outEquationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outEquationArray = omc_ExpandableArray_new(threadData, _size, _OMC_LIT86);
  _return: OMC_LABEL_UNUSED
  return _outEquationArray;
}
modelica_metatype boxptr_BackendEquation_emptyEqnsSized(threadData_t *threadData, modelica_metatype _size)
{
  modelica_integer tmp1;
  modelica_metatype _outEquationArray = NULL;
  tmp1 = mmc_unbox_integer(_size);
  _outEquationArray = omc_BackendEquation_emptyEqnsSized(threadData, tmp1);
  /* skip box _outEquationArray; ExpandableArray<BackendDAE.Equation> */
  return _outEquationArray;
}

DLLDirection
modelica_metatype omc_BackendEquation_emptyEqns(threadData_t *threadData)
{
  modelica_metatype _equationArray = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _equationArray = omc_BackendEquation_emptyEqnsSized(threadData, ((modelica_integer) 0));
  _return: OMC_LABEL_UNUSED
  return _equationArray;
}

