#include "omc_simulation_settings.h"
#include "RemoveSimpleEquations.h"
#define _OMC_LIT0_data "(-)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT0,3,_OMC_LIT0_data);
#define _OMC_LIT0 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT0)
#define _OMC_LIT1_data ""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT1,0,_OMC_LIT1_data);
#define _OMC_LIT1 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT1)
#define _OMC_LIT2_data "ALIASE: 		"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT2,10,_OMC_LIT2_data);
#define _OMC_LIT2 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT2)
#define _OMC_LIT3_data " = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT3,3,_OMC_LIT3_data);
#define _OMC_LIT3 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT3)
#define _OMC_LIT4_data "  ("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT4,3,_OMC_LIT4_data);
#define _OMC_LIT4 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT4)
#define _OMC_LIT5_data ", "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT5,2,_OMC_LIT5_data);
#define _OMC_LIT5 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT5)
#define _OMC_LIT6_data ")"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT6,1,_OMC_LIT6_data);
#define _OMC_LIT6 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT6)
#define _OMC_LIT7_data "PARAMETERALIASE: 	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT7,18,_OMC_LIT7_data);
#define _OMC_LIT7 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT7)
#define _OMC_LIT8_data "TIMEALIASE: 	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT8,13,_OMC_LIT8_data);
#define _OMC_LIT8 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT8)
#define _OMC_LIT9_data "TIMEINDEPENT: 	"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT9,15,_OMC_LIT9_data);
#define _OMC_LIT9 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT9)
#define _OMC_LIT10_data "----------"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT10,10,_OMC_LIT10_data);
#define _OMC_LIT10 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT10)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT11,2,3) {&DAE_Exp_ICONST__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT11 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT11)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT12,0.0);
#define _OMC_LIT12 MMC_REFREALLIT(_OMC_LIT_STRUCT12)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT13,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT1,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_LIT12}};
#define _OMC_LIT13 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT13)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT14,1,4) {&DAE_ComponentPrefix_NOCOMPPRE__desc,}};
#define _OMC_LIT14 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT14)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT15,8,3) {&DAE_ElementSource_SOURCE__desc,_OMC_LIT13,MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT14,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT15 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT15)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT16,1,3) {&BackendDAE_EquationKind_BINDING__EQUATION__desc,}};
#define _OMC_LIT16 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT16)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT17,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_LIT17 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT17)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT18,4,3) {&BackendDAE_EquationAttributes_EQUATION__ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT16,_OMC_LIT17}};
#define _OMC_LIT18 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT18)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT19,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT12}};
#define _OMC_LIT19 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT19)
#define _OMC_LIT20_data "START: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT20,7,_OMC_LIT20_data);
#define _OMC_LIT20 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT20)
#define _OMC_LIT21_data "\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT21,1,_OMC_LIT21_data);
#define _OMC_LIT21 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT21)
#define _OMC_LIT22_data "debugAlias"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT22,10,_OMC_LIT22_data);
#define _OMC_LIT22 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT22)
#define _OMC_LIT23_data "Dumps some information about the process of removeSimpleEquations."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT23,66,_OMC_LIT23_data);
#define _OMC_LIT23 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT23)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT24,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(43)),_OMC_LIT22,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT23}};
#define _OMC_LIT24 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT24)
#define _OMC_LIT25_data "NOMINAL: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT25,9,_OMC_LIT25_data);
#define _OMC_LIT25 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT25)
#define _OMC_LIT26_data "\n++++++++++ Error in RemoveSimpleEquations.getThisAttributes ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT26,72,_OMC_LIT26_data);
#define _OMC_LIT26 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT26)
#define _OMC_LIT27_data "\n++++++++++ Error in RemoveSimpleEquations.setAttributes ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT27,68,_OMC_LIT27_data);
#define _OMC_LIT27 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT27)
#define _OMC_LIT28_data "\n++++++++++ Error in RemoveSimpleEquations.addThisCrefs ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT28,67,_OMC_LIT28_data);
#define _OMC_LIT28 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT28)
#define _OMC_LIT29_data "\n++++++++++ Error in RemoveSimpleEquations.addRestCrefs ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT29,67,_OMC_LIT29_data);
#define _OMC_LIT29 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT29)
#define _OMC_LIT30_data "\n++++++++++ Error in RemoveSimpleEquations.solveAllCrefs1 ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT30,69,_OMC_LIT30_data);
#define _OMC_LIT30 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT30)
#define _OMC_LIT31_data "\n++++++++++ Error in RemoveSimpleEquations.solveAllCrefs ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT31,68,_OMC_LIT31_data);
#define _OMC_LIT31 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT31)
#define _OMC_LIT32_data "\n++++++++++ Error in RemoveSimpleEquations.addToCrToExp ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT32,67,_OMC_LIT32_data);
#define _OMC_LIT32 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT32)
#define _OMC_LIT33_data "\n++++++++++ Error in RemoveSimpleEquations.addToCrAndEqLists ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT33,72,_OMC_LIT33_data);
#define _OMC_LIT33 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT33)
#define _OMC_LIT34_data "Solve for:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT34,10,_OMC_LIT34_data);
#define _OMC_LIT34 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT34)
#define _OMC_LIT35_data "time"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT35,4,_OMC_LIT35_data);
#define _OMC_LIT35 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT35)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT36,2,4) {&DAE_Type_T__REAL__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT36 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT36)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT37,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT35,_OMC_LIT36,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT37 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT37)
#define _OMC_LIT38_data "Found Equation al0: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT38,20,_OMC_LIT38_data);
#define _OMC_LIT38 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT38)
#define _OMC_LIT39_data "Found Equation al1: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT39,20,_OMC_LIT39_data);
#define _OMC_LIT39 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT39)
#define _OMC_LIT40_data "Found Equation knw0: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT40,21,_OMC_LIT40_data);
#define _OMC_LIT40 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT40)
#define _OMC_LIT41_data "Found Equation knw1: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT41,21,_OMC_LIT41_data);
#define _OMC_LIT41 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT41)
#define _OMC_LIT42_data "\n++++++++++ Error in RemoveSimpleEquations.findSimpleEquations ++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT42,74,_OMC_LIT42_data);
#define _OMC_LIT42 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT42)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT43,1,7) {&BackendDAE_VarKind_DUMMY__STATE__desc,}};
#define _OMC_LIT43 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT43)
#define _OMC_LIT44_data "Number of Unknowns:    "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT44,23,_OMC_LIT44_data);
#define _OMC_LIT44 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT44)
#define _OMC_LIT45_data "Number of \"Complex\" Equations:   "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT45,33,_OMC_LIT45_data);
#define _OMC_LIT45 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT45)
#define _OMC_LIT46_data "Number of Alias Equations:   "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT46,29,_OMC_LIT46_data);
#define _OMC_LIT46 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT46)
#define _OMC_LIT47_data "Number of Simple Equations:   "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT47,30,_OMC_LIT47_data);
#define _OMC_LIT47 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT47)
#define _OMC_LIT48_data "\nAliases:\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT48,67,_OMC_LIT48_data);
#define _OMC_LIT48 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT48)
#define _OMC_LIT49_data "dumprepl"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT49,8,_OMC_LIT49_data);
#define _OMC_LIT49 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT49)
#define _OMC_LIT50_data "Dump the found replacements for simple equation removal."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT50,56,_OMC_LIT50_data);
#define _OMC_LIT50 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT50)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT51,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(38)),_OMC_LIT49,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT50}};
#define _OMC_LIT51 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT51)
#define _OMC_LIT52_data "Negating: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT52,10,_OMC_LIT52_data);
#define _OMC_LIT52 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT52)
#define _OMC_LIT53_data " "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT53,1,_OMC_LIT53_data);
#define _OMC_LIT53 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT53)
#define _OMC_LIT54_data ".\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT54,2,_OMC_LIT54_data);
#define _OMC_LIT54 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT54)
#define _OMC_LIT55_data "Not negating: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT55,14,_OMC_LIT55_data);
#define _OMC_LIT55 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT55)
#define _OMC_LIT56_data " returning: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT56,12,_OMC_LIT56_data);
#define _OMC_LIT56 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT56)
#define _OMC_LIT57_data "pre"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT57,3,_OMC_LIT57_data);
#define _OMC_LIT57 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT57)
#define _OMC_LIT58_data "The following initial equation is inconsistent due to simplifications in RemoveSimpleEquations and therefore removed from the initialization problem: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT58,150,_OMC_LIT58_data);
#define _OMC_LIT58 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT58)
#define _OMC_LIT59_data " -> "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT59,4,_OMC_LIT59_data);
#define _OMC_LIT59 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT59)
#define _OMC_LIT60_data "The following initial equation is redundant and consistent due to simplifications in RemoveSimpleEquations and therefore removed from the initialization problem: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT60,162,_OMC_LIT60_data);
#define _OMC_LIT60 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT60)
#define _OMC_LIT61_data "=> Select value from "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT61,21,_OMC_LIT61_data);
#define _OMC_LIT61 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT61)
#define _OMC_LIT62_data "("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT62,1,_OMC_LIT62_data);
#define _OMC_LIT62 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT62)
#define _OMC_LIT63_data ") for variable: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT63,16,_OMC_LIT63_data);
#define _OMC_LIT63 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT63)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT64,1,5) {&ErrorTypes_MessageType_TRANSLATION__desc,}};
#define _OMC_LIT64 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT64)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT65,1,5) {&ErrorTypes_Severity_WARNING__desc,}};
#define _OMC_LIT65 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT65)
#define _OMC_LIT66_data "%s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT66,2,_OMC_LIT66_data);
#define _OMC_LIT66 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT66)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT67,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(6000)),_OMC_LIT64,_OMC_LIT65,_OMC_LIT66}};
#define _OMC_LIT67 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT67)
#define _OMC_LIT68_data "aliasConflicts"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT68,14,_OMC_LIT68_data);
#define _OMC_LIT68 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT68)
#define _OMC_LIT69_data "Dumps alias sets with different start or nominal values."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT69,56,_OMC_LIT69_data);
#define _OMC_LIT69 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT69)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT70,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(163)),_OMC_LIT68,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT69}};
#define _OMC_LIT70 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT70)
#define _OMC_LIT71_data " * Candidate: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT71,14,_OMC_LIT71_data);
#define _OMC_LIT71 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT71)
#define _OMC_LIT72_data ", confidence number = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT72,22,_OMC_LIT72_data);
#define _OMC_LIT72 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT72)
#define _OMC_LIT73_data ")\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT73,2,_OMC_LIT73_data);
#define _OMC_LIT73 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT73)
#define _OMC_LIT74_data "Alias set with conflicting start values\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT74,40,_OMC_LIT74_data);
#define _OMC_LIT74 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT74)
#define _OMC_LIT75_data "start"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT75,5,_OMC_LIT75_data);
#define _OMC_LIT75 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT75)
#define _OMC_LIT76_data "RemoveSimpleEquations.handleVarSetAttributes failed!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT76,53,_OMC_LIT76_data);
#define _OMC_LIT76 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT76)
#define _OMC_LIT77_data "Alias variables with invalid limits min "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT77,40,_OMC_LIT77_data);
#define _OMC_LIT77 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT77)
#define _OMC_LIT78_data " > max "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT78,7,_OMC_LIT78_data);
#define _OMC_LIT78 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT78)
#define _OMC_LIT79_data " min_1 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT79,7,_OMC_LIT79_data);
#define _OMC_LIT79 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT79)
#define _OMC_LIT80_data " max_1 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT80,7,_OMC_LIT80_data);
#define _OMC_LIT80 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT80)
#define _OMC_LIT81_data " max_2 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT81,7,_OMC_LIT81_data);
#define _OMC_LIT81 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT81)
#define _OMC_LIT82_data " min_2 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT82,7,_OMC_LIT82_data);
#define _OMC_LIT82 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT82)
#define _OMC_LIT83_data "RemoveSimpleEquations.mergeMinMax failed!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT83,42,_OMC_LIT83_data);
#define _OMC_LIT83 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT83)
#define _OMC_LIT84_data "Alias set with conflicting nominal values\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT84,42,_OMC_LIT84_data);
#define _OMC_LIT84 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT84)
#define _OMC_LIT85_data "nominal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT85,7,_OMC_LIT85_data);
#define _OMC_LIT85 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT85)
#define _OMC_LIT86_data "Conflicting start values for fixed states:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT86,43,_OMC_LIT86_data);
#define _OMC_LIT86 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT86)
#define _OMC_LIT87_data "(start = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT87,9,_OMC_LIT87_data);
#define _OMC_LIT87 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT87)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT88,1,6) {&ErrorTypes_MessageType_SYMBOLIC__desc,}};
#define _OMC_LIT88 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT88)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT89,1,4) {&ErrorTypes_Severity_ERROR__desc,}};
#define _OMC_LIT89 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT89)
#define _OMC_LIT90_data "The model contains alias variables with conflicting fixed start values. It is necessary to resolve the conflicts, because otherwise the initial system is impossible to solve. To print the conflicting alias sets and the chosen candidates please use -d=aliasConflicts."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT90,266,_OMC_LIT90_data);
#define _OMC_LIT90 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT90)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT91,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(7018)),_OMC_LIT88,_OMC_LIT89,_OMC_LIT90}};
#define _OMC_LIT91 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT91)
#define _OMC_LIT92_data " start_1 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT92,9,_OMC_LIT92_data);
#define _OMC_LIT92 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT92)
#define _OMC_LIT93_data " start_2 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT93,9,_OMC_LIT93_data);
#define _OMC_LIT93 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT93)
#define _OMC_LIT94_data "RemoveSimpleEquations.addStartValue failed!\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT94,44,_OMC_LIT94_data);
#define _OMC_LIT94 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT94)
#define _OMC_LIT95_data " in negateOptExp "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT95,17,_OMC_LIT95_data);
#define _OMC_LIT95 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT95)
#define _OMC_LIT96_data " ALIAS_1 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT96,9,_OMC_LIT96_data);
#define _OMC_LIT96 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT96)
#define _OMC_LIT97_data " ALIAS_2 "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT97,9,_OMC_LIT97_data);
#define _OMC_LIT97 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT97)
#define _OMC_LIT98_data " PARAMETERLAIAS "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT98,16,_OMC_LIT98_data);
#define _OMC_LIT98 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT98)
#define _OMC_LIT99_data "Found equation without time-dependent variables: %s = %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT99,56,_OMC_LIT99_data);
#define _OMC_LIT99 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT99)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT100,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(550)),_OMC_LIT88,_OMC_LIT89,_OMC_LIT99}};
#define _OMC_LIT100 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT100)
#define _OMC_LIT101_data " PARAMETERALIAS "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT101,16,_OMC_LIT101_data);
#define _OMC_LIT101 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT101)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT102,1,1) {_OMC_LIT19}};
#define _OMC_LIT102 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT102)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT103,2,0) {MMC_IMMEDIATE(MMC_TAGFIXNUM(-1)),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT103 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT103)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT104,2,0) {MMC_REFSTRUCTLIT(mmc_none),MMC_REFSTRUCTLIT(mmc_none)}};
#define _OMC_LIT104 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT104)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT105,4,0) {MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT103,MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT104}};
#define _OMC_LIT105 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT105)
#define _OMC_LIT106_data " timealias "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT106,11,_OMC_LIT106_data);
#define _OMC_LIT106 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT106)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT107,1.0);
#define _OMC_LIT107 MMC_REFREALLIT(_OMC_LIT_STRUCT107)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT108,2,4) {&DAE_Exp_RCONST__desc,_OMC_LIT107}};
#define _OMC_LIT108 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT108)
#define _OMC_LIT109_data " timealias der "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT109,15,_OMC_LIT109_data);
#define _OMC_LIT109 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT109)
#define _OMC_LIT110_data "----------------------------------"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT110,34,_OMC_LIT110_data);
#define _OMC_LIT110 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT110)
#define _OMC_LIT111_data "Circular Equalities Detected for Variables:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT111,44,_OMC_LIT111_data);
#define _OMC_LIT111 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT111)
#define _OMC_LIT112_data "Internal error %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT112,17,_OMC_LIT112_data);
#define _OMC_LIT112 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT112)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT113,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(63)),_OMC_LIT64,_OMC_LIT89,_OMC_LIT112}};
#define _OMC_LIT113 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT113)
#define _OMC_LIT114_data "Const Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT114,15,_OMC_LIT114_data);
#define _OMC_LIT114 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT114)
#define _OMC_LIT115_data " found.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT115,8,_OMC_LIT115_data);
#define _OMC_LIT115 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT115)
#define _OMC_LIT116_data "evalRecursionLimit"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT116,18,_OMC_LIT116_data);
#define _OMC_LIT116 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT116)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT117,1,4) {&Flags_FlagVisibility_EXTERNAL__desc,}};
#define _OMC_LIT117 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT117)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT118,2,5) {&Flags_FlagData_INT__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(256))}};
#define _OMC_LIT118 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT118)
#define _OMC_LIT119_data "The recursion limit used when evaluating constant function calls."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT119,65,_OMC_LIT119_data);
#define _OMC_LIT119 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT119)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT120,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(118)),_OMC_LIT116,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT117,_OMC_LIT118,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT119}};
#define _OMC_LIT120 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT120)
#define _OMC_LIT121_data "Const Equation (through Ceval, case 1) "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT121,39,_OMC_LIT121_data);
#define _OMC_LIT121 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT121)
#define _OMC_LIT122_data "Const Equation (through Ceval, case 2) "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT122,39,_OMC_LIT122_data);
#define _OMC_LIT122 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT122)
#define _OMC_LIT123_data "previous"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT123,8,_OMC_LIT123_data);
#define _OMC_LIT123 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT123)
#define _OMC_LIT124_data "change"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT124,6,_OMC_LIT124_data);
#define _OMC_LIT124 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT124)
#define _OMC_LIT125_data "edge"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT125,4,_OMC_LIT125_data);
#define _OMC_LIT125 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT125)
#define _OMC_LIT126_data " checkEqualAlias "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT126,17,_OMC_LIT126_data);
#define _OMC_LIT126 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT126)
#define _OMC_LIT127_data "Model is structurally singular, error found sorting equations\n%s\nfor variables\n%s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT127,81,_OMC_LIT127_data);
#define _OMC_LIT127 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT127)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT128,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(34)),_OMC_LIT88,_OMC_LIT89,_OMC_LIT127}};
#define _OMC_LIT128 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT128)
#define _OMC_LIT129_data " generateSimpleContainter "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT129,26,_OMC_LIT129_data);
#define _OMC_LIT129 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT129)
#define _OMC_LIT130_data "Alias Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT130,15,_OMC_LIT130_data);
#define _OMC_LIT130 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT130)
#define _OMC_LIT131_data " found. Negated lhs["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT131,20,_OMC_LIT131_data);
#define _OMC_LIT131 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT131)
#define _OMC_LIT132_data "true"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT132,4,_OMC_LIT132_data);
#define _OMC_LIT132 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT132)
#define _OMC_LIT133_data "false"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT133,5,_OMC_LIT133_data);
#define _OMC_LIT133 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT133)
#define _OMC_LIT134_data "] = rhs["
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT134,8,_OMC_LIT134_data);
#define _OMC_LIT134 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT134)
#define _OMC_LIT135_data "].\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT135,3,_OMC_LIT135_data);
#define _OMC_LIT135 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT135)
#define _OMC_LIT136_data "Non Alias Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT136,19,_OMC_LIT136_data);
#define _OMC_LIT136 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT136)
#define _OMC_LIT137_data " to generate.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT137,14,_OMC_LIT137_data);
#define _OMC_LIT137 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT137)
#define _OMC_LIT138_data "failtrace"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT138,9,_OMC_LIT138_data);
#define _OMC_LIT138 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT138)
#define _OMC_LIT139_data "Sets whether to print a failtrace or not."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT139,41,_OMC_LIT139_data);
#define _OMC_LIT139 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT139)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT140,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT138,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT139}};
#define _OMC_LIT140 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT140)
#define _OMC_LIT141_data "- BackendDAEOptimize.generateEquation failed on: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT141,49,_OMC_LIT141_data);
#define _OMC_LIT141 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT141)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT142,2,6) {&DAE_Exp_BCONST__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT142 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT142)
#define _OMC_LIT143_data "Failed assertion exp is 0"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT143,25,_OMC_LIT143_data);
#define _OMC_LIT143 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT143)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT144,2,5) {&DAE_Exp_SCONST__desc,_OMC_LIT143}};
#define _OMC_LIT144 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT144)
#define _OMC_LIT145_data "AssertionLevel"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT145,14,_OMC_LIT145_data);
#define _OMC_LIT145 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT145)
#define _OMC_LIT146_data "error"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT146,5,_OMC_LIT146_data);
#define _OMC_LIT146 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT146)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT147,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT146}};
#define _OMC_LIT147 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT147)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT148,3,3) {&Absyn_Path_QUALIFIED__desc,_OMC_LIT145,_OMC_LIT147}};
#define _OMC_LIT148 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT148)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT149,3,8) {&DAE_Exp_ENUM__LITERAL__desc,_OMC_LIT148,MMC_IMMEDIATE(MMC_TAGFIXNUM(2))}};
#define _OMC_LIT149 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT149)
#define _OMC_LIT150_data "Found Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT150,15,_OMC_LIT150_data);
#define _OMC_LIT150 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT150)
#define _OMC_LIT151_data " to handle.\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT151,12,_OMC_LIT151_data);
#define _OMC_LIT151 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT151)
#define _OMC_LIT152_data "Found Array Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT152,21,_OMC_LIT152_data);
#define _OMC_LIT152 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT152)
#define _OMC_LIT153_data "Found Solved Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT153,22,_OMC_LIT153_data);
#define _OMC_LIT153 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT153)
#define _OMC_LIT154_data "Found Residual Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT154,24,_OMC_LIT154_data);
#define _OMC_LIT154 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT154)
#define _OMC_LIT155_data "Found Complex Equation "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT155,23,_OMC_LIT155_data);
#define _OMC_LIT155 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT155)
#define _OMC_LIT156_data "Unreplaceable Crefs:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT156,20,_OMC_LIT156_data);
#define _OMC_LIT156 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT156)
#define _OMC_LIT157_data "The model contains alias variables with redundant start and/or conflicting nominal values. It is recommended to resolve the conflicts, because otherwise the system could be hard to solve. To print the conflicting alias sets and the chosen candidates please use -d=aliasConflicts."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT157,279,_OMC_LIT157_data);
#define _OMC_LIT157 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT157)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT158,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(7017)),_OMC_LIT88,_OMC_LIT65,_OMC_LIT157}};
#define _OMC_LIT158 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT158)
#define _OMC_LIT159_data "maxTraversals"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT159,13,_OMC_LIT159_data);
#define _OMC_LIT159 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT159)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT160,2,5) {&Flags_FlagData_INT__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(2))}};
#define _OMC_LIT160 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT160)
#define _OMC_LIT161_data "Maximal traversals to find simple equations in the acausal system."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT161,66,_OMC_LIT161_data);
#define _OMC_LIT161 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT161)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT162,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(38)),_OMC_LIT159,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT117,_OMC_LIT160,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT161}};
#define _OMC_LIT162 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT162)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT163,1,6) {&BackendDAE_BaseClockPartitionKind_UNSPECIFIED__PARTITION__desc,}};
#define _OMC_LIT163 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT163)
#define _OMC_LIT164_data "fixKnownVarsCausal2 failed for ..."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT164,34,_OMC_LIT164_data);
#define _OMC_LIT164 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT164)
#define _OMC_LIT165_data "fixKnownVarsCausal2 failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT165,26,_OMC_LIT165_data);
#define _OMC_LIT165 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT165)
#define _OMC_LIT166_data "fixAliasVarsCausal2 failed for ..."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT166,34,_OMC_LIT166_data);
#define _OMC_LIT166 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT166)
#define _OMC_LIT167_data "fixAliasVarsCausal2 failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT167,26,_OMC_LIT167_data);
#define _OMC_LIT167 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT167)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT168,1,3) {&Flags_FlagVisibility_INTERNAL__desc,}};
#define _OMC_LIT168 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT168)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT169,2,4) {&Flags_FlagData_BOOL__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT169 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT169)
#define _OMC_LIT170_data "Is true when building an FMU (so the compiler can look for URIs to package as FMI resources)."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT170,93,_OMC_LIT170_data);
#define _OMC_LIT170 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT170)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT171,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(114)),_OMC_LIT1,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT168,_OMC_LIT169,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT170}};
#define _OMC_LIT171 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT171)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT172,1,10) {&BackendDAE_VarKind_PARAM__desc,}};
#define _OMC_LIT172 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT172)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT173,1,11) {&BackendDAE_VarKind_CONST__desc,}};
#define _OMC_LIT173 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT173)
#define _OMC_LIT174_data "Cannot run removeVerySimpleEquations on a matched system (continuing anyway)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT174,76,_OMC_LIT174_data);
#define _OMC_LIT174 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT174)
#define _OMC_LIT175_data "/projects/OpenModelica-session2/OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT175,84,_OMC_LIT175_data);
#define _OMC_LIT175 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT175)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT176_6,1.782113391e9);
#define _OMC_LIT176_6 MMC_REFREALLIT(_OMC_LIT_STRUCT176_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT176,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT175,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(195)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(195)),MMC_IMMEDIATE(MMC_TAGFIXNUM(121)),_OMC_LIT176_6}};
#define _OMC_LIT176 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT176)
#define _OMC_LIT177_data "removeSimpleEquations"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT177,21,_OMC_LIT177_data);
#define _OMC_LIT177 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT177)
#define _OMC_LIT178_data "default"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT178,7,_OMC_LIT178_data);
#define _OMC_LIT178 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT178)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT179,2,8) {&Flags_FlagData_STRING__FLAG__desc,_OMC_LIT178}};
#define _OMC_LIT179 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT179)
#define _OMC_LIT180_data "none"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT180,4,_OMC_LIT180_data);
#define _OMC_LIT180 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT180)
#define _OMC_LIT181_data "Disables module"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT181,15,_OMC_LIT181_data);
#define _OMC_LIT181 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT181)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT182,2,0) {_OMC_LIT180,_OMC_LIT181}};
#define _OMC_LIT182 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT182)
#define _OMC_LIT183_data "Performs alias elimination and removes constant variables. Default case uses in preOpt phase the fastAcausal and in postOpt phase the causal implementation."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT183,156,_OMC_LIT183_data);
#define _OMC_LIT183 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT183)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT184,2,0) {_OMC_LIT178,_OMC_LIT183}};
#define _OMC_LIT184 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT184)
#define _OMC_LIT185_data "causal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT185,6,_OMC_LIT185_data);
#define _OMC_LIT185 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT185)
#define _OMC_LIT186_data "Performs alias elimination and removes constant variables. Causal implementation."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT186,81,_OMC_LIT186_data);
#define _OMC_LIT186 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT186)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT187,2,0) {_OMC_LIT185,_OMC_LIT186}};
#define _OMC_LIT187 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT187)
#define _OMC_LIT188_data "fastAcausal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT188,11,_OMC_LIT188_data);
#define _OMC_LIT188 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT188)
#define _OMC_LIT189_data "Performs alias elimination and removes constant variables. fastImplementation fastAcausal."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT189,90,_OMC_LIT189_data);
#define _OMC_LIT189 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT189)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT190,2,0) {_OMC_LIT188,_OMC_LIT189}};
#define _OMC_LIT190 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT190)
#define _OMC_LIT191_data "allAcausal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT191,10,_OMC_LIT191_data);
#define _OMC_LIT191 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT191)
#define _OMC_LIT192_data "Performs alias elimination and removes constant variables. Implementation allAcausal."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT192,85,_OMC_LIT192_data);
#define _OMC_LIT192 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT192)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT193,2,0) {_OMC_LIT191,_OMC_LIT192}};
#define _OMC_LIT193 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT193)
#define _OMC_LIT194_data "new"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT194,3,_OMC_LIT194_data);
#define _OMC_LIT194 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT194)
#define _OMC_LIT195_data "New implementation (experimental)"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT195,33,_OMC_LIT195_data);
#define _OMC_LIT195 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT195)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT196,2,0) {_OMC_LIT194,_OMC_LIT195}};
#define _OMC_LIT196 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT196)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT197,2,1) {_OMC_LIT196,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT197 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT197)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT198,2,1) {_OMC_LIT193,_OMC_LIT197}};
#define _OMC_LIT198 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT198)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT199,2,1) {_OMC_LIT190,_OMC_LIT198}};
#define _OMC_LIT199 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT199)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT200,2,1) {_OMC_LIT187,_OMC_LIT199}};
#define _OMC_LIT200 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT200)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT201,2,1) {_OMC_LIT184,_OMC_LIT200}};
#define _OMC_LIT201 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT201)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT202,2,1) {_OMC_LIT182,_OMC_LIT201}};
#define _OMC_LIT202 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT202)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT203,2,4) {&Flags_ValidOptions_STRING__DESC__OPTION__desc,_OMC_LIT202}};
#define _OMC_LIT203 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT203)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT204,1,1) {_OMC_LIT203}};
#define _OMC_LIT204 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT204)
#define _OMC_LIT205_data "Specifies method that removes simple equations."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT205,47,_OMC_LIT205_data);
#define _OMC_LIT205 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT205)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT206,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(59)),_OMC_LIT177,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT117,_OMC_LIT179,_OMC_LIT204,_OMC_LIT205}};
#define _OMC_LIT206 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT206)
#include "util/modelica.h"

#include "RemoveSimpleEquations_includes.h"


/* default, do not make protected functions static */
#if !defined(PROTECTED_FUNCTION_STATIC)
#define PROTECTED_FUNCTION_STATIC
#endif
PROTECTED_FUNCTION_STATIC modelica_string omc_RemoveSimpleEquations_dumpSimpleContainer(threadData_t *threadData, modelica_metatype _container);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_dumpSimpleContainer,2,0) {(void*) boxptr_RemoveSimpleEquations_dumpSimpleContainer,0}};
#define boxvar_RemoveSimpleEquations_dumpSimpleContainer MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_dumpSimpleContainer)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getDominantAttributeValue(threadData_t *threadData, modelica_metatype _tplExpIndList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getDominantAttributeValue,2,0) {(void*) boxptr_RemoveSimpleEquations_getDominantAttributeValue,0}};
#define boxvar_RemoveSimpleEquations_getDominantAttributeValue MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getDominantAttributeValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getThisAttributes(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _cr_eq_lst, modelica_metatype _inAliasVars, modelica_metatype _inHTStartExpToInt, modelica_metatype _inHTNominalExpToInt, modelica_metatype *out_outHTNominalExpToInt);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getThisAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_getThisAttributes,0}};
#define boxvar_RemoveSimpleEquations_getThisAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getThisAttributes)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_setAttributes(threadData_t *threadData, modelica_metatype _tplCrEqLst, modelica_metatype _inVars, modelica_metatype _inAliasVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_setAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_setAttributes,0}};
#define boxvar_RemoveSimpleEquations_setAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_setAttributes)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasAttributes(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype *out_outShared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_getAliasAttributes,0}};
#define boxvar_RemoveSimpleEquations_getAliasAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasAttributes)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_determineAliasLst(threadData_t *threadData, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _inHTAliasLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_determineAliasLst,2,0) {(void*) boxptr_RemoveSimpleEquations_determineAliasLst,0}};
#define boxvar_RemoveSimpleEquations_determineAliasLst MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_determineAliasLst)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_checkOp(threadData_t *threadData, modelica_metatype _inOp);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_checkOp(threadData_t *threadData, modelica_metatype _inOp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkOp,2,0) {(void*) boxptr_RemoveSimpleEquations_checkOp,0}};
#define boxvar_RemoveSimpleEquations_checkOp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkOp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_checkOperator(threadData_t *threadData, modelica_metatype _inExp, modelica_boolean _inIsSimple, modelica_boolean *out_cont, modelica_boolean *out_outIsSimple);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_checkOperator(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inIsSimple, modelica_metatype *out_cont, modelica_metatype *out_outIsSimple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkOperator,2,0) {(void*) boxptr_RemoveSimpleEquations_checkOperator,0}};
#define boxvar_RemoveSimpleEquations_checkOperator MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkOperator)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isSimple(threadData_t *threadData, modelica_metatype _inExp);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isSimple(threadData_t *threadData, modelica_metatype _inExp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isSimple,2,0) {(void*) boxptr_RemoveSimpleEquations_isSimple,0}};
#define boxvar_RemoveSimpleEquations_isSimple MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isSimple)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addThisCrefs(threadData_t *threadData, modelica_metatype _cr_eq_lst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addThisCrefs,2,0) {(void*) boxptr_RemoveSimpleEquations_addThisCrefs,0}};
#define boxvar_RemoveSimpleEquations_addThisCrefs MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addThisCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addRestCrefs(threadData_t *threadData, modelica_metatype _tplCrEqLst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addRestCrefs,2,0) {(void*) boxptr_RemoveSimpleEquations_addRestCrefs,0}};
#define boxvar_RemoveSimpleEquations_addRestCrefs MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addRestCrefs)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isCrefInValue(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isCrefInValue(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isCrefInValue,2,0) {(void*) boxptr_RemoveSimpleEquations_isCrefInValue,0}};
#define boxvar_RemoveSimpleEquations_isCrefInValue MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isCrefInValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveAllCrefs1(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value, modelica_metatype _cr_eq_lst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveAllCrefs1,2,0) {(void*) boxptr_RemoveSimpleEquations_solveAllCrefs1,0}};
#define boxvar_RemoveSimpleEquations_solveAllCrefs1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveAllCrefs1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveAllCrefs(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveAllCrefs,2,0) {(void*) boxptr_RemoveSimpleEquations_solveAllCrefs,0}};
#define boxvar_RemoveSimpleEquations_solveAllCrefs MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveAllCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addToCrToExp(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _eq, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addToCrToExp,2,0) {(void*) boxptr_RemoveSimpleEquations_addToCrToExp,0}};
#define boxvar_RemoveSimpleEquations_addToCrToExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addToCrToExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addToCrAndEqLists(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _eq, modelica_metatype _inHTCrToCrEqLst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addToCrAndEqLists,2,0) {(void*) boxptr_RemoveSimpleEquations_addToCrAndEqLists,0}};
#define boxvar_RemoveSimpleEquations_addToCrAndEqLists MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addToCrAndEqLists)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_findCrefs(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inTuple, modelica_boolean *out_cont, modelica_metatype *out_outTuple);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_findCrefs(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inTuple, modelica_metatype *out_cont, modelica_metatype *out_outTuple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_findCrefs,2,0) {(void*) boxptr_RemoveSimpleEquations_findCrefs,0}};
#define boxvar_RemoveSimpleEquations_findCrefs MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_findCrefs)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_findSimpleEquations(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTuple, modelica_boolean _findAliases, modelica_metatype *out_outTuple);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_findSimpleEquations(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTuple, modelica_metatype _findAliases, modelica_metatype *out_outTuple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_findSimpleEquations,2,0) {(void*) boxptr_RemoveSimpleEquations_findSimpleEquations,0}};
#define boxvar_RemoveSimpleEquations_findSimpleEquations MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_findSimpleEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeStateDerInfo(threadData_t *threadData, modelica_metatype _inVarList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeStateDerInfo,2,0) {(void*) boxptr_RemoveSimpleEquations_removeStateDerInfo,0}};
#define boxvar_RemoveSimpleEquations_removeStateDerInfo MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeStateDerInfo)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_insertReplacementsInEquations(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inHTCrToExp, modelica_boolean *out_cont, modelica_metatype *out_outHTCrToExp);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_insertReplacementsInEquations(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inHTCrToExp, modelica_metatype *out_cont, modelica_metatype *out_outHTCrToExp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_insertReplacementsInEquations,2,0) {(void*) boxptr_RemoveSimpleEquations_insertReplacementsInEquations,0}};
#define boxvar_RemoveSimpleEquations_insertReplacementsInEquations MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_insertReplacementsInEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseExpTopDown(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inHTCrToExp, modelica_metatype *out_outHTCrToExp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseExpTopDown,2,0) {(void*) boxptr_RemoveSimpleEquations_traverseExpTopDown,0}};
#define boxvar_RemoveSimpleEquations_traverseExpTopDown MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseExpTopDown)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addVarReplacements(threadData_t *threadData, modelica_metatype _cr_exp_lst, modelica_metatype _inRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addVarReplacements,2,0) {(void*) boxptr_RemoveSimpleEquations_addVarReplacements,0}};
#define boxvar_RemoveSimpleEquations_addVarReplacements MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addVarReplacements)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_moveVars(threadData_t *threadData, modelica_metatype _cr_exp_lst, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype *out_outVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_moveVars,2,0) {(void*) boxptr_RemoveSimpleEquations_moveVars,0}};
#define boxvar_RemoveSimpleEquations_moveVars MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_moveVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_eliminateTrivialEquations(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_boolean _findAliases, modelica_metatype *out_outShared);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_eliminateTrivialEquations(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _findAliases, modelica_metatype *out_outShared);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_eliminateTrivialEquations,2,0) {(void*) boxptr_RemoveSimpleEquations_eliminateTrivialEquations,0}};
#define boxvar_RemoveSimpleEquations_eliminateTrivialEquations MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_eliminateTrivialEquations)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_performAliasEliminationBB(threadData_t *threadData, modelica_metatype _inDAE, modelica_boolean _findAliases);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_performAliasEliminationBB(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _findAliases);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_performAliasEliminationBB,2,0) {(void*) boxptr_RemoveSimpleEquations_performAliasEliminationBB,0}};
#define boxvar_RemoveSimpleEquations_performAliasEliminationBB MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_performAliasEliminationBB)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_negateExpression(threadData_t *threadData, modelica_boolean _negationFlag, modelica_metatype _inExp, modelica_metatype _inAlternative, modelica_string _message);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_negateExpression(threadData_t *threadData, modelica_metatype _negationFlag, modelica_metatype _inExp, modelica_metatype _inAlternative, modelica_metatype _message);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_negateExpression,2,0) {(void*) boxptr_RemoveSimpleEquations_negateExpression,0}};
#define boxvar_RemoveSimpleEquations_negateExpression MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_negateExpression)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseCrefUnreplaceable(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _preCref, modelica_metatype _iUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseCrefUnreplaceable,2,0) {(void*) boxptr_RemoveSimpleEquations_traverseCrefUnreplaceable,0}};
#define boxvar_RemoveSimpleEquations_traverseCrefUnreplaceable MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseCrefUnreplaceable)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverserExpUnreplaceable(threadData_t *threadData, modelica_metatype _e, modelica_metatype _unReplaceable, modelica_metatype *out_outHt);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverserExpUnreplaceable,2,0) {(void*) boxptr_RemoveSimpleEquations_traverserExpUnreplaceable,0}};
#define boxvar_RemoveSimpleEquations_traverserExpUnreplaceable MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverserExpUnreplaceable)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenOps(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_metatype _iHs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenOps,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhenOps,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhenOps MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenOps)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhen(threadData_t *threadData, modelica_metatype _inWEqn, modelica_metatype _iHs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhen,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhen,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhen MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhen)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStmt(threadData_t *threadData, modelica_metatype _inStmt, modelica_metatype _inHS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStmt,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromStmt,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromStmt MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStmt)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenStmt(threadData_t *threadData, modelica_metatype _inStmt, modelica_metatype _inHS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenStmt,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhenStmt,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhenStmt MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenStmt)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenEqn(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inHs, modelica_metatype *out_hs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenEqn,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhenEqn,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhenEqn MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhenEqn)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhensSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhensSystem,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhensSystem,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhensSystem MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhensSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromEqnsExp(threadData_t *threadData, modelica_metatype _e, modelica_metatype _hs, modelica_metatype *out_ohs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromEqnsExp,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromEqnsExp,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromEqnsExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromEqnsExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhens(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhens,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromWhens,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromWhens MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromWhens)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSet(threadData_t *threadData, modelica_metatype _iStateSet, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSet,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromStateSet,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromStateSet MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSet)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSets(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSets,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceableFromStateSets,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceableFromStateSets MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceableFromStateSets)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData_t *threadData, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptExprTraverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceOptExprTraverser,0}};
#define boxvar_RemoveSimpleEquations_replaceOptExprTraverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptExprTraverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceExprTraverser(threadData_t *threadData, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceExprTraverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceExprTraverser,0}};
#define boxvar_RemoveSimpleEquations_replaceExprTraverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceExprTraverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceEquationTraverser(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceEquationTraverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceEquationTraverser,0}};
#define boxvar_RemoveSimpleEquations_replaceEquationTraverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceEquationTraverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasVarReplacements(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inRepl, modelica_metatype *out_repl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasVarReplacements,2,0) {(void*) boxptr_RemoveSimpleEquations_getAliasVarReplacements,0}};
#define boxvar_RemoveSimpleEquations_getAliasVarReplacements MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasVarReplacements)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasReplacements(threadData_t *threadData, modelica_metatype _iStatesetrepl, modelica_metatype _aliasVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasReplacements,2,0) {(void*) boxptr_RemoveSimpleEquations_getAliasReplacements,0}};
#define boxvar_RemoveSimpleEquations_getAliasReplacements MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAliasReplacements)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptimicaContraints(threadData_t *threadData, modelica_metatype _icontraints, modelica_metatype _irepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptimicaContraints,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceOptimicaContraints,0}};
#define boxvar_RemoveSimpleEquations_replaceOptimicaContraints MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptimicaContraints)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptimicaExps(threadData_t *threadData, modelica_metatype _icontraints, modelica_metatype _iclassAttributes, modelica_metatype _irepl, modelica_metatype *out_oclassAttributes);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptimicaExps,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceOptimicaExps,0}};
#define boxvar_RemoveSimpleEquations_replaceOptimicaExps MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOptimicaExps)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData_t *threadData, modelica_metatype _iVarLst, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _hs, modelica_metatype _iAcc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOtherStateSetVars,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceOtherStateSetVars,0}};
#define boxvar_RemoveSimpleEquations_replaceOtherStateSetVars MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceOtherStateSetVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeEqualLshRshEqns(threadData_t *threadData, modelica_metatype _iEqn, modelica_metatype _iEqns);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeEqualLshRshEqns,2,0) {(void*) boxptr_RemoveSimpleEquations_removeEqualLshRshEqns,0}};
#define boxvar_RemoveSimpleEquations_removeEqualLshRshEqns MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeEqualLshRshEqns)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeAliasVarsStateSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iStatesetrepl, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _iAcc, modelica_boolean _inB, modelica_boolean *out_outB, modelica_metatype *out_oStatesetrepl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_removeAliasVarsStateSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iStatesetrepl, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _iAcc, modelica_metatype _inB, modelica_metatype *out_outB, modelica_metatype *out_oStatesetrepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeAliasVarsStateSets,2,0) {(void*) boxptr_RemoveSimpleEquations_removeAliasVarsStateSets,0}};
#define boxvar_RemoveSimpleEquations_removeAliasVarsStateSets MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeAliasVarsStateSets)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeSimpleEquationsShared1(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inSysts1, modelica_metatype _repl, modelica_metatype _statesetrepl, modelica_metatype _aliasVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeSimpleEquationsShared1,2,0) {(void*) boxptr_RemoveSimpleEquations_removeSimpleEquationsShared1,0}};
#define boxvar_RemoveSimpleEquations_removeSimpleEquationsShared1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeSimpleEquationsShared1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceVarTraverser(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inRepl, modelica_metatype *out_repl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceVarTraverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceVarTraverser,0}};
#define boxvar_RemoveSimpleEquations_replaceVarTraverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceVarTraverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceAliasVarTraverser(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceAliasVarTraverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceAliasVarTraverser,0}};
#define boxvar_RemoveSimpleEquations_replaceAliasVarTraverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceAliasVarTraverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasConstBindings1(threadData_t *threadData, modelica_metatype _iCr, modelica_metatype _iExp, modelica_metatype _iAVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasConstBindings1,2,0) {(void*) boxptr_RemoveSimpleEquations_fixAliasConstBindings1,0}};
#define boxvar_RemoveSimpleEquations_fixAliasConstBindings1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasConstBindings1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasConstBindings(threadData_t *threadData, modelica_metatype _iAVar, modelica_metatype _iAVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasConstBindings,2,0) {(void*) boxptr_RemoveSimpleEquations_fixAliasConstBindings,0}};
#define boxvar_RemoveSimpleEquations_fixAliasConstBindings MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasConstBindings)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData_t *threadData, modelica_boolean _b, modelica_metatype _inDAE, modelica_metatype _repl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_removeSimpleEquationsShared(threadData_t *threadData, modelica_metatype _b, modelica_metatype _inDAE, modelica_metatype _repl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeSimpleEquationsShared,2,0) {(void*) boxptr_RemoveSimpleEquations_removeSimpleEquationsShared,0}};
#define boxvar_RemoveSimpleEquations_removeSimpleEquationsShared MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_removeSimpleEquationsShared)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateStateOrder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateStateOrder,2,0) {(void*) boxptr_RemoveSimpleEquations_updateStateOrder,0}};
#define boxvar_RemoveSimpleEquations_updateStateOrder MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateStateOrder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_oTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateVar,2,0) {(void*) boxptr_RemoveSimpleEquations_updateVar,0}};
#define boxvar_RemoveSimpleEquations_updateVar MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateSystem(threadData_t *threadData, modelica_boolean _foundSimple, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _repl, modelica_metatype _isyst);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_updateSystem(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _repl, modelica_metatype _isyst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateSystem,2,0) {(void*) boxptr_RemoveSimpleEquations_updateSystem,0}};
#define boxvar_RemoveSimpleEquations_updateSystem MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_updateSystem)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectMinDepth(threadData_t *threadData, modelica_metatype _e, modelica_metatype _inMin, modelica_boolean *out_cont, modelica_metatype *out_outMin);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_selectMinDepth(threadData_t *threadData, modelica_metatype _e, modelica_metatype _inMin, modelica_metatype *out_cont, modelica_metatype *out_outMin);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectMinDepth,2,0) {(void*) boxptr_RemoveSimpleEquations_selectMinDepth,0}};
#define boxvar_RemoveSimpleEquations_selectMinDepth MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectMinDepth)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectFreeValue1(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _iFavorit, modelica_string _iStr, modelica_string _iAttributeName, modelica_fnptr _inFunc, modelica_metatype _inVar, modelica_metatype _globalKnownVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectFreeValue1,2,0) {(void*) boxptr_RemoveSimpleEquations_selectFreeValue1,0}};
#define boxvar_RemoveSimpleEquations_selectFreeValue1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectFreeValue1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectNonZeroExpression(threadData_t *threadData, modelica_metatype _iFavorit);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectNonZeroExpression,2,0) {(void*) boxptr_RemoveSimpleEquations_selectNonZeroExpression,0}};
#define boxvar_RemoveSimpleEquations_selectNonZeroExpression MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectNonZeroExpression)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectFreeValue(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_selectFreeValue(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectFreeValue,2,0) {(void*) boxptr_RemoveSimpleEquations_selectFreeValue,0}};
#define boxvar_RemoveSimpleEquations_selectFreeValue MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_selectFreeValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getZeroFreeValues(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _iAcc);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getZeroFreeValues,2,0) {(void*) boxptr_RemoveSimpleEquations_getZeroFreeValues,0}};
#define boxvar_RemoveSimpleEquations_getZeroFreeValues MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getZeroFreeValues)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *threadData, modelica_metatype _exp, modelica_boolean _replaced, modelica_metatype _vars, modelica_metatype _replacedCrefs, modelica_boolean *out_outReplaced);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _replaced, modelica_metatype _vars, modelica_metatype _replacedCrefs, modelica_metatype *out_outReplaced);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceCrefWithBindExp__traverser,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceCrefWithBindExp__traverser,0}};
#define boxvar_RemoveSimpleEquations_replaceCrefWithBindExp__traverser MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceCrefWithBindExp__traverser)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _vars, modelica_boolean *out_replaced);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _vars, modelica_metatype *out_replaced);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceCrefWithBindExp,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceCrefWithBindExp,0}};
#define boxvar_RemoveSimpleEquations_replaceCrefWithBindExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceCrefWithBindExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_equalFreeStartValues(threadData_t *threadData, modelica_metatype _iValues, modelica_metatype _globalKnownVars, modelica_metatype _iValue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_equalFreeStartValues,2,0) {(void*) boxptr_RemoveSimpleEquations_equalFreeStartValues,0}};
#define boxvar_RemoveSimpleEquations_equalFreeStartValues MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_equalFreeStartValues)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_equalNonFreeStartValues(threadData_t *threadData, modelica_metatype _iValues, modelica_metatype _globalKnownVars, modelica_metatype _iValue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_equalNonFreeStartValues,2,0) {(void*) boxptr_RemoveSimpleEquations_equalNonFreeStartValues,0}};
#define boxvar_RemoveSimpleEquations_equalNonFreeStartValues MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_equalNonFreeStartValues)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_optExpReplaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _iOExp, modelica_metatype _globalKnownVars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_optExpReplaceCrefWithBindExp,2,0) {(void*) boxptr_RemoveSimpleEquations_optExpReplaceCrefWithBindExp,0}};
#define boxvar_RemoveSimpleEquations_optExpReplaceCrefWithBindExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_optExpReplaceCrefWithBindExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleVarSetAttributes(threadData_t *threadData, modelica_metatype _inAttributes, modelica_metatype _inVar, modelica_metatype _inVars, modelica_metatype _inShared, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleVarSetAttributes(threadData_t *threadData, modelica_metatype _inAttributes, modelica_metatype _inVar, modelica_metatype _inVars, modelica_metatype _inShared, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleVarSetAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_handleVarSetAttributes,0}};
#define boxvar_RemoveSimpleEquations_handleVarSetAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleVarSetAttributes)
PROTECTED_FUNCTION_STATIC void omc_RemoveSimpleEquations_checkMinMax(threadData_t *threadData, modelica_metatype _minmax, modelica_integer _mark, modelica_metatype _simpleeqnsarr);
PROTECTED_FUNCTION_STATIC void boxptr_RemoveSimpleEquations_checkMinMax(threadData_t *threadData, modelica_metatype _minmax, modelica_metatype _mark, modelica_metatype _simpleeqnsarr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkMinMax,2,0) {(void*) boxptr_RemoveSimpleEquations_checkMinMax,0}};
#define boxvar_RemoveSimpleEquations_checkMinMax MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkMinMax)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeMinMax1(threadData_t *threadData, modelica_metatype _ominmax, modelica_metatype _ominmax1);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeMinMax1,2,0) {(void*) boxptr_RemoveSimpleEquations_mergeMinMax1,0}};
#define boxvar_RemoveSimpleEquations_mergeMinMax1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeMinMax1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeMinMax(threadData_t *threadData, modelica_boolean _negate, modelica_metatype _ominmax, modelica_metatype _ominmax1, modelica_integer _mark, modelica_metatype _simpleeqnsarr);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeMinMax(threadData_t *threadData, modelica_metatype _negate, modelica_metatype _ominmax, modelica_metatype _ominmax1, modelica_metatype _mark, modelica_metatype _simpleeqnsarr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeMinMax,2,0) {(void*) boxptr_RemoveSimpleEquations_mergeMinMax,0}};
#define boxvar_RemoveSimpleEquations_mergeMinMax MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeMinMax)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addMinMaxAttribute(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMinMax);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addMinMaxAttribute(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMinMax);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addMinMaxAttribute,2,0) {(void*) boxptr_RemoveSimpleEquations_addMinMaxAttribute,0}};
#define boxvar_RemoveSimpleEquations_addMinMaxAttribute MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addMinMaxAttribute)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeNominalAttribute(threadData_t *threadData, modelica_metatype _nominalList, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeNominalAttribute(threadData_t *threadData, modelica_metatype _nominalList, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeNominalAttribute,2,0) {(void*) boxptr_RemoveSimpleEquations_mergeNominalAttribute,0}};
#define boxvar_RemoveSimpleEquations_mergeNominalAttribute MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeNominalAttribute)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addNominalValue(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _iNominal);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addNominalValue,2,0) {(void*) boxptr_RemoveSimpleEquations_addNominalValue,0}};
#define boxvar_RemoveSimpleEquations_addNominalValue MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addNominalValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeStartFixedAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _fixed, modelica_metatype _startvalues, modelica_metatype _ishared, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeStartFixedAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _fixed, modelica_metatype _startvalues, modelica_metatype _ishared, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeStartFixedAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_mergeStartFixedAttributes,0}};
#define boxvar_RemoveSimpleEquations_mergeStartFixedAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_mergeStartFixedAttributes)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_addStartValue(threadData_t *threadData, modelica_boolean _fixed, modelica_boolean _fixedset, modelica_metatype _cr, modelica_metatype _start, modelica_metatype _origin, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iStartvalues, modelica_metatype *out_oStartvalues);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addStartValue(threadData_t *threadData, modelica_metatype _fixed, modelica_metatype _fixedset, modelica_metatype _cr, modelica_metatype _start, modelica_metatype _origin, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iStartvalues, modelica_metatype *out_oStartvalues);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addStartValue,2,0) {(void*) boxptr_RemoveSimpleEquations_addStartValue,0}};
#define boxvar_RemoveSimpleEquations_addStartValue MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addStartValue)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addVarSetAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iAttributes);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addVarSetAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iAttributes);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addVarSetAttributes,2,0) {(void*) boxptr_RemoveSimpleEquations_addVarSetAttributes,0}};
#define boxvar_RemoveSimpleEquations_addVarSetAttributes MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addVarSetAttributes)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addSubstitutionOption(threadData_t *threadData, modelica_metatype _optExp, modelica_metatype _exp, modelica_metatype __omcQ_24in_5Fsource);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addSubstitutionOption,2,0) {(void*) boxptr_RemoveSimpleEquations_addSubstitutionOption,0}};
#define boxvar_RemoveSimpleEquations_addSubstitutionOption MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addSubstitutionOption)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_negateOptExp(threadData_t *threadData, modelica_metatype _iExp);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_negateOptExp,2,0) {(void*) boxptr_RemoveSimpleEquations_negateOptExp,0}};
#define boxvar_RemoveSimpleEquations_negateOptExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_negateOptExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseAliasTree1(threadData_t *threadData, modelica_metatype _sc, modelica_integer _r, modelica_integer _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_boolean _globalnegated, modelica_metatype _derReplaceState, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traverseAliasTree1(threadData_t *threadData, modelica_metatype _sc, modelica_metatype _r, modelica_metatype _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_metatype _globalnegated, modelica_metatype _derReplaceState, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseAliasTree1,2,0) {(void*) boxptr_RemoveSimpleEquations_traverseAliasTree1,0}};
#define boxvar_RemoveSimpleEquations_traverseAliasTree1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseAliasTree1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseAliasTree(threadData_t *threadData, modelica_metatype _rows, modelica_integer _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_boolean _globalnegate, modelica_metatype _derReplaceState, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traverseAliasTree(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_metatype _globalnegate, modelica_metatype _derReplaceState, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseAliasTree,2,0) {(void*) boxptr_RemoveSimpleEquations_traverseAliasTree,0}};
#define boxvar_RemoveSimpleEquations_traverseAliasTree MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseAliasTree)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_moveVarShared(threadData_t *threadData, modelica_metatype _v, modelica_integer _i, modelica_metatype _source, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype *out_oshared, modelica_boolean *out_bs);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_moveVarShared(threadData_t *threadData, modelica_metatype _v, modelica_metatype _i, modelica_metatype _source, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype *out_oshared, modelica_metatype *out_bs);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_moveVarShared,2,0) {(void*) boxptr_RemoveSimpleEquations_moveVarShared,0}};
#define boxvar_RemoveSimpleEquations_moveVarShared MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_moveVarShared)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_optMoveVarShared(threadData_t *threadData, modelica_boolean _replaceable_, modelica_metatype _v, modelica_integer _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iEqnslst, modelica_metatype *out_oshared, modelica_boolean *out_bs, modelica_metatype *out_oEqnslst);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_optMoveVarShared(threadData_t *threadData, modelica_metatype _replaceable_, modelica_metatype _v, modelica_metatype _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_bs, modelica_metatype *out_oEqnslst);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_optMoveVarShared,2,0) {(void*) boxptr_RemoveSimpleEquations_optMoveVarShared,0}};
#define boxvar_RemoveSimpleEquations_optMoveVarShared MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_optMoveVarShared)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addDerConstRepl(threadData_t *threadData, modelica_boolean _state, modelica_metatype _derConstRepl, modelica_metatype _cr, modelica_metatype _iRepl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addDerConstRepl(threadData_t *threadData, modelica_metatype _state, modelica_metatype _derConstRepl, modelica_metatype _cr, modelica_metatype _iRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addDerConstRepl,2,0) {(void*) boxptr_RemoveSimpleEquations_addDerConstRepl,0}};
#define boxvar_RemoveSimpleEquations_addDerConstRepl MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addDerConstRepl)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSetVar(threadData_t *threadData, modelica_boolean _replaceable_, modelica_metatype _derReplaceState, modelica_metatype _v, modelica_integer _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSetVar(threadData_t *threadData, modelica_metatype _replaceable_, modelica_metatype _derReplaceState, modelica_metatype _v, modelica_metatype _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSetVar,2,0) {(void*) boxptr_RemoveSimpleEquations_handleSetVar,0}};
#define boxvar_RemoveSimpleEquations_handleSetVar MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSetVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_varStateDerivative(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_varStateDerivative,2,0) {(void*) boxptr_RemoveSimpleEquations_varStateDerivative,0}};
#define boxvar_RemoveSimpleEquations_varStateDerivative MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_varStateDerivative)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSet(threadData_t *threadData, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSet(threadData_t *threadData, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSet,2,0) {(void*) boxptr_RemoveSimpleEquations_handleSet,0}};
#define boxvar_RemoveSimpleEquations_handleSet MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSet)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_replaceableAlias(threadData_t *threadData, modelica_metatype _var, modelica_metatype _unReplaceable, modelica_boolean *out_res1);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceableAlias(threadData_t *threadData, modelica_metatype _var, modelica_metatype _unReplaceable, modelica_metatype *out_res1);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceableAlias,2,0) {(void*) boxptr_RemoveSimpleEquations_replaceableAlias,0}};
#define boxvar_RemoveSimpleEquations_replaceableAlias MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_replaceableAlias)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_setVisited(threadData_t *threadData, modelica_integer _visited, modelica_metatype _iS);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_setVisited(threadData_t *threadData, modelica_metatype _visited, modelica_metatype _iS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_setVisited,2,0) {(void*) boxptr_RemoveSimpleEquations_setVisited,0}};
#define boxvar_RemoveSimpleEquations_setVisited MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_setVisited)
PROTECTED_FUNCTION_STATIC modelica_integer omc_RemoveSimpleEquations_getVisited(threadData_t *threadData, modelica_metatype _iS);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getVisited(threadData_t *threadData, modelica_metatype _iS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVisited,2,0) {(void*) boxptr_RemoveSimpleEquations_getVisited,0}};
#define boxvar_RemoveSimpleEquations_getVisited MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVisited)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isVisited(threadData_t *threadData, modelica_integer _mark, modelica_metatype _iS);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isVisited(threadData_t *threadData, modelica_metatype _mark, modelica_metatype _iS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isVisited,2,0) {(void*) boxptr_RemoveSimpleEquations_isVisited,0}};
#define boxvar_RemoveSimpleEquations_isVisited MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_isVisited)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias3(threadData_t *threadData, modelica_metatype _var, modelica_integer _i, modelica_boolean _state, modelica_boolean _replaceable_, modelica_integer _r, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias3(threadData_t *threadData, modelica_metatype _var, modelica_metatype _i, modelica_metatype _state, modelica_metatype _replaceable_, modelica_metatype _r, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias3,2,0) {(void*) boxptr_RemoveSimpleEquations_getAlias3,0}};
#define boxvar_RemoveSimpleEquations_getAlias3 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias3)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias2(threadData_t *threadData, modelica_metatype _containerIn, modelica_integer _currIdx, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias2(threadData_t *threadData, modelica_metatype _containerIn, modelica_metatype _currIdx, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias2,2,0) {(void*) boxptr_RemoveSimpleEquations_getAlias2,0}};
#define boxvar_RemoveSimpleEquations_getAlias2 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVarsNames(threadData_t *threadData, modelica_metatype _iS);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVarsNames,2,0) {(void*) boxptr_RemoveSimpleEquations_getVarsNames,0}};
#define boxvar_RemoveSimpleEquations_getVarsNames MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVarsNames)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData_t *threadData, modelica_metatype _stack, modelica_integer _iR, modelica_metatype _simpleeqnsarr);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData_t *threadData, modelica_metatype _stack, modelica_metatype _iR, modelica_metatype _simpleeqnsarr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_circularEqualityMsg__dispatch,2,0) {(void*) boxptr_RemoveSimpleEquations_circularEqualityMsg__dispatch,0}};
#define boxvar_RemoveSimpleEquations_circularEqualityMsg__dispatch MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_circularEqualityMsg__dispatch)
PROTECTED_FUNCTION_STATIC modelica_string omc_RemoveSimpleEquations_circularEqualityMsg(threadData_t *threadData, modelica_metatype _stack, modelica_integer _iR, modelica_metatype _simpleeqnsarr, modelica_string _iMsg);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_circularEqualityMsg(threadData_t *threadData, modelica_metatype _stack, modelica_metatype _iR, modelica_metatype _simpleeqnsarr, modelica_metatype _iMsg);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_circularEqualityMsg,2,0) {(void*) boxptr_RemoveSimpleEquations_circularEqualityMsg,0}};
#define boxvar_RemoveSimpleEquations_circularEqualityMsg MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_circularEqualityMsg)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias1(threadData_t *threadData, modelica_boolean _visited, modelica_metatype _containerIn, modelica_integer _currIdx, modelica_metatype _rows, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias1(threadData_t *threadData, modelica_metatype _visited, modelica_metatype _containerIn, modelica_metatype _currIdx, modelica_metatype _rows, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias1,2,0) {(void*) boxptr_RemoveSimpleEquations_getAlias1,0}};
#define boxvar_RemoveSimpleEquations_getAlias1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias,2,0) {(void*) boxptr_RemoveSimpleEquations_getAlias,0}};
#define boxvar_RemoveSimpleEquations_getAlias MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getAlias)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSets(threadData_t *threadData, modelica_integer _containerIdx, modelica_integer _inMark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype __omcQ_24in_5Fvars, modelica_metatype __omcQ_24in_5Feqnslst, modelica_metatype __omcQ_24in_5Fshared, modelica_metatype __omcQ_24in_5Frepl, modelica_metatype *out_eqnslst, modelica_metatype *out_shared, modelica_metatype *out_repl, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSets(threadData_t *threadData, modelica_metatype _containerIdx, modelica_metatype _inMark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype __omcQ_24in_5Fvars, modelica_metatype __omcQ_24in_5Feqnslst, modelica_metatype __omcQ_24in_5Fshared, modelica_metatype __omcQ_24in_5Frepl, modelica_metatype *out_eqnslst, modelica_metatype *out_shared, modelica_metatype *out_repl, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSets,2,0) {(void*) boxptr_RemoveSimpleEquations_handleSets,0}};
#define boxvar_RemoveSimpleEquations_handleSets MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_handleSets)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_aliasExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype *out_outCr);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_aliasExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype *out_outCr);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_aliasExp,2,0) {(void*) boxptr_RemoveSimpleEquations_aliasExp,0}};
#define boxvar_RemoveSimpleEquations_aliasExp MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_aliasExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_constOrAliasAcausal(threadData_t *threadData, modelica_metatype _var, modelica_integer _i, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_constOrAliasAcausal(threadData_t *threadData, modelica_metatype _var, modelica_metatype _i, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_constOrAliasAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_constOrAliasAcausal,0}};
#define boxvar_RemoveSimpleEquations_constOrAliasAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_constOrAliasAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_constOrAliasArrayAcausal(threadData_t *threadData, modelica_metatype _vars, modelica_metatype _indxs, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_constOrAliasArrayAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_constOrAliasArrayAcausal,0}};
#define boxvar_RemoveSimpleEquations_constOrAliasArrayAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_constOrAliasArrayAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveTimeIndependentAcausal1(threadData_t *threadData, modelica_metatype _vlst, modelica_metatype _ilst, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveTimeIndependentAcausal1,2,0) {(void*) boxptr_RemoveSimpleEquations_solveTimeIndependentAcausal1,0}};
#define boxvar_RemoveSimpleEquations_solveTimeIndependentAcausal1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveTimeIndependentAcausal1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveTimeIndependentAcausal(threadData_t *threadData, modelica_metatype _vlst, modelica_metatype _ilst, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveTimeIndependentAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_solveTimeIndependentAcausal,0}};
#define boxvar_RemoveSimpleEquations_solveTimeIndependentAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_solveTimeIndependentAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traversingTimeVarsFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_boolean *out_cont, modelica_metatype *out_outTuple);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traversingTimeVarsFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_metatype *out_cont, modelica_metatype *out_outTuple);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traversingTimeVarsFinder,2,0) {(void*) boxptr_RemoveSimpleEquations_traversingTimeVarsFinder,0}};
#define boxvar_RemoveSimpleEquations_traversingTimeVarsFinder MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traversingTimeVarsFinder)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_toplevelInputOrUnfixed(threadData_t *threadData, modelica_metatype _inVar);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_toplevelInputOrUnfixed(threadData_t *threadData, modelica_metatype _inVar);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_toplevelInputOrUnfixed,2,0) {(void*) boxptr_RemoveSimpleEquations_toplevelInputOrUnfixed,0}};
#define boxvar_RemoveSimpleEquations_toplevelInputOrUnfixed MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_toplevelInputOrUnfixed)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_timeIndependentExpressionAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_timeIndependentExpressionAcausal,0}};
#define boxvar_RemoveSimpleEquations_timeIndependentExpressionAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_timeIndependentExpressionAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_timeIndependentEquationAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_timeIndependentEquationAcausal,0}};
#define boxvar_RemoveSimpleEquations_timeIndependentEquationAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_timeIndependentEquationAcausal)
PROTECTED_FUNCTION_STATIC void omc_RemoveSimpleEquations_checkEqualAlias(threadData_t *threadData, modelica_boolean _equal, modelica_metatype _v1, modelica_boolean _negatedCr1, modelica_metatype _v2, modelica_boolean _negatedCr2, modelica_metatype _eqnAttributes);
PROTECTED_FUNCTION_STATIC void boxptr_RemoveSimpleEquations_checkEqualAlias(threadData_t *threadData, modelica_metatype _equal, modelica_metatype _v1, modelica_metatype _negatedCr1, modelica_metatype _v2, modelica_metatype _negatedCr2, modelica_metatype _eqnAttributes);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkEqualAlias,2,0) {(void*) boxptr_RemoveSimpleEquations_checkEqualAlias,0}};
#define boxvar_RemoveSimpleEquations_checkEqualAlias MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_checkEqualAlias)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateSimpleContainter(threadData_t *threadData, modelica_metatype _v1, modelica_boolean _negatedCr1, modelica_integer _i1, modelica_boolean _varskn1, modelica_metatype _v2, modelica_boolean _negatedCr2, modelica_integer _i2, modelica_boolean _varskn2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_integer _iIndex, modelica_metatype _iMT, modelica_integer *out_oIndex, modelica_metatype *out_oMT);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_generateSimpleContainter(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _negatedCr1, modelica_metatype _i1, modelica_metatype _varskn1, modelica_metatype _v2, modelica_metatype _negatedCr2, modelica_metatype _i2, modelica_metatype _varskn2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_metatype _iIndex, modelica_metatype _iMT, modelica_metatype *out_oIndex, modelica_metatype *out_oMT);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateSimpleContainter,2,0) {(void*) boxptr_RemoveSimpleEquations_generateSimpleContainter,0}};
#define boxvar_RemoveSimpleEquations_generateSimpleContainter MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateSimpleContainter)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateSimpleContainters(threadData_t *threadData, modelica_metatype _vars1, modelica_boolean _negatedCr1, modelica_metatype _ilst1, modelica_boolean _varskn1, modelica_boolean _time1, modelica_metatype _vars2, modelica_boolean _negatedCr2, modelica_metatype _ilst2, modelica_boolean _varskn2, modelica_boolean _time2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_integer _iIndex, modelica_metatype _iMT, modelica_integer *out_oIndex, modelica_metatype *out_oMT);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_generateSimpleContainters(threadData_t *threadData, modelica_metatype _vars1, modelica_metatype _negatedCr1, modelica_metatype _ilst1, modelica_metatype _varskn1, modelica_metatype _time1, modelica_metatype _vars2, modelica_metatype _negatedCr2, modelica_metatype _ilst2, modelica_metatype _varskn2, modelica_metatype _time2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_metatype _iIndex, modelica_metatype _iMT, modelica_metatype *out_oIndex, modelica_metatype *out_oMT);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateSimpleContainters,2,0) {(void*) boxptr_RemoveSimpleEquations_generateSimpleContainters,0}};
#define boxvar_RemoveSimpleEquations_generateSimpleContainters MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateSimpleContainters)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVars(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars, modelica_metatype _shared, modelica_metatype *out_oIndexs, modelica_boolean *out_varskn, modelica_boolean *out_time_);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getVars(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars, modelica_metatype _shared, modelica_metatype *out_oIndexs, modelica_metatype *out_varskn, modelica_metatype *out_time_);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVars,2,0) {(void*) boxptr_RemoveSimpleEquations_getVars,0}};
#define boxvar_RemoveSimpleEquations_getVars MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _inE1, modelica_boolean _negatedCr1, modelica_metatype _cr2, modelica_metatype _inE2, modelica_boolean _negatedCr2, modelica_metatype _eqnAttributes, modelica_boolean _genEqn, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addSimpleEquationAcausal(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _inE1, modelica_metatype _negatedCr1, modelica_metatype _cr2, modelica_metatype _inE2, modelica_metatype _negatedCr2, modelica_metatype _eqnAttributes, modelica_metatype _genEqn, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addSimpleEquationAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_addSimpleEquationAcausal,0}};
#define boxvar_RemoveSimpleEquations_addSimpleEquationAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addSimpleEquationAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleExpressionAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleExpressionAcausal,0}};
#define boxvar_RemoveSimpleEquations_simpleExpressionAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleExpressionAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateEquation(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _ty, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateEquation,2,0) {(void*) boxptr_RemoveSimpleEquations_generateEquation,0}};
#define boxvar_RemoveSimpleEquations_generateEquation MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_generateEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausal1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausal1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausal1,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleEquationAcausal1,0}};
#define boxvar_RemoveSimpleEquations_simpleEquationAcausal1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausal1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausalLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausalLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausalLst,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleEquationAcausalLst,0}};
#define boxvar_RemoveSimpleEquations_simpleEquationAcausalLst MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausalLst)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _ty, modelica_metatype _eqnAttributes, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleArrayEquationAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleArrayEquationAcausal,0}};
#define boxvar_RemoveSimpleEquations_simpleArrayEquationAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleArrayEquationAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausal,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleEquationAcausal,0}};
#define boxvar_RemoveSimpleEquations_simpleEquationAcausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationAcausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationsFinder(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationsFinder,2,0) {(void*) boxptr_RemoveSimpleEquations_simpleEquationsFinder,0}};
#define boxvar_RemoveSimpleEquations_simpleEquationsFinder MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_simpleEquationsFinder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder2(threadData_t *threadData, modelica_boolean _b, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _globalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_allCausalFinder2(threadData_t *threadData, modelica_metatype _b, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _globalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder2,2,0) {(void*) boxptr_RemoveSimpleEquations_allCausalFinder2,0}};
#define boxvar_RemoveSimpleEquations_allCausalFinder2 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder1(threadData_t *threadData, modelica_boolean _foundSimple, modelica_boolean _didReplacement, modelica_metatype _iSimpleeqnslst, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _globalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_allCausalFinder1(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _didReplacement, modelica_metatype _iSimpleeqnslst, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _globalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder1,2,0) {(void*) boxptr_RemoveSimpleEquations_allCausalFinder1,0}};
#define boxvar_RemoveSimpleEquations_allCausalFinder1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder,2,0) {(void*) boxptr_RemoveSimpleEquations_allCausalFinder,0}};
#define boxvar_RemoveSimpleEquations_allCausalFinder MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allCausalFinder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseComponents(threadData_t *threadData, modelica_metatype _inComps, modelica_metatype _iEqns, modelica_fnptr _inFunc, modelica_metatype _inTypeA);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseComponents,2,0) {(void*) boxptr_RemoveSimpleEquations_traverseComponents,0}};
#define boxvar_RemoveSimpleEquations_traverseComponents MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_traverseComponents)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causal1,2,0) {(void*) boxptr_RemoveSimpleEquations_causal1,0}};
#define boxvar_RemoveSimpleEquations_causal1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causal1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allAcausal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allAcausal1,2,0) {(void*) boxptr_RemoveSimpleEquations_allAcausal1,0}};
#define boxvar_RemoveSimpleEquations_allAcausal1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_allAcausal1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causalFinder1(threadData_t *threadData, modelica_boolean _finished, modelica_boolean _b, modelica_metatype _iEqnslst, modelica_integer _index, modelica_integer _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _inGlobalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_causalFinder1(threadData_t *threadData, modelica_metatype _finished, modelica_metatype _b, modelica_metatype _iEqnslst, modelica_metatype _index, modelica_metatype _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _inGlobalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causalFinder1,2,0) {(void*) boxptr_RemoveSimpleEquations_causalFinder1,0}};
#define boxvar_RemoveSimpleEquations_causalFinder1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causalFinder1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causalFinder(threadData_t *threadData, modelica_boolean _foundSimple, modelica_metatype _simpleContainerIn, modelica_metatype _iEqnslst, modelica_integer _traversalIdx, modelica_integer _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _inGlobalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_causalFinder(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _simpleContainerIn, modelica_metatype _iEqnslst, modelica_metatype _traversalIdx, modelica_metatype _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _inGlobalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causalFinder,2,0) {(void*) boxptr_RemoveSimpleEquations_causalFinder,0}};
#define boxvar_RemoveSimpleEquations_causalFinder MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_causalFinder)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fastAcausal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fastAcausal1,2,0) {(void*) boxptr_RemoveSimpleEquations_fastAcausal1,0}};
#define boxvar_RemoveSimpleEquations_fastAcausal1 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fastAcausal1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceable(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _inUnreplaceable);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceable,2,0) {(void*) boxptr_RemoveSimpleEquations_addUnreplaceable,0}};
#define boxvar_RemoveSimpleEquations_addUnreplaceable MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_addUnreplaceable)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixKnownVarsCausal2(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixKnownVarsCausal2,2,0) {(void*) boxptr_RemoveSimpleEquations_fixKnownVarsCausal2,0}};
#define boxvar_RemoveSimpleEquations_fixKnownVarsCausal2 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixKnownVarsCausal2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasVarsCausal2(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasVarsCausal2,2,0) {(void*) boxptr_RemoveSimpleEquations_fixAliasVarsCausal2,0}};
#define boxvar_RemoveSimpleEquations_fixAliasVarsCausal2 MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasVarsCausal2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasAndKnownVarsCausal(threadData_t *threadData, modelica_metatype _inDAE1, modelica_metatype _inDAE2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasAndKnownVarsCausal,2,0) {(void*) boxptr_RemoveSimpleEquations_fixAliasAndKnownVarsCausal,0}};
#define boxvar_RemoveSimpleEquations_fixAliasAndKnownVarsCausal MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasAndKnownVarsCausal)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixKnownVars(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fdae);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixKnownVars,2,0) {(void*) boxptr_RemoveSimpleEquations_fixKnownVars,0}};
#define boxvar_RemoveSimpleEquations_fixKnownVars MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixKnownVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasVars(threadData_t *threadData, modelica_metatype _inDAE);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasVars,2,0) {(void*) boxptr_RemoveSimpleEquations_fixAliasVars,0}};
#define boxvar_RemoveSimpleEquations_fixAliasVars MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_fixAliasVars)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVarsHelper(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars);
static const MMC_DEFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVarsHelper,2,0) {(void*) boxptr_RemoveSimpleEquations_getVarsHelper,0}};
#define boxvar_RemoveSimpleEquations_getVarsHelper MMC_REFSTRUCTLIT(boxvar_lit_RemoveSimpleEquations_getVarsHelper)

PROTECTED_FUNCTION_STATIC modelica_string omc_RemoveSimpleEquations_dumpSimpleContainer(threadData_t *threadData, modelica_metatype _container)
{
  modelica_string _sOut = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _sOut has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _container;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      modelica_boolean _n1;
      modelica_boolean _n2;
      modelica_integer _i1;
      modelica_integer _i2;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _e has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      // _n1 has no default value.
      // _n2 has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          
          _cr1 = tmpMeta6;
          _n1 = tmp8  /* pattern as ty=Boolean */;
          _i1 = tmp10  /* pattern as ty=Integer */;
          _cr2 = tmpMeta11;
          _n2 = tmp13  /* pattern as ty=Boolean */;
          _i2 = tmp15  /* pattern as ty=Integer */;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _s1 = (_n1?_OMC_LIT0:_OMC_LIT1);

          _s2 = (_n2?_OMC_LIT0:_OMC_LIT1);

          tmpMeta16 = stringAppend(_s1,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
          _s1 = tmpMeta16;

          tmpMeta17 = stringAppend(_s2,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr2));
          _s2 = tmpMeta17;
          tmpMeta18 = stringAppend(_OMC_LIT2,_s1);
          tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT3);
          tmpMeta20 = stringAppend(tmpMeta19,_s2);
          tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT4);
          tmpMeta22 = stringAppend(tmpMeta21,intString(_i1));
          tmpMeta23 = stringAppend(tmpMeta22,_OMC_LIT5);
          tmpMeta24 = stringAppend(tmpMeta23,intString(_i2));
          tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT6);
          tmp1 = tmpMeta25;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_integer tmp28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_integer tmp33;
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          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,1,8) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp28 = mmc_unbox_integer(tmpMeta27);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp33 = mmc_unbox_integer(tmpMeta32);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          
          _cr1 = tmpMeta26;
          _n1 = tmp28  /* pattern as ty=Boolean */;
          _i1 = tmp30  /* pattern as ty=Integer */;
          _cr2 = tmpMeta31;
          _n2 = tmp33  /* pattern as ty=Boolean */;
          _i2 = tmp35  /* pattern as ty=Integer */;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _s1 = (_n1?_OMC_LIT0:_OMC_LIT1);

          _s2 = (_n2?_OMC_LIT0:_OMC_LIT1);

          tmpMeta36 = stringAppend(_s1,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
          _s1 = tmpMeta36;

          tmpMeta37 = stringAppend(_s2,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr2));
          _s2 = tmpMeta37;
          tmpMeta38 = stringAppend(_OMC_LIT7,_s1);
          tmpMeta39 = stringAppend(tmpMeta38,_OMC_LIT3);
          tmpMeta40 = stringAppend(tmpMeta39,_s2);
          tmpMeta41 = stringAppend(tmpMeta40,_OMC_LIT4);
          tmpMeta42 = stringAppend(tmpMeta41,intString(_i1));
          tmpMeta43 = stringAppend(tmpMeta42,_OMC_LIT5);
          tmpMeta44 = stringAppend(tmpMeta43,intString(_i2));
          tmpMeta45 = stringAppend(tmpMeta44,_OMC_LIT6);
          tmp1 = tmpMeta45;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_integer tmp48;
          modelica_metatype tmpMeta49;
          modelica_integer tmp50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_integer tmp53;
          modelica_metatype tmpMeta54;
          modelica_integer tmp55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp48 = mmc_unbox_integer(tmpMeta47);
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp50 = mmc_unbox_integer(tmpMeta49);
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp53 = mmc_unbox_integer(tmpMeta52);
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp55 = mmc_unbox_integer(tmpMeta54);
          
          _cr1 = tmpMeta46;
          _n1 = tmp48  /* pattern as ty=Boolean */;
          _i1 = tmp50  /* pattern as ty=Integer */;
          _cr2 = tmpMeta51;
          _n2 = tmp53  /* pattern as ty=Boolean */;
          _i2 = tmp55  /* pattern as ty=Integer */;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _s1 = (_n1?_OMC_LIT0:_OMC_LIT1);

          _s2 = (_n2?_OMC_LIT0:_OMC_LIT1);

          tmpMeta56 = stringAppend(_s1,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
          _s1 = tmpMeta56;

          tmpMeta57 = stringAppend(_s2,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr2));
          _s2 = tmpMeta57;
          tmpMeta58 = stringAppend(_OMC_LIT8,_s1);
          tmpMeta59 = stringAppend(tmpMeta58,_OMC_LIT3);
          tmpMeta60 = stringAppend(tmpMeta59,_s2);
          tmpMeta61 = stringAppend(tmpMeta60,_OMC_LIT4);
          tmpMeta62 = stringAppend(tmpMeta61,intString(_i1));
          tmpMeta63 = stringAppend(tmpMeta62,_OMC_LIT5);
          tmpMeta64 = stringAppend(tmpMeta63,intString(_i2));
          tmpMeta65 = stringAppend(tmpMeta64,_OMC_LIT6);
          tmp1 = tmpMeta65;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _cr1 = tmpMeta66;
          _e = tmpMeta67;
          /* Pattern matching succeeded */
          tmpMeta68 = stringAppend(_OMC_LIT9,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
          tmpMeta69 = stringAppend(tmpMeta68,_OMC_LIT3);
          tmpMeta70 = stringAppend(tmpMeta69,omc_ExpressionBasics_printExpStr(threadData, _e));
          tmp1 = tmpMeta70;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT10;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _sOut = tmp1;
  _return: OMC_LABEL_UNUSED
  return _sOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getDominantAttributeValue(threadData_t *threadData, modelica_metatype _tplExpIndList)
{
  modelica_metatype _outE = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _tpl = NULL;
  modelica_integer _i;
  modelica_integer _j;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outE = _OMC_LIT11;
  // _e has no default value.
  // _tpl has no default value.
  // _i has no default value.
  _j = ((modelica_integer) 111111);
  {
    modelica_metatype _tpl;
    for (tmpMeta1 = _tplExpIndList; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _tpl = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _tpl;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      tmp5 = mmc_unbox_integer(tmpMeta4);
      _e = tmpMeta3;
      _i = tmp5  /* pattern as ty=Integer */;

      if((_i < _j))
      {
        _outE = _e;

        _j = _i;
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getThisAttributes(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _cr_eq_lst, modelica_metatype _inAliasVars, modelica_metatype _inHTStartExpToInt, modelica_metatype _inHTNominalExpToInt, modelica_metatype *out_outHTNominalExpToInt)
{
  modelica_metatype _outHTStartExpToInt = NULL;
  modelica_metatype _outHTNominalExpToInt = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outHTStartExpToInt = _inHTStartExpToInt;
  _outHTNominalExpToInt = _inHTNominalExpToInt;
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp5_1;
    tmp5_1 = _cr_eq_lst;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr_lst = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype tmpMeta3;
      modelica_metatype _e2 = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _cr_eq_rest = NULL;
      modelica_integer _j;
      modelica_integer _j1;
      volatile mmc_switch_type tmp5;
      int tmp6;
      // _cr1 has no default value.
      // _cr_lst has no default value.
      // _res has no default value.
      // _e has no default value.
      tmpMeta3 = mmc_mk_box2(3, &DAE_Exp_ICONST__desc, mmc_mk_integer(((modelica_integer) 0)));
      _e1 = tmpMeta3;
      // _e2 has no default value.
      // _v has no default value.
      // _cr_eq_rest has no default value.
      // _j has no default value.
      // _j1 has no default value.
      tmp5 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp4_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp5 < 3; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          if (!listEmpty(tmp5_1)) goto tmp4_end;
          tmp5 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _outHTStartExpToInt;
          tmpMeta[0+1] = _outHTNominalExpToInt;
          goto tmp4_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          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;
          if (listEmpty(tmp5_1)) goto tmp4_end;
          tmpMeta7 = MMC_CAR(tmp5_1);
          tmpMeta8 = MMC_CDR(tmp5_1);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          
          _cr1 = tmpMeta9;
          _cr_eq_rest = tmpMeta8;
          /* Pattern matching succeeded */
          _v = omc_BackendVariable_getVarSingle(threadData, _cr1, _inAliasVars, NULL);

          _e = omc_BackendVariable_varBindExp(threadData, _v);

          if(omc_BackendVariable_varHasStartValue(threadData, _v))
          {
            _res = omc_BackendVariable_varStartValue(threadData, _v);

            /* Pattern-matching assignment */
            tmpMeta10 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_Expression_crefExp(threadData, _cr1), _e, _OMC_LIT15, _OMC_LIT18);
            tmpMeta11 = omc_BackendEquation_solveEquation(threadData, tmpMeta10, omc_Expression_crefExp(threadData, _cr), mmc_mk_none());
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,0,4) == 0) goto goto_2;
            tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 3));
            _e1 = tmpMeta12;

            /* Pattern-matching assignment */
            tmpMeta13 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _res, _e, _OMC_LIT15, _OMC_LIT18);
            tmpMeta14 = omc_BackendEquation_solveEquation(threadData, tmpMeta13, omc_Expression_crefExp(threadData, _cr), mmc_mk_none());
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,0,4) == 0) goto goto_2;
            tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
            _e2 = tmpMeta15;

            _e2 = omc_ExpressionSimplify_simplify(threadData, _e2, NULL);

            if(omc_Expression_isZero(threadData, _e2))
            {
              _e2 = _OMC_LIT19;
            }

            _cr_lst = omc_Expression_extractCrefsFromExp(threadData, _e2);

            _j = ((modelica_integer) 2) - listLength(_cr_lst);

            _j = (_j) * (omc_ComponentReference_crefDepth(threadData, _cr1));

            if(omc_BaseHashTable_hasKey(threadData, _e2, _outHTStartExpToInt))
            {
              _j1 = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _e2, _outHTStartExpToInt));

              if((_j1 < _j))
              {
                _j = _j1;
              }
            }

            tmpMeta16 = mmc_mk_box2(0, _e2, mmc_mk_integer(_j));
            _outHTStartExpToInt = omc_BaseHashTable_add(threadData, tmpMeta16, _outHTStartExpToInt);

            if(omc_Flags_isSet(threadData, _OMC_LIT24))
            {
              tmpMeta17 = stringAppend(_OMC_LIT20,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
              tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT3);
              tmpMeta19 = stringAppend(tmpMeta18,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmpMeta20 = stringAppend(tmpMeta19,_OMC_LIT3);
              tmpMeta21 = stringAppend(tmpMeta20,omc_ExpressionBasics_printExpStr(threadData, _e2));
              tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT21);
              fputs(MMC_STRINGDATA(tmpMeta22),stdout);
            }
          }

          if(omc_BackendVariable_varHasNominalValue(threadData, _v))
          {
            _e2 = omc_BackendVariable_varNominalValue(threadData, _v);

            _cr_lst = omc_Expression_extractCrefsFromExp(threadData, _e2);

            _j = ((modelica_integer) 2) - listLength(_cr_lst);

            _j = (_j) * (omc_ComponentReference_crefDepth(threadData, _cr1));

            if(omc_BaseHashTable_hasKey(threadData, _e2, _outHTNominalExpToInt))
            {
              _j1 = mmc_unbox_integer(omc_BaseHashTable_get(threadData, _e2, _outHTNominalExpToInt));

              if((_j1 < _j))
              {
                _j = _j1;
              }
            }

            tmpMeta23 = mmc_mk_box2(0, _e2, mmc_mk_integer(_j));
            _outHTNominalExpToInt = omc_BaseHashTable_add(threadData, tmpMeta23, _outHTNominalExpToInt);

            if(omc_Flags_isSet(threadData, _OMC_LIT24))
            {
              tmpMeta24 = stringAppend(_OMC_LIT25,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
              tmpMeta25 = stringAppend(tmpMeta24,_OMC_LIT3);
              tmpMeta26 = stringAppend(tmpMeta25,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmpMeta27 = stringAppend(tmpMeta26,_OMC_LIT3);
              tmpMeta28 = stringAppend(tmpMeta27,omc_ExpressionBasics_printExpStr(threadData, _e2));
              tmpMeta29 = stringAppend(tmpMeta28,_OMC_LIT21);
              fputs(MMC_STRINGDATA(tmpMeta29),stdout);
            }
          }
          tmpMeta[0+0] = omc_RemoveSimpleEquations_getThisAttributes(threadData, _cr, _cr_eq_rest, _inAliasVars, _outHTStartExpToInt, _outHTNominalExpToInt, &tmpMeta[0+1]);
          goto tmp4_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT26),stdout);
          tmpMeta[0+0] = _outHTStartExpToInt;
          tmpMeta[0+1] = _outHTNominalExpToInt;
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_2;
      tmp4_done:
      (void)tmp5;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp4_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp5 < 3) {
        goto tmp4_top;
      }
      MMC_THROW_INTERNAL();
      tmp4_done2:;
    }
  }
  _outHTStartExpToInt = tmpMeta[0+0];
  _outHTNominalExpToInt = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outHTNominalExpToInt) { *out_outHTNominalExpToInt = _outHTNominalExpToInt; }
  return _outHTStartExpToInt;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_setAttributes(threadData_t *threadData, modelica_metatype _tplCrEqLst, modelica_metatype _inVars, modelica_metatype _inAliasVars)
{
  jmp_buf *old_mmc_jumper = threadData->mmc_jumper;
  modelica_metatype _outVars = NULL;
  modelica_metatype _cr1 = NULL;
  modelica_metatype _cr_lst = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _v = NULL;
  modelica_integer _i;
  modelica_integer _j;
  modelica_metatype _cr_eq_lst = NULL;
  modelica_metatype _HTStartExpToInt = NULL;
  modelica_metatype _HTNominalExpToInt = NULL;
  modelica_metatype _tplExpIndList = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVars = _inVars;
  // _cr1 has no default value.
  // _cr_lst has no default value.
  // _e has no default value.
  // _v has no default value.
  // _i has no default value.
  // _j has no default value.
  // _cr_eq_lst has no default value.
  // _HTStartExpToInt has no default value.
  // _HTNominalExpToInt has no default value.
  // _tplExpIndList has no default value.
  if(listEmpty(_tplCrEqLst))
  {
    goto _return;
  }

  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          /* Pattern matching succeeded */
          _HTStartExpToInt = omc_HashTableExpToIndex_emptyHashTableSized(threadData, ((modelica_integer) 100));

          _HTNominalExpToInt = omc_HashTableExpToIndex_emptyHashTableSized(threadData, ((modelica_integer) 100));

          {
            modelica_metatype _tpl;
            for (tmpMeta5 = _tplCrEqLst; !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
            {
              _tpl = MMC_CAR(tmpMeta5);
              /* Pattern-matching assignment */
              tmpMeta6 = _tpl;
              tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
              tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
              _cr1 = tmpMeta7;
              _cr_eq_lst = tmpMeta8;

              omc_BaseHashTable_clear(threadData, _HTStartExpToInt);

              omc_BaseHashTable_clear(threadData, _HTNominalExpToInt);

              _v = omc_BackendVariable_getVarSingle(threadData, _cr1, _outVars ,&_i);

              if(omc_BackendVariable_varHasStartValue(threadData, _v))
              {
                _e = omc_BackendVariable_varStartValue(threadData, _v);

                if(omc_Expression_isZero(threadData, _e))
                {
                  _e = _OMC_LIT19;
                }

                _cr_lst = omc_Expression_extractCrefsFromExp(threadData, _e);

                _j = ((modelica_integer) 2) - listLength(_cr_lst);

                _j = (_j) * (omc_ComponentReference_crefDepth(threadData, _cr1));

                tmpMeta9 = mmc_mk_box2(0, _e, mmc_mk_integer(_j));
                _HTStartExpToInt = omc_BaseHashTable_add(threadData, tmpMeta9, _HTStartExpToInt);

                if(omc_Flags_isSet(threadData, _OMC_LIT24))
                {
                  tmpMeta10 = stringAppend(_OMC_LIT20,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
                  tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT3);
                  tmpMeta12 = stringAppend(tmpMeta11,omc_ExpressionBasics_printExpStr(threadData, _e));
                  tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT21);
                  fputs(MMC_STRINGDATA(tmpMeta13),stdout);
                }
              }

              if(omc_BackendVariable_varHasNominalValue(threadData, _v))
              {
                _e = omc_BackendVariable_varNominalValue(threadData, _v);

                _cr_lst = omc_Expression_extractCrefsFromExp(threadData, _e);

                _j = ((modelica_integer) 2) - listLength(_cr_lst);

                _j = (_j) * (omc_ComponentReference_crefDepth(threadData, _cr1));

                tmpMeta14 = mmc_mk_box2(0, _e, mmc_mk_integer(_j));
                _HTNominalExpToInt = omc_BaseHashTable_add(threadData, tmpMeta14, _HTNominalExpToInt);

                if(omc_Flags_isSet(threadData, _OMC_LIT24))
                {
                  tmpMeta15 = stringAppend(_OMC_LIT25,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
                  tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT3);
                  tmpMeta17 = stringAppend(tmpMeta16,omc_ExpressionBasics_printExpStr(threadData, _e));
                  tmpMeta18 = stringAppend(tmpMeta17,_OMC_LIT21);
                  fputs(MMC_STRINGDATA(tmpMeta18),stdout);
                }
              }

              _HTStartExpToInt = omc_RemoveSimpleEquations_getThisAttributes(threadData, _cr1, _cr_eq_lst, _inAliasVars, _HTStartExpToInt, _HTNominalExpToInt ,&_HTNominalExpToInt);

              _tplExpIndList = omc_BaseHashTable_hashTableList(threadData, _HTStartExpToInt);

              if((!listEmpty(_tplExpIndList)))
              {
                _e = omc_RemoveSimpleEquations_getDominantAttributeValue(threadData, _tplExpIndList);

                _v = omc_BackendVariable_setVarStartValue(threadData, _v, _e);

                if(omc_Flags_isSet(threadData, _OMC_LIT24))
                {
                  tmpMeta19 = stringAppend(_OMC_LIT20,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
                  tmpMeta20 = stringAppend(tmpMeta19,_OMC_LIT3);
                  tmpMeta21 = stringAppend(tmpMeta20,omc_ExpressionBasics_printExpStr(threadData, _e));
                  tmpMeta22 = stringAppend(tmpMeta21,_OMC_LIT21);
                  fputs(MMC_STRINGDATA(tmpMeta22),stdout);

                  omc_BaseHashTable_dumpHashTable(threadData, _HTStartExpToInt);
                }
              }

              _tplExpIndList = omc_BaseHashTable_hashTableList(threadData, _HTNominalExpToInt);

              if((!listEmpty(_tplExpIndList)))
              {
                _e = omc_RemoveSimpleEquations_getDominantAttributeValue(threadData, _tplExpIndList);

                _v = omc_BackendVariable_setVarNominalValue(threadData, _v, _e);

                if(omc_Flags_isSet(threadData, _OMC_LIT24))
                {
                  tmpMeta23 = stringAppend(_OMC_LIT25,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr1));
                  tmpMeta24 = stringAppend(tmpMeta23,_OMC_LIT3);
                  tmpMeta25 = stringAppend(tmpMeta24,omc_ExpressionBasics_printExpStr(threadData, _e));
                  tmpMeta26 = stringAppend(tmpMeta25,_OMC_LIT21);
                  fputs(MMC_STRINGDATA(tmpMeta26),stdout);

                  omc_BaseHashTable_dumpHashTable(threadData, _HTNominalExpToInt);
                }
              }

              _outVars = omc_BackendVariable_setVarAt(threadData, _outVars, _i, _v);
            }
          }
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT27),stdout);
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  threadData->mmc_jumper = old_mmc_jumper;
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasAttributes(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype *out_outShared)
{
  modelica_metatype _outSystem = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _orderedVars = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype _HTAliasLst = NULL;
  modelica_metatype _tplAliasLst = NULL;
  modelica_integer _size;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSystem has no default value.
  _outShared = _inShared;
  // _orderedVars has no default value.
  // _aliasVars has no default value.
  // _HTAliasLst has no default value.
  // _tplAliasLst has no default value.
  // _size has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inSystem;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _orderedVars = tmpMeta2;

  /* Pattern-matching assignment */
  tmpMeta3 = _inShared;
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 5));
  _aliasVars = tmpMeta4;

  _size = omc_BackendVariable_varsSize(threadData, _orderedVars);

  _size = modelica_integer_max((modelica_integer)(((modelica_integer) 2053)),(modelica_integer)(((modelica_integer)floor((0.7) * (((modelica_real)_size))))));

  _HTAliasLst = omc_HashTableCrToCrEqLst_emptyHashTableSized(threadData, _size);

  _HTAliasLst = omc_RemoveSimpleEquations_determineAliasLst(threadData, _aliasVars, _orderedVars, _HTAliasLst);

  _tplAliasLst = omc_BaseHashTable_hashTableList(threadData, _HTAliasLst);

  _orderedVars = omc_RemoveSimpleEquations_setAttributes(threadData, _tplAliasLst, _orderedVars, _aliasVars);

  _outSystem = omc_BackendDAEUtil_setEqSystVars(threadData, _inSystem, _orderedVars);
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  return _outSystem;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_determineAliasLst(threadData_t *threadData, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype _inHTAliasLst)
{
  modelica_metatype _outHTAliasLst = NULL;
  modelica_metatype _cr1 = NULL;
  modelica_metatype _cr2 = NULL;
  modelica_metatype _cr_lst = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _eq = NULL;
  modelica_metatype _w = NULL;
  modelica_metatype _v = NULL;
  modelica_integer _count;
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta22;
  modelica_integer tmp23;
  modelica_integer tmp24;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outHTAliasLst = _inHTAliasLst;
  // _cr1 has no default value.
  // _cr2 has no default value.
  // _cr_lst has no default value.
  // _e has no default value.
  // _eq has no default value.
  // _w has no default value.
  // _v has no default value.
  // _count has no default value.
  // _vars has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inAliasVars;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  _vars = tmpMeta3;

  {
    modelica_metatype _w;
    for (tmpMeta4 = _vars, tmp24 = arrayLength(tmpMeta4), tmp23 = 1; tmp23 <= tmp24; tmp23++)
    {
      _w = arrayGet(tmpMeta4,tmp23);
      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp7;
          int tmp8;
          tmp7 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp6_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp7 < 2; tmp7++) {
            switch (MMC_SWITCH_CAST(tmp7)) {
            case 0: {
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              modelica_metatype tmpMeta11;
              modelica_metatype tmpMeta12;
              modelica_metatype tmpMeta13;
              modelica_integer tmp14;
              modelica_metatype tmpMeta15;
              modelica_metatype tmpMeta16;
              modelica_integer tmp17;
              modelica_metatype tmpMeta18;
              modelica_metatype tmpMeta19;
              modelica_metatype tmpMeta20;
              modelica_metatype tmpMeta21;
              /* Pattern matching succeeded */
              /* Pattern-matching assignment */
              tmpMeta9 = _w;
              if (optionNone(tmpMeta9)) goto goto_5;
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
              _v = tmpMeta10;

              _cr1 = omc_BackendVariable_varCref(threadData, _v);

              _e = omc_BackendVariable_varBindExp(threadData, _v);

              /* Pattern-matching tuple assignment, wild first pattern */
              tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta16 = mmc_mk_box5(0, tmpMeta15, _inVars, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_boolean(1 /* true */));
              omc_Expression_traverseExpTopDown(threadData, _e, boxvar_RemoveSimpleEquations_findCrefs, tmpMeta16, &tmpMeta11);
              tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
              tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 3));
              tmp14 = mmc_unbox_integer(tmpMeta13);
              _cr_lst = tmpMeta12;
              _count = tmp14  /* pattern as ty=Integer */;

              /* Pattern-matching assignment */
              tmp17 = _count;
              if (1 != tmp17) goto goto_5;

              /* Pattern-matching assignment */
              tmpMeta18 = _cr_lst;
              if (listEmpty(tmpMeta18)) goto goto_5;
              tmpMeta19 = MMC_CAR(tmpMeta18);
              tmpMeta20 = MMC_CDR(tmpMeta18);
              if (!listEmpty(tmpMeta20)) goto goto_5;
              _cr2 = tmpMeta19;

              tmpMeta21 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_Expression_crefExp(threadData, _cr1), _e, _OMC_LIT15, _OMC_LIT18);
              _eq = tmpMeta21;

              _outHTAliasLst = omc_RemoveSimpleEquations_addToCrAndEqLists(threadData, _cr2, _cr1, _eq, _outHTAliasLst);
              goto tmp6_done;
            }
            case 1: {
              /* Pattern matching succeeded */
              _outHTAliasLst = _outHTAliasLst;
              goto tmp6_done;
            }
            }
            goto tmp6_end;
            tmp6_end: ;
          }
          goto goto_5;
          tmp6_done:
          (void)tmp7;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp6_done2;
          goto_5:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp7 < 2) {
            goto tmp6_top;
          }
          MMC_THROW_INTERNAL();
          tmp6_done2:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outHTAliasLst;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_checkOp(threadData_t *threadData, modelica_metatype _inOp)
{
  modelica_boolean _outB;
  modelica_boolean tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outB has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inOp;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmp1 = 1 /* true */;
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 32: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 6: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        case 7: {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmp1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outB = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outB;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_checkOp(threadData_t *threadData, modelica_metatype _inOp)
{
  modelica_boolean _outB;
  modelica_metatype out_outB;
  _outB = omc_RemoveSimpleEquations_checkOp(threadData, _inOp);
  out_outB = mmc_mk_icon(_outB);
  return out_outB;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_checkOperator(threadData_t *threadData, modelica_metatype _inExp, modelica_boolean _inIsSimple, modelica_boolean *out_cont, modelica_boolean *out_outIsSimple)
{
  modelica_metatype _outExp = NULL;
  modelica_boolean _cont;
  modelica_boolean _outIsSimple;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _cont has no default value.
  // _outIsSimple has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inExp;
    {
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _op = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _op 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;
          modelica_metatype tmpMeta8;
          modelica_boolean tmp9;
          modelica_boolean tmp10;
          modelica_boolean tmp11;
          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));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _exp1 = tmpMeta6;
          _op = tmpMeta7;
          _exp2 = tmpMeta8;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmp9 = omc_RemoveSimpleEquations_checkOp(threadData, _op);
          if (1 /* true */ != tmp9) goto goto_2;

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_RemoveSimpleEquations_checkOperator(threadData, _exp1, _inIsSimple, &tmp10, NULL);
          if (1 /* true */ != tmp10) goto goto_2;

          /* Pattern-matching tuple assignment, wild first pattern */
          omc_RemoveSimpleEquations_checkOperator(threadData, _exp2, _inIsSimple, &tmp11, NULL);
          if (1 /* true */ != tmp11) goto goto_2;
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          _exp1 = tmpMeta12;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = omc_RemoveSimpleEquations_checkOperator(threadData, _exp1, _inIsSimple, &tmp1_c1, &tmp1_c2);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          _exp1 = tmpMeta13;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = omc_RemoveSimpleEquations_checkOperator(threadData, _exp1, _inIsSimple, &tmp1_c1, &tmp1_c2);
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,1) == 0) goto tmp3_end;
          
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,1) == 0) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 7: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmp1_c2 = 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 < 9) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outExp = tmpMeta[0+0];
  _cont = tmp1_c1;
  _outIsSimple = tmp1_c2;
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_outIsSimple) { *out_outIsSimple = _outIsSimple; }
  return _outExp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_checkOperator(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inIsSimple, modelica_metatype *out_cont, modelica_metatype *out_outIsSimple)
{
  modelica_integer tmp1;
  modelica_boolean _cont;
  modelica_boolean _outIsSimple;
  modelica_metatype _outExp = NULL;
  tmp1 = mmc_unbox_integer(_inIsSimple);
  _outExp = omc_RemoveSimpleEquations_checkOperator(threadData, _inExp, tmp1, &_cont, &_outIsSimple);
  /* skip box _outExp; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  if (out_outIsSimple) { *out_outIsSimple = mmc_mk_icon(_outIsSimple); }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isSimple(threadData_t *threadData, modelica_metatype _inExp)
{
  modelica_boolean _outIsSimple;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outIsSimple has no default value.
  /* Pattern-matching tuple assignment, wild first pattern */
  omc_Expression_traverseExpTopDown(threadData, _inExp, boxvar_RemoveSimpleEquations_checkOperator, mmc_mk_boolean(1 /* true */), &tmpMeta1);
  tmp2 = mmc_unbox_integer(tmpMeta1);
  _outIsSimple = tmp2  /* pattern as ty=Boolean */;
  _return: OMC_LABEL_UNUSED
  return _outIsSimple;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isSimple(threadData_t *threadData, modelica_metatype _inExp)
{
  modelica_boolean _outIsSimple;
  modelica_metatype out_outIsSimple;
  _outIsSimple = omc_RemoveSimpleEquations_isSimple(threadData, _inExp);
  out_outIsSimple = mmc_mk_icon(_outIsSimple);
  return out_outIsSimple;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addThisCrefs(threadData_t *threadData, modelica_metatype _cr_eq_lst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _outHTCrToExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHTCrToExp has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _cr_eq_lst;
    tmp4_2 = _inHTCrToExp;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _eq = NULL;
      modelica_metatype _HTCrToExp = NULL;
      modelica_metatype _cr_eq_rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _eq has no default value.
      // _HTCrToExp has no default value.
      // _cr_eq_rest has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _HTCrToExp = tmp4_2;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _HTCrToExp;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _cr1 = tmpMeta8;
          _eq = tmpMeta9;
          _cr_eq_rest = tmpMeta7;
          _HTCrToExp = tmp4_2;
          /* Pattern matching succeeded */
          if((!omc_BaseHashTable_hasKey(threadData, _cr1, _HTCrToExp)))
          {
            _HTCrToExp = omc_RemoveSimpleEquations_addToCrToExp(threadData, _cr1, _eq, _HTCrToExp, _inHTCrToCrEqLst);
          }
          tmpMeta1 = omc_RemoveSimpleEquations_addThisCrefs(threadData, _cr_eq_rest, _HTCrToExp, _inHTCrToCrEqLst);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT28),stdout);
          tmpMeta1 = _inHTCrToExp;
          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:;
    }
  }
  _outHTCrToExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHTCrToExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addRestCrefs(threadData_t *threadData, modelica_metatype _tplCrEqLst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _HTCrToExp = NULL;
  modelica_metatype _cr1 = NULL;
  modelica_metatype _cr_eq_lst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _HTCrToExp = _inHTCrToExp;
  // _cr1 has no default value.
  // _cr_eq_lst 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;
          /* Pattern matching succeeded */
          {
            modelica_metatype _tpl;
            for (tmpMeta5 = _tplCrEqLst; !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
            {
              _tpl = MMC_CAR(tmpMeta5);
              /* Pattern-matching assignment */
              tmpMeta6 = _tpl;
              tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
              tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
              _cr1 = tmpMeta7;
              _cr_eq_lst = tmpMeta8;

              if((!omc_BaseHashTable_hasKey(threadData, _cr1, _HTCrToExp)))
              {
                _HTCrToExp = omc_RemoveSimpleEquations_addThisCrefs(threadData, _cr_eq_lst, _HTCrToExp, _inHTCrToCrEqLst);
              }
            }
          }
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT29),stdout);

          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _HTCrToExp;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isCrefInValue(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value)
{
  modelica_boolean _isInValue;
  modelica_metatype _cr_lst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _isInValue has no default value.
  // _cr_lst has no default value.
  _cr_lst = omc_Expression_extractCrefsFromExp(threadData, _value);

  _isInValue = listMember(_cr, _cr_lst);
  _return: OMC_LABEL_UNUSED
  return _isInValue;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isCrefInValue(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value)
{
  modelica_boolean _isInValue;
  modelica_metatype out_isInValue;
  _isInValue = omc_RemoveSimpleEquations_isCrefInValue(threadData, _cr, _value);
  out_isInValue = mmc_mk_icon(_isInValue);
  return out_isInValue;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveAllCrefs1(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value, modelica_metatype _cr_eq_lst, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _outHTCrToExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHTCrToExp has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _cr_eq_lst;
    tmp4_2 = _inHTCrToExp;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _eq = NULL;
      modelica_metatype _HTCrToExp = NULL;
      modelica_metatype _cr_eq_rest = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _res has no default value.
      // _eq has no default value.
      // _HTCrToExp has no default value.
      // _cr_eq_rest 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 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _HTCrToExp = tmp4_2;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _HTCrToExp;
          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;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _cr1 = tmpMeta8;
          _eq = tmpMeta9;
          _cr_eq_rest = tmpMeta7;
          _HTCrToExp = tmp4_2;
          /* Pattern matching succeeded */
          if(((!omc_BaseHashTable_hasKey(threadData, _cr1, _HTCrToExp)) && (!omc_RemoveSimpleEquations_isCrefInValue(threadData, _cr1, _value))))
          {
            /* Pattern-matching assignment */
            tmpMeta10 = omc_BackendEquation_solveEquation(threadData, _eq, omc_Expression_crefExp(threadData, _cr1), mmc_mk_none());
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,0,4) == 0) goto goto_2;
            tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
            tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 4));
            tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 5));
            _res = tmpMeta11;
            _source = tmpMeta12;
            _eqAttr = tmpMeta13;

            _res = omc_Expression_replaceExp(threadData, _res, omc_Expression_crefExp(threadData, _cr), _value, NULL);

            _res = omc_ExpressionSimplify_simplify(threadData, _res, NULL);

            tmpMeta14 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_Expression_crefExp(threadData, _cr1), _res, _source, _eqAttr);
            _HTCrToExp = omc_RemoveSimpleEquations_addToCrToExp(threadData, _cr1, tmpMeta14, _inHTCrToExp, _inHTCrToCrEqLst);
          }
          tmpMeta1 = omc_RemoveSimpleEquations_solveAllCrefs1(threadData, _cr, _value, _cr_eq_rest, _HTCrToExp, _inHTCrToCrEqLst);
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT30),stdout);
          tmpMeta1 = _inHTCrToExp;
          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:;
    }
  }
  _outHTCrToExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHTCrToExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveAllCrefs(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _value, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _outHTCrToExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHTCrToExp has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inHTCrToExp;
    {
      modelica_metatype _HTCrToExp = NULL;
      modelica_metatype _cr_eq_lst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _HTCrToExp has no default value.
      // _cr_eq_lst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          
          _HTCrToExp = tmp4_1;
          /* Pattern matching succeeded */
          if(omc_BaseHashTable_hasKey(threadData, _cr, _inHTCrToCrEqLst))
          {
            _cr_eq_lst = omc_BaseHashTable_get(threadData, _cr, _inHTCrToCrEqLst);

            _HTCrToExp = omc_RemoveSimpleEquations_solveAllCrefs1(threadData, _cr, _value, _cr_eq_lst, _HTCrToExp, _inHTCrToCrEqLst);
          }
          tmpMeta1 = _HTCrToExp;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT31),stdout);
          tmpMeta1 = _inHTCrToExp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outHTCrToExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHTCrToExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addToCrToExp(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _eq, modelica_metatype _inHTCrToExp, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _outHTCrToExp = NULL;
  modelica_metatype _value = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHTCrToExp has no default value.
  // _value has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = omc_BackendEquation_solveEquation(threadData, _eq, omc_Expression_crefExp(threadData, _cr), mmc_mk_none());
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,4) == 0) goto goto_2;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          _value = tmpMeta7;

          tmpMeta8 = mmc_mk_box2(0, _cr, _value);
          _outHTCrToExp = omc_BaseHashTable_add(threadData, tmpMeta8, _inHTCrToExp);
          tmpMeta1 = omc_RemoveSimpleEquations_solveAllCrefs(threadData, _cr, _value, _outHTCrToExp, _inHTCrToCrEqLst);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta9;
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT32),stdout);

          omc_BackendDump_printEquation(threadData, _eq);

          tmpMeta9 = stringAppend(omc_ComponentReference_debugPrintComponentRefTypeStr(threadData, _cr),_OMC_LIT21);
          fputs(MMC_STRINGDATA(tmpMeta9),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outHTCrToExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHTCrToExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addToCrAndEqLists(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _cr2, modelica_metatype _eq, modelica_metatype _inHTCrToCrEqLst)
{
  modelica_metatype _outHTCrToCrEqLst = NULL;
  modelica_metatype _cr_eq_lst = NULL;
  modelica_metatype _eqSolved = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHTCrToCrEqLst has no default value.
  // _cr_eq_lst has no default value.
  // _eqSolved has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inHTCrToCrEqLst;
    {
      modelica_metatype _HTCrToCrEqLst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _HTCrToCrEqLst has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          
          _HTCrToCrEqLst = tmp4_1;
          /* Pattern matching succeeded */
          _eqSolved = omc_BackendEquation_solveEquation(threadData, _eq, omc_Expression_crefExp(threadData, _cr2), mmc_mk_none());

          if(omc_BaseHashTable_hasKey(threadData, _cr1, _HTCrToCrEqLst))
          {
            _cr_eq_lst = omc_BaseHashTable_get(threadData, _cr1, _HTCrToCrEqLst);

            tmpMeta7 = mmc_mk_box2(0, _cr2, _eqSolved);
            tmpMeta6 = mmc_mk_cons(tmpMeta7, _cr_eq_lst);
            _cr_eq_lst = tmpMeta6;
          }
          else
          {
            tmpMeta9 = mmc_mk_box2(0, _cr2, _eqSolved);
            tmpMeta8 = mmc_mk_cons(tmpMeta9, MMC_REFSTRUCTLIT(mmc_nil));
            _cr_eq_lst = tmpMeta8;
          }
          tmpMeta10 = mmc_mk_box2(0, _cr1, _cr_eq_lst);
          tmpMeta1 = omc_BaseHashTable_add(threadData, tmpMeta10, _HTCrToCrEqLst);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT33),stdout);

          omc_BackendDump_printEquation(threadData, _eq);

          tmpMeta11 = stringAppend(_OMC_LIT34,omc_ComponentReference_debugPrintComponentRefTypeStr(threadData, _cr1));
          tmpMeta12 = stringAppend(tmpMeta11,_OMC_LIT21);
          fputs(MMC_STRINGDATA(tmpMeta12),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outHTCrToCrEqLst = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHTCrToCrEqLst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_findCrefs(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inTuple, modelica_boolean *out_cont, modelica_metatype *out_outTuple)
{
  modelica_metatype _outE1 = NULL;
  modelica_boolean _cont;
  modelica_metatype _outTuple = NULL;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outE1 has no default value.
  // _cont has no default value.
  // _outTuple has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inE1;
    tmp4_2 = _inTuple;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _cr_lst = NULL;
      modelica_integer _count;
      modelica_integer _paramCount;
      modelica_metatype _vars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _cr_lst has no default value.
      // _count has no default value.
      // _paramCount has no default value.
      // _vars 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;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _vars = tmpMeta6;
          _count = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(_count < ((modelica_integer) 0))) goto tmp3_end;
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box5(0, tmpMeta9, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta10;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          if (1 /* true */ != tmp18) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr_lst = tmpMeta11;
          _vars = tmpMeta12;
          _count = tmp14  /* pattern as ty=Integer */;
          _paramCount = tmp16  /* pattern as ty=Integer */;
          _cr = tmpMeta19;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((_count < ((modelica_integer) 2)) && (!omc_ComponentReferenceBasics_crefEqual(threadData, _cr, _OMC_LIT37)))) goto tmp3_end;
          omc_BackendVariable_getVar(threadData, _cr, _vars, NULL);
          tmpMeta20 = mmc_mk_cons(_cr, _cr_lst);
          tmpMeta21 = mmc_mk_box5(0, tmpMeta20, _vars, mmc_mk_integer(((modelica_integer) 1) + _count), mmc_mk_integer(_paramCount), mmc_mk_boolean(1 /* true */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = tmpMeta21;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp29 = mmc_unbox_integer(tmpMeta28);
          if (1 /* true */ != tmp29) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr_lst = tmpMeta22;
          _vars = tmpMeta23;
          _count = tmp25  /* pattern as ty=Integer */;
          _paramCount = tmp27  /* pattern as ty=Integer */;
          _cr = tmpMeta30;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((_count < ((modelica_integer) 2)) && (!omc_ComponentReferenceBasics_crefEqual(threadData, _cr, _OMC_LIT37)))) goto tmp3_end;
          tmpMeta31 = mmc_mk_box5(0, _cr_lst, _vars, mmc_mk_integer(_count), mmc_mk_integer(((modelica_integer) 1) + _paramCount), mmc_mk_boolean(1 /* true */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = tmpMeta31;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_integer tmp34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp34 = mmc_unbox_integer(tmpMeta33);
          if (1 /* true */ != tmp34) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          
          _vars = tmpMeta32;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta35 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta36 = mmc_mk_box5(0, tmpMeta35, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta36;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _vars = tmpMeta37;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta38 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta39 = mmc_mk_box5(0, tmpMeta38, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta39;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _vars = tmpMeta40;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta41 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta42 = mmc_mk_box5(0, tmpMeta41, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta42;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _vars = tmpMeta43;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta44 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta45 = mmc_mk_box5(0, tmpMeta44, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta45;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,14,4) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _vars = tmpMeta46;
          /* Pattern matching succeeded */
          tmpMeta47 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta48 = mmc_mk_box5(0, tmpMeta47, _vars, mmc_mk_integer(((modelica_integer) -1)), mmc_mk_integer(((modelica_integer) -1)), mmc_mk_boolean(0 /* false */));
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta48;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = _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:;
    }
  }
  _outE1 = tmpMeta[0+0];
  _cont = tmp1_c1;
  _outTuple = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_outTuple) { *out_outTuple = _outTuple; }
  return _outE1;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_findCrefs(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inTuple, modelica_metatype *out_cont, modelica_metatype *out_outTuple)
{
  modelica_boolean _cont;
  modelica_metatype _outE1 = NULL;
  _outE1 = omc_RemoveSimpleEquations_findCrefs(threadData, _inE1, _inTuple, &_cont, out_outTuple);
  /* skip box _outE1; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  /* skip box _outTuple; tuple<list<DAE.ComponentRef>, BackendDAE.Variables, #Integer, #Integer, #Boolean> */
  return _outE1;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_findSimpleEquations(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTuple, modelica_boolean _findAliases, modelica_metatype *out_outTuple)
{
  modelica_metatype _outEq = NULL;
  modelica_metatype _outTuple = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEq has no default value.
  // _outTuple has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inEq;
    tmp4_2 = _inTuple;
    {
      modelica_metatype _eq = NULL;
      modelica_metatype _eqSolved = NULL;
      modelica_metatype _HTCrToExp = NULL;
      modelica_metatype _HTCrToCrEqLst = NULL;
      modelica_metatype _cr_lst = NULL;
      modelica_metatype _eqList = NULL;
      modelica_metatype _simpleEqList = NULL;
      modelica_integer _count;
      modelica_integer _paramCount;
      modelica_metatype _cr = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _value = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _vars = NULL;
      modelica_boolean _keepEquation;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _eq has no default value.
      // _eqSolved has no default value.
      // _HTCrToExp has no default value.
      // _HTCrToCrEqLst has no default value.
      // _cr_lst has no default value.
      // _eqList has no default value.
      // _simpleEqList has no default value.
      // _count has no default value.
      // _paramCount has no default value.
      // _cr has no default value.
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _res has no default value.
      // _value has no default value.
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _vars has no default value.
      // _keepEquation 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 < 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_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_boolean tmp33;
          modelica_boolean tmp34;
          modelica_boolean tmp35;
          modelica_boolean tmp36;
          modelica_boolean tmp37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_boolean tmp40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_boolean tmp50;
          modelica_boolean tmp51;
          modelica_boolean tmp52;
          modelica_boolean tmp53;
          modelica_boolean tmp54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_boolean tmp57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_boolean tmp60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          _eq = tmp4_1;
          _vars = tmpMeta6;
          _HTCrToExp = tmpMeta7;
          _HTCrToCrEqLst = tmpMeta8;
          _eqList = tmpMeta9;
          _simpleEqList = tmpMeta10;
          /* Pattern matching succeeded */
          _res = omc_BackendEquation_getEquationRHS(threadData, _eq);

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta20 = mmc_mk_box5(0, tmpMeta19, _vars, mmc_mk_integer(((modelica_integer) 0)), mmc_mk_integer(((modelica_integer) 0)), mmc_mk_boolean(1 /* true */));
          omc_Expression_traverseExpTopDown(threadData, _res, boxvar_RemoveSimpleEquations_findCrefs, tmpMeta20, &tmpMeta11);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 3));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 4));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 5));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          if (1 /* true */ != tmp18) goto goto_2;
          _cr_lst = tmpMeta12;
          _count = tmp14  /* pattern as ty=Integer */;
          _paramCount = tmp16  /* pattern as ty=Integer */;

          _res = omc_BackendEquation_getEquationLHS(threadData, _eq);

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta27 = mmc_mk_box5(0, _cr_lst, _vars, mmc_mk_integer(_count), mmc_mk_integer(_paramCount), mmc_mk_boolean(1 /* true */));
          omc_Expression_traverseExpTopDown(threadData, _res, boxvar_RemoveSimpleEquations_findCrefs, tmpMeta27, &tmpMeta21);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 1));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 3));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 5));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          if (1 /* true */ != tmp26) goto goto_2;
          _cr_lst = tmpMeta22;
          _count = tmp24  /* pattern as ty=Integer */;

          _keepEquation = 1 /* true */;

          if((_count == ((modelica_integer) 1)))
          {
            if(omc_Flags_isSet(threadData, _OMC_LIT24))
            {
              tmpMeta28 = stringAppend(_OMC_LIT40,omc_BackendDump_equationString(threadData, _eq));
              tmpMeta29 = stringAppend(tmpMeta28,_OMC_LIT21);
              fputs(MMC_STRINGDATA(tmpMeta29),stdout);
            }

            /* Pattern-matching assignment */
            tmpMeta30 = _cr_lst;
            if (listEmpty(tmpMeta30)) goto goto_2;
            tmpMeta31 = MMC_CAR(tmpMeta30);
            tmpMeta32 = MMC_CDR(tmpMeta30);
            if (!listEmpty(tmpMeta32)) goto goto_2;
            _cr = tmpMeta31;

            /* Pattern-matching assignment */
            tmp33 = omc_BackendVariable_isState(threadData, _cr, _vars);
            if (0 /* false */ != tmp33) goto goto_2;

            /* Pattern-matching assignment */
            tmp34 = omc_BackendVariable_isClockedState(threadData, _cr, _vars);
            if (0 /* false */ != tmp34) goto goto_2;

            /* Pattern-matching assignment */
            tmp35 = omc_BackendVariable_isOutput(threadData, _cr, _vars);
            if (0 /* false */ != tmp35) goto goto_2;

            /* Pattern-matching assignment */
            tmp36 = omc_BackendVariable_isDiscrete(threadData, _cr, _vars);
            if (0 /* false */ != tmp36) goto goto_2;

            _exp1 = omc_Expression_crefExp(threadData, _cr);

            /* Pattern-matching assignment */
            tmp37 = omc_Types_isSimpleType(threadData, omc_Expression_typeof(threadData, _exp1));
            if (1 /* true */ != tmp37) goto goto_2;

            /* Pattern-matching assignment */
            tmpMeta38 = omc_BackendEquation_solveEquation(threadData, _eq, _exp1, mmc_mk_none());
            if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,0,4) == 0) goto goto_2;
            tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 3));
            _eqSolved = tmpMeta38;
            _res = tmpMeta39;

            /* Pattern-matching assignment */
            tmp40 = omc_RemoveSimpleEquations_isSimple(threadData, _res);
            if (1 /* true */ != tmp40) goto goto_2;

            if(omc_Flags_isSet(threadData, _OMC_LIT24))
            {
              tmpMeta41 = stringAppend(_OMC_LIT41,omc_BackendDump_equationString(threadData, _eq));
              tmpMeta42 = stringAppend(tmpMeta41,_OMC_LIT21);
              fputs(MMC_STRINGDATA(tmpMeta42),stdout);
            }

            _HTCrToExp = omc_RemoveSimpleEquations_addToCrToExp(threadData, _cr, _eqSolved, _HTCrToExp, _HTCrToCrEqLst);

            _keepEquation = 0 /* false */;
          }
          else
          {
            if(((_count == ((modelica_integer) 2)) && _findAliases))
            {
              if(omc_Flags_isSet(threadData, _OMC_LIT24))
              {
                tmpMeta43 = stringAppend(_OMC_LIT38,omc_BackendDump_equationString(threadData, _eq));
                tmpMeta44 = stringAppend(tmpMeta43,_OMC_LIT21);
                fputs(MMC_STRINGDATA(tmpMeta44),stdout);
              }

              /* Pattern-matching assignment */
              tmpMeta45 = _cr_lst;
              if (listEmpty(tmpMeta45)) goto goto_2;
              tmpMeta46 = MMC_CAR(tmpMeta45);
              tmpMeta47 = MMC_CDR(tmpMeta45);
              if (listEmpty(tmpMeta47)) goto goto_2;
              tmpMeta48 = MMC_CAR(tmpMeta47);
              tmpMeta49 = MMC_CDR(tmpMeta47);
              if (!listEmpty(tmpMeta49)) goto goto_2;
              _cr2 = tmpMeta46;
              _cr1 = tmpMeta48;

              /* Pattern-matching assignment */
              tmp50 = (omc_BackendVariable_isState(threadData, _cr1, _vars) || omc_BackendVariable_isState(threadData, _cr2, _vars));
              if (0 /* false */ != tmp50) goto goto_2;

              /* Pattern-matching assignment */
              tmp51 = (omc_BackendVariable_isClockedState(threadData, _cr1, _vars) || omc_BackendVariable_isClockedState(threadData, _cr2, _vars));
              if (0 /* false */ != tmp51) goto goto_2;

              /* Pattern-matching assignment */
              tmp52 = (omc_BackendVariable_isOutput(threadData, _cr1, _vars) || omc_BackendVariable_isOutput(threadData, _cr2, _vars));
              if (0 /* false */ != tmp52) goto goto_2;

              /* Pattern-matching assignment */
              tmp53 = (omc_BackendVariable_isDiscrete(threadData, _cr1, _vars) || omc_BackendVariable_isDiscrete(threadData, _cr2, _vars));
              if (0 /* false */ != tmp53) goto goto_2;

              _exp1 = omc_Expression_crefExp(threadData, _cr1);

              /* Pattern-matching assignment */
              tmp54 = omc_Types_isSimpleType(threadData, omc_Expression_typeof(threadData, _exp1));
              if (1 /* true */ != tmp54) goto goto_2;

              _exp2 = omc_Expression_crefExp(threadData, _cr2);

              /* Pattern-matching assignment */
              tmpMeta55 = omc_BackendEquation_solveEquation(threadData, _eq, _exp2, mmc_mk_none());
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,0,4) == 0) goto goto_2;
              tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 3));
              _res = tmpMeta56;

              /* Pattern-matching assignment */
              tmp57 = omc_RemoveSimpleEquations_isSimple(threadData, _res);
              if (1 /* true */ != tmp57) goto goto_2;

              /* Pattern-matching assignment */
              tmpMeta58 = omc_BackendEquation_solveEquation(threadData, _eq, _exp1, mmc_mk_none());
              if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,0,4) == 0) goto goto_2;
              tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 3));
              _res = tmpMeta59;

              /* Pattern-matching assignment */
              tmp60 = omc_RemoveSimpleEquations_isSimple(threadData, _res);
              if (1 /* true */ != tmp60) goto goto_2;

              if(omc_Flags_isSet(threadData, _OMC_LIT24))
              {
                tmpMeta61 = stringAppend(_OMC_LIT39,omc_BackendDump_equationString(threadData, _eq));
                tmpMeta62 = stringAppend(tmpMeta61,_OMC_LIT21);
                fputs(MMC_STRINGDATA(tmpMeta62),stdout);
              }

              _HTCrToCrEqLst = omc_RemoveSimpleEquations_addToCrAndEqLists(threadData, _cr2, _cr1, _inEq, _HTCrToCrEqLst);

              _HTCrToCrEqLst = omc_RemoveSimpleEquations_addToCrAndEqLists(threadData, _cr1, _cr2, _inEq, _HTCrToCrEqLst);

              if(omc_BaseHashTable_hasKey(threadData, _cr2, _HTCrToExp))
              {
                _value = omc_BaseHashTable_get(threadData, _cr2, _HTCrToExp);

                /* Pattern-matching assignment */
                tmpMeta63 = omc_BackendEquation_solveEquation(threadData, _eq, omc_Expression_crefExp(threadData, _cr1), mmc_mk_none());
                if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,0,4) == 0) goto goto_2;
                tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 3));
                tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 4));
                tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 5));
                _res = tmpMeta64;
                _source = tmpMeta65;
                _eqAttr = tmpMeta66;

                _res = omc_Expression_replaceExp(threadData, _res, omc_Expression_crefExp(threadData, _cr2), _value, NULL);

                _res = omc_ExpressionSimplify_simplify(threadData, _res, NULL);

                tmpMeta67 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_Expression_crefExp(threadData, _cr1), _res, _source, _eqAttr);
                _HTCrToExp = omc_RemoveSimpleEquations_addToCrToExp(threadData, _cr1, tmpMeta67, _HTCrToExp, _HTCrToCrEqLst);
              }
              else
              {
                if(omc_BaseHashTable_hasKey(threadData, _cr1, _HTCrToExp))
                {
                  _value = omc_BaseHashTable_get(threadData, _cr1, _HTCrToExp);

                  /* Pattern-matching assignment */
                  tmpMeta68 = omc_BackendEquation_solveEquation(threadData, _eq, omc_Expression_crefExp(threadData, _cr2), mmc_mk_none());
                  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta68,0,4) == 0) goto goto_2;
                  tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 3));
                  tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 4));
                  tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta68), 5));
                  _res = tmpMeta69;
                  _source = tmpMeta70;
                  _eqAttr = tmpMeta71;

                  _res = omc_Expression_replaceExp(threadData, _res, omc_Expression_crefExp(threadData, _cr1), _value, NULL);

                  _res = omc_ExpressionSimplify_simplify(threadData, _res, NULL);

                  tmpMeta72 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_Expression_crefExp(threadData, _cr2), _res, _source, _eqAttr);
                  _HTCrToExp = omc_RemoveSimpleEquations_addToCrToExp(threadData, _cr2, tmpMeta72, _HTCrToExp, _HTCrToCrEqLst);
                }
              }

              _keepEquation = 0 /* false */;
            }
          }

          if(_keepEquation)
          {
            tmpMeta73 = mmc_mk_cons(_inEq, _eqList);
            _eqList = tmpMeta73;
          }
          else
          {
            tmpMeta74 = mmc_mk_cons(_inEq, _simpleEqList);
            _simpleEqList = tmpMeta74;
          }
          tmpMeta75 = mmc_mk_box5(0, _vars, _HTCrToExp, _HTCrToCrEqLst, _eqList, _simpleEqList);
          tmpMeta[0+0] = _inEq;
          tmpMeta[0+1] = tmpMeta75;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          _vars = tmpMeta76;
          _HTCrToExp = tmpMeta77;
          _HTCrToCrEqLst = tmpMeta78;
          _eqList = tmpMeta79;
          _simpleEqList = tmpMeta80;
          /* Pattern matching succeeded */
          tmpMeta81 = mmc_mk_cons(_inEq, _eqList);
          _eqList = tmpMeta81;
          tmpMeta82 = mmc_mk_box5(0, _vars, _HTCrToExp, _HTCrToCrEqLst, _eqList, _simpleEqList);
          tmpMeta[0+0] = _inEq;
          tmpMeta[0+1] = tmpMeta82;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT42),stdout);
          tmpMeta[0+0] = _inEq;
          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 < 3) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outEq = tmpMeta[0+0];
  _outTuple = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTuple) { *out_outTuple = _outTuple; }
  return _outEq;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_findSimpleEquations(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTuple, modelica_metatype _findAliases, modelica_metatype *out_outTuple)
{
  modelica_integer tmp1;
  modelica_metatype _outEq = NULL;
  tmp1 = mmc_unbox_integer(_findAliases);
  _outEq = omc_RemoveSimpleEquations_findSimpleEquations(threadData, _inEq, _inTuple, tmp1, out_outTuple);
  /* skip box _outEq; BackendDAE.Equation */
  /* skip box _outTuple; tuple<BackendDAE.Variables, tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<tuple<DAE.ComponentRef, DAE.Exp>>>>, #Integer, tuple<.HashTableCrToExp.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashTableCrToExp.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashTableCrToExp.FuncCrefStr<function>(DAE.ComponentRef cr) => String, .HashTableCrToExp.FuncExpStr<function>(DAE.Exp exp) => String>>, tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<tuple<DAE.ComponentRef, list<tuple<DAE.ComponentRef, BackendDAE.Equation>>>>>>, #Integer, tuple<.HashTableCrToCrEqLst.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashTableCrToCrEqLst.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashTableCrToCrEqLst.FuncCrefStr<function>(DAE.ComponentRef cr) => String, .HashTableCrToCrEqLst.FuncExpStr<function>(list<tuple<DAE.ComponentRef, BackendDAE.Equation>> exp) => String>>, list<BackendDAE.Equation>, list<BackendDAE.Equation>> */
  return _outEq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeStateDerInfo(threadData_t *threadData, modelica_metatype _inVarList)
{
  modelica_metatype _vars = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _vars has no default value.
  {
    modelica_metatype __omcQ_24tmpVar1;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar0;
    modelica_integer tmp4;
    modelica_metatype _var_loopVar = 0;
    modelica_metatype _var;
    _var_loopVar = _inVarList;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar1 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar1;
    while(1) {
      tmp4 = 1;
      if (!listEmpty(_var_loopVar)) {
        _var = MMC_CAR(_var_loopVar);
        _var_loopVar = MMC_CDR(_var_loopVar);
        tmp4--;
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar0 = (omc_BackendVariable_isStateVar(threadData, _var)?omc_BackendVariable_setStateDerivative(threadData, _var, mmc_mk_none()):_var);
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar0,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar1;
  }
  _vars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _vars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_insertReplacementsInEquations(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inHTCrToExp, modelica_boolean *out_cont, modelica_metatype *out_outHTCrToExp)
{
  modelica_metatype _outE1 = NULL;
  modelica_boolean _cont;
  modelica_metatype _outHTCrToExp = NULL;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outE1 has no default value.
  // _cont has no default value.
  // _outHTCrToExp has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inE1;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _value = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _value has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          if(omc_BaseHashTable_hasKey(threadData, _cr, _inHTCrToExp))
          {
            _value = omc_BaseHashTable_get(threadData, _cr, _inHTCrToExp);
          }
          else
          {
            _value = _inE1;
          }
          tmpMeta[0+0] = _value;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = _inHTCrToExp;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inE1;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = _inHTCrToExp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outE1 = tmpMeta[0+0];
  _cont = tmp1_c1;
  _outHTCrToExp = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_outHTCrToExp) { *out_outHTCrToExp = _outHTCrToExp; }
  return _outE1;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_insertReplacementsInEquations(threadData_t *threadData, modelica_metatype _inE1, modelica_metatype _inHTCrToExp, modelica_metatype *out_cont, modelica_metatype *out_outHTCrToExp)
{
  modelica_boolean _cont;
  modelica_metatype _outE1 = NULL;
  _outE1 = omc_RemoveSimpleEquations_insertReplacementsInEquations(threadData, _inE1, _inHTCrToExp, &_cont, out_outHTCrToExp);
  /* skip box _outE1; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  /* skip box _outHTCrToExp; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<tuple<DAE.ComponentRef, DAE.Exp>>>>, #Integer, tuple<.HashTableCrToExp.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashTableCrToExp.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashTableCrToExp.FuncCrefStr<function>(DAE.ComponentRef cr) => String, .HashTableCrToExp.FuncExpStr<function>(DAE.Exp exp) => String>> */
  return _outE1;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseExpTopDown(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inHTCrToExp, modelica_metatype *out_outHTCrToExp)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outHTCrToExp = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  _outHTCrToExp = _inHTCrToExp;
  _outExp = omc_Expression_traverseExpTopDown(threadData, _inExp, boxvar_RemoveSimpleEquations_insertReplacementsInEquations, _inHTCrToExp, NULL);

  _outExp = omc_ExpressionSimplify_simplify(threadData, _outExp, NULL);
  _return: OMC_LABEL_UNUSED
  if (out_outHTCrToExp) { *out_outHTCrToExp = _outHTCrToExp; }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addVarReplacements(threadData_t *threadData, modelica_metatype _cr_exp_lst, modelica_metatype _inRepl)
{
  modelica_metatype _outRepl = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outRepl = _inRepl;
  // _cr has no default value.
  // _e has no default value.
  {
    modelica_metatype _cr_exp;
    for (tmpMeta1 = _cr_exp_lst; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _cr_exp = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _cr_exp;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _cr = tmpMeta3;
      _e = tmpMeta4;

      _outRepl = omc_BackendVarTransform_addReplacement(threadData, _outRepl, _cr, _e, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator));
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outRepl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_moveVars(threadData_t *threadData, modelica_metatype _cr_exp_lst, modelica_metatype _inAliasVars, modelica_metatype _inVars, modelica_metatype *out_outVars)
{
  modelica_metatype _outAliasVars = NULL;
  modelica_metatype _outVars = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _v = NULL;
  modelica_integer _i;
  modelica_metatype _ops = NULL;
  modelica_boolean _bs;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta11;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outAliasVars = _inAliasVars;
  _outVars = _inVars;
  // _cr has no default value.
  // _e has no default value.
  // _v has no default value.
  // _i has no default value.
  // _ops has no default value.
  // _bs has no default value.
  {
    modelica_metatype _cr_exp;
    for (tmpMeta1 = _cr_exp_lst; !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
    {
      _cr_exp = MMC_CAR(tmpMeta1);
      /* Pattern-matching assignment */
      tmpMeta2 = _cr_exp;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      _cr = tmpMeta3;
      _e = tmpMeta4;

      { /* matchcontinue expression */
        {
          volatile mmc_switch_type tmp7;
          int tmp8;
          tmp7 = 0;
          MMC_TRY_INTERNAL(mmc_jumper)
          tmp6_top:
          threadData->mmc_jumper = &new_mmc_jumper;
          for (; tmp7 < 2; tmp7++) {
            switch (MMC_SWITCH_CAST(tmp7)) {
            case 0: {
              modelica_metatype tmpMeta9;
              modelica_metatype tmpMeta10;
              /* Pattern matching succeeded */
              _v = omc_BackendVariable_getVarSingle(threadData, _cr, _outVars ,&_i);

              _v = omc_BackendVariable_setBindExp(threadData, _v, mmc_mk_some(_e));

              _ops = omc_ElementSource_getSymbolicTransformations(threadData, _OMC_LIT15);

              tmpMeta10 = mmc_mk_box3(10, &DAE_SymbolicOperation_SOLVED__desc, _cr, _e);
              tmpMeta9 = mmc_mk_cons(tmpMeta10, _ops);
              _v = omc_BackendVariable_mergeVariableOperations(threadData, _v, tmpMeta9);

              _bs = omc_BackendVariable_isStateVar(threadData, _v);

              _v = (_bs?omc_BackendVariable_setVarKind(threadData, _v, _OMC_LIT43):_v);

              _outVars = omc_BackendVariable_removeVar(threadData, _i, _outVars, NULL);

              _outAliasVars = omc_BackendVariable_addVar(threadData, _v, _outAliasVars);
              goto tmp6_done;
            }
            case 1: {
              /* Pattern matching succeeded */
              _outAliasVars = _outAliasVars;

              _outVars = _outVars;
              goto tmp6_done;
            }
            }
            goto tmp6_end;
            tmp6_end: ;
          }
          goto goto_5;
          tmp6_done:
          (void)tmp7;
          MMC_RESTORE_INTERNAL(mmc_jumper);
          goto tmp6_done2;
          goto_5:;
          MMC_CATCH_INTERNAL(mmc_jumper);
          if (++tmp7 < 2) {
            goto tmp6_top;
          }
          MMC_THROW_INTERNAL();
          tmp6_done2:;
        }
      }
      ;
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outVars) { *out_outVars = _outVars; }
  return _outAliasVars;
}

static modelica_metatype closure0_RemoveSimpleEquations_findSimpleEquations(threadData_t *thData, modelica_metatype closure, modelica_metatype inEq, modelica_metatype inTuple, modelica_metatype tmp12)
{
  modelica_metatype findAliases = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_RemoveSimpleEquations_findSimpleEquations(thData, inEq, inTuple, findAliases, tmp12);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_eliminateTrivialEquations(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_boolean _findAliases, modelica_metatype *out_outShared)
{
  modelica_metatype _outSystem = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSystem has no default value.
  // _outShared has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inSystem;
    tmp4_2 = _inShared;
    {
      modelica_metatype _orderedVars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _orderedEqs = NULL;
      modelica_metatype _inieqns = NULL;
      modelica_metatype _varList = NULL;
      modelica_metatype _eqList = NULL;
      modelica_metatype _initEqList = NULL;
      modelica_metatype _remEqList = NULL;
      modelica_metatype _simpleEqList = NULL;
      modelica_metatype _HTCrToExp = NULL;
      modelica_metatype _HTCrToCrEqLst = NULL;
      modelica_metatype _tplExp = NULL;
      modelica_metatype _tplCrEqLst = NULL;
      modelica_integer _countAliasEquations;
      modelica_integer _countSimpleEquations;
      modelica_integer _size;
      modelica_metatype _syst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _eventInfo = NULL;
      modelica_metatype _aliasVars = NULL;
      modelica_metatype _varlst = NULL;
      modelica_metatype _repl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _orderedVars has no default value.
      // _globalKnownVars has no default value.
      // _orderedEqs has no default value.
      // _inieqns has no default value.
      // _varList has no default value.
      // _eqList has no default value.
      // _initEqList has no default value.
      // _remEqList has no default value.
      // _simpleEqList has no default value.
      // _HTCrToExp has no default value.
      // _HTCrToCrEqLst has no default value.
      // _tplExp has no default value.
      // _tplCrEqLst has no default value.
      // _countAliasEquations has no default value.
      // _countSimpleEquations has no default value.
      // _size has no default value.
      // _syst has no default value.
      // _shared has no default value.
      // _eventInfo has no default value.
      // _aliasVars has no default value.
      // _varlst has no default value.
      // _repl has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          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_2), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 13));
          
          _syst = tmp4_1;
          _orderedVars = tmpMeta6;
          _orderedEqs = tmpMeta7;
          _shared = tmp4_2;
          _globalKnownVars = tmpMeta8;
          _aliasVars = tmpMeta9;
          _inieqns = tmpMeta10;
          _eventInfo = tmpMeta11;
          /* Pattern matching succeeded */
          _size = omc_BackendVariable_varsSize(threadData, _orderedVars);

          _size = modelica_integer_max((modelica_integer)(((modelica_integer) 2053)),(modelica_integer)(((modelica_integer)floor((0.7) * (((modelica_real)_size))))));

          _HTCrToExp = omc_HashTableCrToExp_emptyHashTableSized(threadData, _size);

          _HTCrToCrEqLst = omc_HashTableCrToCrEqLst_emptyHashTableSized(threadData, _size);

          _repl = omc_BackendVarTransform_emptyReplacementsSized(threadData, _size);

          /* Pattern-matching assignment */
          tmpMeta13 = mmc_mk_box1(0, mmc_mk_boolean(_findAliases));
          tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta16 = mmc_mk_box5(0, _orderedVars, _HTCrToExp, _HTCrToCrEqLst, tmpMeta14, tmpMeta15);
          tmpMeta17 = omc_BackendEquation_traverseEquationArray(threadData, _orderedEqs, (modelica_fnptr) mmc_mk_box2(0,closure0_RemoveSimpleEquations_findSimpleEquations,tmpMeta13), tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 3));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 4));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 5));
          _HTCrToExp = tmpMeta18;
          _HTCrToCrEqLst = tmpMeta19;
          _eqList = tmpMeta20;
          _simpleEqList = tmpMeta21;

          _tplExp = omc_BaseHashTable_hashTableList(threadData, _HTCrToExp);

          _tplCrEqLst = omc_BaseHashTable_hashTableList(threadData, _HTCrToCrEqLst);

          _HTCrToExp = omc_RemoveSimpleEquations_addRestCrefs(threadData, _tplCrEqLst, _HTCrToExp, _HTCrToCrEqLst);

          _tplExp = omc_BaseHashTable_hashTableList(threadData, _HTCrToExp);

          _aliasVars = omc_RemoveSimpleEquations_moveVars(threadData, _tplExp, _aliasVars, _orderedVars ,&_orderedVars);

          _varList = omc_BackendVariable_varList(threadData, _orderedVars);

          _varList = omc_RemoveSimpleEquations_removeStateDerInfo(threadData, _varList);

          _orderedVars = omc_BackendVariable_listVar1(threadData, _varList);

          _eqList = omc_BackendEquation_traverseExpsOfEquationList(threadData, _eqList, boxvar_RemoveSimpleEquations_traverseExpTopDown, _HTCrToExp, NULL);

          _orderedEqs = omc_BackendEquation_listEquation(threadData, _eqList);

          _initEqList = omc_BackendEquation_equationList(threadData, _inieqns);

          _initEqList = omc_BackendEquation_traverseExpsOfEquationList(threadData, _initEqList, boxvar_RemoveSimpleEquations_traverseExpTopDown, _HTCrToExp, NULL);

          _inieqns = omc_BackendEquation_listEquation(threadData, _initEqList);

          _remEqList = omc_BackendEquation_equationList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 10))));

          _remEqList = omc_BackendEquation_traverseExpsOfEquationList(threadData, _remEqList, boxvar_RemoveSimpleEquations_traverseExpTopDown, _HTCrToExp, NULL);

          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[10] = omc_BackendEquation_listEquation(threadData, omc_List_select(threadData, _remEqList, boxvar_BackendEquation_assertWithCondTrue));
          _syst = tmpMeta22;

          _remEqList = omc_BackendEquation_equationList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 7))));

          _remEqList = omc_BackendEquation_traverseExpsOfEquationList(threadData, _remEqList, boxvar_RemoveSimpleEquations_traverseExpTopDown, _HTCrToExp, NULL);

          tmpMeta23 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta23), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta23))[7] = omc_BackendEquation_listEquation(threadData, omc_List_select(threadData, _remEqList, boxvar_BackendEquation_assertWithCondTrue));
          _shared = tmpMeta23;

          _repl = omc_RemoveSimpleEquations_addVarReplacements(threadData, _tplExp, _repl);

          /* Pattern-matching tuple assignment */
          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta27 = mmc_mk_box2(0, _repl, tmpMeta26);
          tmpMeta28 = omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _aliasVars, boxvar_RemoveSimpleEquations_replaceAliasVarTraverser, tmpMeta27, &tmpMeta24);
          _aliasVars = tmpMeta28;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
          _varlst = tmpMeta25;

          _aliasVars = omc_List_fold(threadData, _varlst, boxvar_RemoveSimpleEquations_fixAliasConstBindings, _aliasVars);

          _globalKnownVars = omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _globalKnownVars, boxvar_RemoveSimpleEquations_replaceVarTraverser, _repl, NULL);

          if(omc_Flags_isSet(threadData, _OMC_LIT51))
          {
            _tplExp = omc_BaseHashTable_hashTableList(threadData, _HTCrToExp);

            _countAliasEquations = listLength(_tplExp);

            _countSimpleEquations = listLength(_simpleEqList);

            tmpMeta29 = stringAppend(_OMC_LIT44,intString(omc_BackendVariable_varsSize(threadData, _orderedVars)));
            tmpMeta30 = stringAppend(tmpMeta29,_OMC_LIT21);
            fputs(MMC_STRINGDATA(tmpMeta30),stdout);

            tmpMeta31 = stringAppend(_OMC_LIT45,intString(omc_BackendEquation_equationLstSize(threadData, _eqList)));
            tmpMeta32 = stringAppend(tmpMeta31,_OMC_LIT21);
            fputs(MMC_STRINGDATA(tmpMeta32),stdout);

            tmpMeta33 = stringAppend(_OMC_LIT46,intString(_countAliasEquations));
            tmpMeta34 = stringAppend(tmpMeta33,_OMC_LIT21);
            fputs(MMC_STRINGDATA(tmpMeta34),stdout);

            tmpMeta35 = stringAppend(_OMC_LIT47,intString(_countSimpleEquations));
            tmpMeta36 = stringAppend(tmpMeta35,_OMC_LIT21);
            fputs(MMC_STRINGDATA(tmpMeta36),stdout);

            fputs(MMC_STRINGDATA(_OMC_LIT48),stdout);

            omc_BaseHashTable_dumpHashTable(threadData, _HTCrToExp);
          }

          tmpMeta37 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta37), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta37))[2] = _orderedVars;
          _syst = tmpMeta37;

          tmpMeta38 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta38), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta38))[3] = _orderedEqs;
          _syst = tmpMeta38;

          tmpMeta39 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta39), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta39))[13] = _eventInfo;
          _shared = tmpMeta39;

          tmpMeta40 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta40), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta40))[2] = _globalKnownVars;
          _shared = tmpMeta40;

          tmpMeta41 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta41), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta41))[5] = _aliasVars;
          _shared = tmpMeta41;

          tmpMeta42 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta42), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta42))[6] = _inieqns;
          _shared = tmpMeta42;
          tmpMeta[0+0] = omc_BackendDAEUtil_clearEqSyst(threadData, _syst);
          tmpMeta[0+1] = _shared;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inSystem;
          tmpMeta[0+1] = _inShared;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outSystem = tmpMeta[0+0];
  _outShared = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  return _outSystem;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_eliminateTrivialEquations(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _findAliases, modelica_metatype *out_outShared)
{
  modelica_integer tmp1;
  modelica_metatype _outSystem = NULL;
  tmp1 = mmc_unbox_integer(_findAliases);
  _outSystem = omc_RemoveSimpleEquations_eliminateTrivialEquations(threadData, _inSystem, _inShared, tmp1, out_outShared);
  /* skip box _outSystem; BackendDAE.EqSystem */
  /* skip box _outShared; BackendDAE.Shared */
  return _outSystem;
}

static modelica_metatype closure1_RemoveSimpleEquations_eliminateTrivialEquations(threadData_t *thData, modelica_metatype closure, modelica_metatype inSystem, modelica_metatype inShared, modelica_metatype tmp1)
{
  modelica_metatype findAliases = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_RemoveSimpleEquations_eliminateTrivialEquations(thData, inSystem, inShared, findAliases, tmp1);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_performAliasEliminationBB(threadData_t *threadData, modelica_metatype _inDAE, modelica_boolean _findAliases)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  tmpMeta2 = mmc_mk_box1(0, mmc_mk_boolean(_findAliases));
  _outDAE = omc_BackendDAEUtil_mapEqSystem(threadData, _inDAE, (modelica_fnptr) mmc_mk_box2(0,closure1_RemoveSimpleEquations_eliminateTrivialEquations,tmpMeta2));

  _outDAE = omc_BackendDAEUtil_mapEqSystem(threadData, _outDAE, boxvar_RemoveSimpleEquations_getAliasAttributes);
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_performAliasEliminationBB(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _findAliases)
{
  modelica_integer tmp1;
  modelica_metatype _outDAE = NULL;
  tmp1 = mmc_unbox_integer(_findAliases);
  _outDAE = omc_RemoveSimpleEquations_performAliasEliminationBB(threadData, _inDAE, tmp1);
  /* skip box _outDAE; BackendDAE.BackendDAE */
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_negateExpression(threadData_t *threadData, modelica_boolean _negationFlag, modelica_metatype _inExp, modelica_metatype _inAlternative, modelica_string _message)
{
  modelica_metatype _outExpression = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExpression has no default value.
  { /* match expression */
    modelica_boolean tmp4_1;
    tmp4_1 = _negationFlag;
    {
      modelica_metatype _negatedExp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _negatedExp has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          /* Pattern matching succeeded */
          _negatedExp = omc_Expression_negate(threadData, _inExp);

          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            tmpMeta6 = stringAppend(_OMC_LIT53,_message);
            tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT54);
            omc_BackendDump_debugStrExpStr(threadData, _OMC_LIT52, _inExp, tmpMeta7);
          }
          tmpMeta1 = _negatedExp;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            tmpMeta8 = stringAppend(_OMC_LIT53,_message);
            tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT54);
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT55, _inExp, _OMC_LIT56, _inAlternative, tmpMeta9);
          }
          tmpMeta1 = _inAlternative;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outExpression = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outExpression;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_negateExpression(threadData_t *threadData, modelica_metatype _negationFlag, modelica_metatype _inExp, modelica_metatype _inAlternative, modelica_metatype _message)
{
  modelica_integer tmp1;
  modelica_metatype _outExpression = NULL;
  tmp1 = mmc_unbox_integer(_negationFlag);
  _outExpression = omc_RemoveSimpleEquations_negateExpression(threadData, tmp1, _inExp, _inAlternative, _message);
  /* skip box _outExpression; DAE.Exp */
  return _outExpression;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseCrefUnreplaceable(threadData_t *threadData, modelica_metatype _inCref, modelica_metatype _preCref, modelica_metatype _iUnreplaceable)
{
  modelica_metatype _oUnreplaceable = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oUnreplaceable has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inCref;
    tmp4_2 = _preCref;
    {
      modelica_string _name = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _pcr = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _subs = NULL;
      modelica_metatype _unReplaceable = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _name has no default value.
      // _cr has no default value.
      // _pcr has no default value.
      // _ty has no default value.
      // _subs has no default value.
      // _unReplaceable has no default value.
      // _b 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_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_boolean tmp14;
          modelica_metatype tmpMeta15;
          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));
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          _name = tmpMeta6;
          _ty = tmpMeta7;
          _subs = tmpMeta8;
          _cr = tmpMeta9;
          _pcr = tmpMeta10;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          omc_Expression_traverseExpTopDownSubs(threadData, _subs, boxvar_Expression_traversingComponentRefPresent, mmc_mk_boolean(0 /* false */), &tmpMeta11);
          tmp12 = mmc_unbox_integer(tmpMeta11);
          _b = tmp12  /* pattern as ty=Boolean */;

          tmp14 = (modelica_boolean)_b;
          if(tmp14)
          {
            tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta15 = omc_ComponentReference_crefPrependIdent(threadData, _pcr, _name, tmpMeta13, _ty);
          }
          else
          {
            tmpMeta15 = _pcr;
          }
          _pcr = tmpMeta15;

          _unReplaceable = (_b?omc_BaseHashSet_add(threadData, _pcr, _iUnreplaceable):_iUnreplaceable);

          _pcr = omc_ComponentReference_crefPrependIdent(threadData, _pcr, _name, _subs, _ty);
          /* Tail recursive call */
          _inCref = _cr;
          _preCref = mmc_mk_some(_pcr);
          _iUnreplaceable = _unReplaceable;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 1: {
          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_boolean tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,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));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          if (!optionNone(tmp4_2)) goto tmp3_end;
          _name = tmpMeta16;
          _ty = tmpMeta17;
          _subs = tmpMeta18;
          _cr = tmpMeta19;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          omc_Expression_traverseExpTopDownSubs(threadData, _subs, boxvar_Expression_traversingComponentRefPresent, mmc_mk_boolean(0 /* false */), &tmpMeta20);
          tmp21 = mmc_unbox_integer(tmpMeta20);
          _b = tmp21  /* pattern as ty=Boolean */;

          tmp24 = (modelica_boolean)_b;
          if(tmp24)
          {
            tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta23 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _name, _ty, tmpMeta22);
            tmpMeta25 = omc_BaseHashSet_add(threadData, tmpMeta23, _iUnreplaceable);
          }
          else
          {
            tmpMeta25 = _iUnreplaceable;
          }
          _unReplaceable = tmpMeta25;
          tmpMeta26 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _name, _ty, _subs);
          /* Tail recursive call */
          _inCref = _cr;
          _preCref = mmc_mk_some(tmpMeta26);
          _iUnreplaceable = _unReplaceable;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          modelica_metatype tmpMeta33;
          modelica_boolean tmp34;
          modelica_metatype tmpMeta35;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,3) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          _name = tmpMeta27;
          _ty = tmpMeta28;
          _subs = tmpMeta29;
          _pcr = tmpMeta30;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          omc_Expression_traverseExpTopDownSubs(threadData, _subs, boxvar_Expression_traversingComponentRefPresent, mmc_mk_boolean(0 /* false */), &tmpMeta31);
          tmp32 = mmc_unbox_integer(tmpMeta31);
          _b = tmp32  /* pattern as ty=Boolean */;
          tmp34 = (modelica_boolean)_b;
          if(tmp34)
          {
            tmpMeta33 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta35 = omc_BaseHashSet_add(threadData, omc_ComponentReference_crefPrependIdent(threadData, _pcr, _name, tmpMeta33, _ty), _iUnreplaceable);
          }
          else
          {
            tmpMeta35 = _iUnreplaceable;
          }
          tmpMeta1 = tmpMeta35;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_integer tmp39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_boolean tmp42;
          modelica_metatype tmpMeta43;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,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));
          if (!optionNone(tmp4_2)) goto tmp3_end;
          _name = tmpMeta36;
          _ty = tmpMeta37;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          omc_Expression_traverseExpTopDownCrefHelper(threadData, _inCref, boxvar_Expression_traversingComponentRefPresent, mmc_mk_boolean(0 /* false */), &tmpMeta38);
          tmp39 = mmc_unbox_integer(tmpMeta38);
          _b = tmp39  /* pattern as ty=Boolean */;
          tmp42 = (modelica_boolean)_b;
          if(tmp42)
          {
            tmpMeta40 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta41 = mmc_mk_box4(4, &DAE_ComponentRef_CREF__IDENT__desc, _name, _ty, tmpMeta40);
            tmpMeta43 = omc_BaseHashSet_add(threadData, tmpMeta41, _iUnreplaceable);
          }
          else
          {
            tmpMeta43 = _iUnreplaceable;
          }
          tmpMeta1 = tmpMeta43;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iUnreplaceable;
          goto tmp3_done;
        }
        case 5: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,0) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iUnreplaceable;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oUnreplaceable = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverserExpUnreplaceable(threadData_t *threadData, modelica_metatype _e, modelica_metatype _unReplaceable, modelica_metatype *out_outHt)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _outHt = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outHt has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _e;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _explst = NULL;
      modelica_metatype _crlst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _explst has no default value.
      // _crlst has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _outHt = omc_RemoveSimpleEquations_traverseCrefUnreplaceable(threadData, _cr, mmc_mk_none(), _unReplaceable);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _outHt;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          if (3 != MMC_STRLEN(tmpMeta8) || strcmp(MMC_STRINGDATA(_OMC_LIT57), MMC_STRINGDATA(tmpMeta8)) != 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _explst = tmpMeta9;
          /* Pattern matching succeeded */
          _crlst = omc_List_flatten(threadData, omc_List_map(threadData, _explst, boxvar_Expression_extractCrefsFromExp));

          _crlst = omc_List_map(threadData, _crlst, boxvar_ComponentReferenceBasics_crefStripLastSubs);

          _outHt = omc_List_fold(threadData, _crlst, boxvar_BaseHashSet_add, _unReplaceable);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _outHt;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _unReplaceable;
          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:;
    }
  }
  _outExp = tmpMeta[0+0];
  _outHt = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outHt) { *out_outHt = _outHt; }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenOps(threadData_t *threadData, modelica_metatype _inWhenOps, modelica_metatype _iHs)
{
  modelica_metatype _oHs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oHs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWhenOps;
    {
      modelica_metatype _left = NULL;
      modelica_metatype _crefLst = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _hs = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _left has no default value.
      // _crefLst has no default value.
      // _e has no default value.
      // _rest has no default value.
      // _hs 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;
          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));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,6,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          
          _left = tmpMeta9;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _left = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _left);

          _hs = omc_BaseHashSet_add(threadData, _left, _iHs);
          /* Tail recursive call */
          _inWhenOps = _rest;
          _iHs = _hs;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,0,3) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _e = tmpMeta12;
          _rest = tmpMeta11;
          /* Pattern matching succeeded */
          _crefLst = omc_Expression_getAllCrefs(threadData, _e);

          _hs = _iHs;

          {
            modelica_metatype _left;
            for (tmpMeta13 = _crefLst; !listEmpty(tmpMeta13); tmpMeta13=MMC_CDR(tmpMeta13))
            {
              _left = MMC_CAR(tmpMeta13);
              _left = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _left);

              _hs = omc_BaseHashSet_add(threadData, _left, _hs);
            }
          }
          /* Tail recursive call */
          _inWhenOps = _rest;
          _iHs = _hs;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iHs;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oHs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oHs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhen(threadData_t *threadData, modelica_metatype _inWEqn, modelica_metatype _iHs)
{
  modelica_metatype _oHs = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oHs has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inWEqn;
    {
      modelica_metatype _weqn = NULL;
      modelica_metatype _hs = NULL;
      modelica_metatype _whenStmtLst = NULL;
      modelica_metatype _oweqn = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _weqn has no default value.
      // _hs has no default value.
      // _whenStmtLst has no default value.
      // _oweqn 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;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          _whenStmtLst = tmpMeta6;
          _oweqn = tmpMeta7;
          /* Pattern matching succeeded */
          _hs = omc_RemoveSimpleEquations_addUnreplaceableFromWhenOps(threadData, _whenStmtLst, _iHs);

          if(isSome(_oweqn))
          {
            /* Pattern-matching assignment */
            tmpMeta8 = _oweqn;
            if (optionNone(tmpMeta8)) goto goto_2;
            tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
            _weqn = tmpMeta9;

            _hs = omc_RemoveSimpleEquations_addUnreplaceableFromWhen(threadData, _weqn, _hs);
          }
          tmpMeta1 = _hs;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oHs = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oHs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStmt(threadData_t *threadData, modelica_metatype _inStmt, modelica_metatype _inHS)
{
  modelica_metatype _outHS = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHS has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inStmt;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _expExpLst = NULL;
      modelica_metatype _crlst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _expExpLst has no default value.
      // _crlst has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; 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), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _cr = tmpMeta7;
          /* Pattern matching succeeded */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);
          tmpMeta1 = omc_BaseHashSet_add(threadData, _cr, _inHS);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _expExpLst = tmpMeta8;
          /* Pattern matching succeeded */
          _crlst = omc_List_flatten(threadData, omc_List_map(threadData, _expExpLst, boxvar_Expression_extractCrefsFromExp));

          _crlst = omc_List_map(threadData, _crlst, boxvar_ComponentReferenceBasics_crefStripLastSubs);
          tmpMeta1 = omc_List_fold(threadData, _crlst, boxvar_BaseHashSet_add, _inHS);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,6,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          
          _cr = tmpMeta10;
          /* Pattern matching succeeded */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);
          tmpMeta1 = omc_BaseHashSet_add(threadData, _cr, _inHS);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inHS;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outHS = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHS;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenStmt(threadData_t *threadData, modelica_metatype _inStmt, modelica_metatype _inHS)
{
  modelica_metatype _outHS = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHS has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inStmt;
    {
      modelica_metatype _stmt = NULL;
      modelica_metatype _stmts = NULL;
      modelica_metatype _hs = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stmt has no default value.
      // _stmts has no default value.
      // _hs has no default value.
      // _cr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,6) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (!optionNone(tmpMeta7)) goto tmp3_end;
          
          _stmts = tmpMeta6;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = omc_List_fold(threadData, _stmts, boxvar_RemoveSimpleEquations_addUnreplaceableFromStmt, _inHS);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,6) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          if (optionNone(tmpMeta9)) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          
          _stmts = tmpMeta8;
          _stmt = tmpMeta10;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _hs = omc_List_fold(threadData, _stmts, boxvar_RemoveSimpleEquations_addUnreplaceableFromStmt, _inHS);
          tmpMeta1 = omc_RemoveSimpleEquations_addUnreplaceableFromWhenStmt(threadData, _stmt, _hs);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,4) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,6,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          
          _cr = tmpMeta12;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);
          tmpMeta1 = omc_BaseHashSet_add(threadData, _cr, _inHS);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,4) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,6,2) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          
          _cr = tmpMeta14;
          /* Pattern matching succeeded */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);
          tmpMeta1 = omc_BaseHashSet_add(threadData, _cr, _inHS);
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inHS;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outHS = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHS;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhenEqn(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inHs, modelica_metatype *out_hs)
{
  modelica_metatype _eqn = NULL;
  modelica_metatype _hs = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eqn has no default value.
  // _hs has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inEq;
    tmp4_2 = _inHs;
    {
      modelica_metatype _weqn = NULL;
      modelica_metatype _stmts = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _weqn has no default value.
      // _stmts 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,5,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _eqn = tmp4_1;
          _weqn = tmpMeta6;
          _hs = tmp4_2;
          /* Pattern matching succeeded */
          _hs = omc_RemoveSimpleEquations_addUnreplaceableFromWhen(threadData, _weqn, _hs);
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _hs;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,4,5) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          
          _eqn = tmp4_1;
          _stmts = tmpMeta8;
          _hs = tmp4_2;
          /* Pattern matching succeeded */
          _hs = omc_List_fold(threadData, _stmts, boxvar_RemoveSimpleEquations_addUnreplaceableFromWhenStmt, _hs);
          tmpMeta[0+0] = _eqn;
          tmpMeta[0+1] = _hs;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inEq;
          tmpMeta[0+1] = _inHs;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _eqn = tmpMeta[0+0];
  _hs = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_hs) { *out_hs = _hs; }
  return _eqn;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhensSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype _eqns = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnreplaceable has no default value.
  // _eqns has no default value.
  _eqns = omc_BackendEquation_getEqnsFromEqSystem(threadData, _isyst);

  _outUnreplaceable = omc_BackendEquation_traverseEquationArray(threadData, _eqns, boxvar_RemoveSimpleEquations_addUnreplaceableFromWhenEqn, _inUnreplaceable);
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromEqnsExp(threadData_t *threadData, modelica_metatype _e, modelica_metatype _hs, modelica_metatype *out_ohs)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype _ohs = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _ohs has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _e;
    {
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr 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,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;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _hs;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta7;
          /* Pattern matching succeeded */
          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);

          _ohs = omc_BaseHashSet_add(threadData, _cr, _hs);
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _ohs;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = _hs;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outExp = tmpMeta[0+0];
  _ohs = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_ohs) { *out_ohs = _ohs; }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromWhens(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype _systs = NULL;
  modelica_metatype _eqns = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnreplaceable has no default value.
  // _systs has no default value.
  // _eqns has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inDAE;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 6));
  _systs = tmpMeta2;
  _eqns = tmpMeta4;

  _outUnreplaceable = omc_List_fold(threadData, _systs, boxvar_RemoveSimpleEquations_addUnreplaceableFromWhensSystem, _inUnreplaceable);

  /* Pattern-matching assignment */
  tmpMeta5 = mmc_mk_box2(0, boxvar_RemoveSimpleEquations_addUnreplaceableFromEqnsExp, _outUnreplaceable);
  tmpMeta6 = omc_BackendDAEUtil_traverseBackendDAEExpsEqns(threadData, _eqns, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta5);
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
  _outUnreplaceable = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSet(threadData_t *threadData, modelica_metatype _iStateSet, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype _statevars = NULL;
  modelica_metatype _crlst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnreplaceable has no default value.
  // _statevars has no default value.
  // _crlst has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iStateSet;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  _statevars = tmpMeta2;

  _crlst = omc_List_map(threadData, _statevars, boxvar_BackendVariable_varCref);

  _crlst = omc_List_map(threadData, _crlst, boxvar_ComponentReferenceBasics_crefStripLastSubs);

  _outUnreplaceable = omc_List_fold(threadData, _crlst, boxvar_BaseHashSet_add, _inUnreplaceable);
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem(threadData_t *threadData, modelica_metatype _isyst, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnreplaceable has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _isyst;
    {
      modelica_metatype _stateSets = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stateSets has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          if (!listEmpty(tmpMeta6)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inUnreplaceable;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _stateSets = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_fold(threadData, _stateSets, boxvar_RemoveSimpleEquations_addUnreplaceableFromStateSet, _inUnreplaceable);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outUnreplaceable = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceableFromStateSets(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype _systs = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnreplaceable has no default value.
  // _systs has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inDAE;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _systs = tmpMeta2;

  _outUnreplaceable = omc_List_fold(threadData, _systs, boxvar_RemoveSimpleEquations_addUnreplaceableFromStateSetSystem, _inUnreplaceable);
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData_t *threadData, 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;
    tmp4_1 = _inTpl;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _expOpt = NULL;
      modelica_metatype _exps = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _exp1 has no default value.
      // _repl has no default value.
      // _expOpt has no default value.
      // _exps has no default value.
      // _b has no default value.
      // _b1 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (!optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          _repl = tmpMeta8;
          _exps = tmpMeta9;
          _b = tmp11  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmpMeta12 = mmc_mk_cons(mmc_mk_none(), _exps);
          _exps = tmpMeta12;
          tmpMeta13 = mmc_mk_box3(0, _repl, _exps, mmc_mk_boolean(_b));
          tmpMeta14 = mmc_mk_box2(0, mmc_mk_none(), tmpMeta13);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (optionNone(tmpMeta15)) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 1));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 3));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          _expOpt = tmpMeta15;
          _exp = tmpMeta16;
          _repl = tmpMeta18;
          _exps = tmpMeta19;
          _b = tmp21  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          _exp1 = omc_BackendVarTransform_replaceExp(threadData, _exp, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);

          if(referenceEq(_exp1, _exp))
          {
            tmpMeta22 = mmc_mk_cons(_expOpt, _exps);
            _exps = tmpMeta22;
          }
          else
          {
            tmpMeta23 = mmc_mk_cons(mmc_mk_some(_exp1), _exps);
            _exps = tmpMeta23;
          }
          tmpMeta24 = mmc_mk_box3(0, _repl, _exps, mmc_mk_boolean((_b || _b1)));
          tmpMeta25 = mmc_mk_box2(0, _expOpt, tmpMeta24);
          tmpMeta1 = tmpMeta25;
          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;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceExprTraverser(threadData_t *threadData, 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;
    tmp4_1 = _inTpl;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _exps = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _exp1 has no default value.
      // _repl has no default value.
      // _exps has no default value.
      // _b has no default value.
      // _b1 has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          _exp = tmpMeta6;
          _repl = tmpMeta8;
          _exps = tmpMeta9;
          _b = tmp11  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          _exp1 = omc_BackendVarTransform_replaceExp(threadData, _exp, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);

          tmpMeta12 = mmc_mk_cons(_exp1, _exps);
          _exps = tmpMeta12;
          tmpMeta13 = mmc_mk_box3(0, _repl, _exps, mmc_mk_boolean((_b || _b1)));
          tmpMeta14 = mmc_mk_box2(0, _exp, tmpMeta13);
          tmpMeta1 = tmpMeta14;
          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;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceEquationTraverser(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outEq = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outEq has no default value.
  // _outTpl has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _inEq;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _eqn = NULL;
      modelica_metatype _lhs = NULL;
      modelica_metatype _rhs = NULL;
      modelica_metatype _res = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqns1 = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _eqn has no default value.
      // _lhs has no default value.
      // _rhs has no default value.
      // _res has no default value.
      // _repl has no default value.
      // _eqns has no default value.
      // _eqns1 has no default value.
      // _b has no default value.
      // _b1 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_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_boolean tmp13;
          modelica_string tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_boolean tmp19;
          modelica_string tmp20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          _e = tmp4_1;
          _repl = tmpMeta6;
          _eqns = tmpMeta7;
          _b = tmp9  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_cons(_e, MMC_REFSTRUCTLIT(mmc_nil));
          _eqns1 = omc_BackendVarTransform_replaceEquations(threadData, tmpMeta10, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);

          if((omc_BackendEquation_isInitialEquation(threadData, _e) && omc_BackendEquation_isEquation(threadData, _e)))
          {
            _eqn = listHead(_eqns1);

            _lhs = omc_BackendEquation_getEquationLHS(threadData, _eqn);

            _rhs = omc_BackendEquation_getEquationRHS(threadData, _eqn);

            _res = omc_Expression_createResidualExp(threadData, _lhs, _rhs);

            if(omc_Expression_isConst(threadData, _res))
            {
              if(omc_Expression_isZero(threadData, _res))
              {
                tmpMeta11 = stringAppend(_OMC_LIT60,omc_BackendDump_equationString(threadData, _e));
                tmp13 = (modelica_boolean)_b1;
                if(tmp13)
                {
                  tmpMeta12 = stringAppend(_OMC_LIT59,omc_BackendDump_equationString(threadData, _eqn));
                  tmp14 = tmpMeta12;
                }
                else
                {
                  tmp14 = _OMC_LIT1;
                }
                tmpMeta15 = stringAppend(tmpMeta11,tmp14);
                omc_Error_addCompilerNotification(threadData, tmpMeta15);

                tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
                _eqns1 = tmpMeta16;

                _b1 = 1 /* true */;
              }
              else
              {
                tmpMeta17 = stringAppend(_OMC_LIT58,omc_BackendDump_equationString(threadData, _e));
                tmp19 = (modelica_boolean)_b1;
                if(tmp19)
                {
                  tmpMeta18 = stringAppend(_OMC_LIT59,omc_BackendDump_equationString(threadData, _eqn));
                  tmp20 = tmpMeta18;
                }
                else
                {
                  tmp20 = _OMC_LIT1;
                }
                tmpMeta21 = stringAppend(tmpMeta17,tmp20);
                omc_Error_addCompilerWarning(threadData, tmpMeta21);

                tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
                _eqns1 = tmpMeta22;

                _b1 = 1 /* true */;
              }
            }
          }

          _eqns = listAppend(_eqns1, _eqns);
          tmpMeta23 = mmc_mk_box3(0, _repl, _eqns, mmc_mk_boolean((_b || _b1)));
          tmpMeta[0+0] = _e;
          tmpMeta[0+1] = tmpMeta23;
          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];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outEq;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasVarReplacements(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inRepl, modelica_metatype *out_repl)
{
  modelica_metatype _v = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype _exp = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _v has no default value.
  // _repl has no default value.
  // _exp has no default value.
  // _cr has no default value.
  _v = _inVar;

  /* Pattern-matching assignment */
  tmpMeta1 = _v;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  if (optionNone(tmpMeta3)) MMC_THROW_INTERNAL();
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
  _cr = tmpMeta2;
  _exp = tmpMeta4;

  _repl = omc_BackendVarTransform_addReplacement(threadData, _inRepl, _cr, _exp, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator));
  _return: OMC_LABEL_UNUSED
  if (out_repl) { *out_repl = _repl; }
  return _v;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAliasReplacements(threadData_t *threadData, modelica_metatype _iStatesetrepl, modelica_metatype _aliasVars)
{
  modelica_metatype _oStatesetrepl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oStatesetrepl has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iStatesetrepl;
    {
      modelica_metatype _repl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _repl has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _repl = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _repl;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          _repl = omc_BackendVarTransform_emptyReplacementsSized(threadData, omc_BackendVariable_varsSize(threadData, _aliasVars));
          tmpMeta1 = omc_BackendVariable_traverseBackendDAEVars(threadData, _aliasVars, boxvar_RemoveSimpleEquations_getAliasVarReplacements, _repl);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oStatesetrepl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oStatesetrepl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptimicaContraints(threadData_t *threadData, modelica_metatype _icontraints, modelica_metatype _irepl)
{
  modelica_metatype _ocontraints = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ocontraints has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _icontraints;
    {
      modelica_metatype _constraintLst = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _constraintLst has no default value.
      // _rest has no default value.
      // _e has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmp4_1);
          tmpMeta8 = MMC_CDR(tmp4_1);
          _e = tmpMeta7;
          _rest = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box3(0, _irepl, tmpMeta9, mmc_mk_boolean(0 /* false */));
          tmpMeta11 = mmc_mk_box2(0, _e, tmpMeta10);
          tmpMeta12 = omc_RemoveSimpleEquations_replaceExprTraverser(threadData, tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          if (listEmpty(tmpMeta14)) goto goto_2;
          tmpMeta15 = MMC_CAR(tmpMeta14);
          tmpMeta16 = MMC_CDR(tmpMeta14);
          if (!listEmpty(tmpMeta16)) goto goto_2;
          _e = tmpMeta15;

          _constraintLst = omc_RemoveSimpleEquations_replaceOptimicaContraints(threadData, _rest, _irepl);
          tmpMeta17 = mmc_mk_cons(_e, _constraintLst);
          tmpMeta1 = tmpMeta17;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _ocontraints = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _ocontraints;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOptimicaExps(threadData_t *threadData, modelica_metatype _icontraints, modelica_metatype _iclassAttributes, modelica_metatype _irepl, modelica_metatype *out_oclassAttributes)
{
  modelica_metatype _ocontraints = NULL;
  modelica_metatype _oclassAttributes = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _ocontraints has no default value.
  // _oclassAttributes has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _icontraints;
    tmp4_2 = _iclassAttributes;
    {
      modelica_metatype _objetiveE = NULL;
      modelica_metatype _objectiveIntegrandE = NULL;
      modelica_metatype _startTimeE = NULL;
      modelica_metatype _finalTimeE = NULL;
      modelica_metatype _constraintLst = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _constraintLstExps = NULL;
      modelica_metatype _classAttributes = NULL;
      modelica_metatype _restClassAtr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _objetiveE has no default value.
      // _objectiveIntegrandE has no default value.
      // _startTimeE has no default value.
      // _finalTimeE has no default value.
      // _constraintLst has no default value.
      // _rest has no default value.
      // _constraintLstExps has no default value.
      // _classAttributes has no default value.
      // _restClassAtr has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta6;
          tmpMeta[0+1] = tmpMeta7;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmp4_2);
          tmpMeta9 = MMC_CDR(tmp4_2);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 5));
          _objetiveE = tmpMeta10;
          _objectiveIntegrandE = tmpMeta11;
          _startTimeE = tmpMeta12;
          _finalTimeE = tmpMeta13;
          _restClassAtr = tmpMeta9;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta15 = mmc_mk_box3(0, _irepl, tmpMeta14, mmc_mk_boolean(0 /* false */));
          tmpMeta16 = mmc_mk_box2(0, _objetiveE, tmpMeta15);
          tmpMeta17 = omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData, tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          if (listEmpty(tmpMeta19)) goto goto_2;
          tmpMeta20 = MMC_CAR(tmpMeta19);
          tmpMeta21 = MMC_CDR(tmpMeta19);
          if (!listEmpty(tmpMeta21)) goto goto_2;
          _objetiveE = tmpMeta20;

          /* Pattern-matching assignment */
          tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta23 = mmc_mk_box3(0, _irepl, tmpMeta22, mmc_mk_boolean(0 /* false */));
          tmpMeta24 = mmc_mk_box2(0, _objectiveIntegrandE, tmpMeta23);
          tmpMeta25 = omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData, tmpMeta24);
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          if (listEmpty(tmpMeta27)) goto goto_2;
          tmpMeta28 = MMC_CAR(tmpMeta27);
          tmpMeta29 = MMC_CDR(tmpMeta27);
          if (!listEmpty(tmpMeta29)) goto goto_2;
          _objectiveIntegrandE = tmpMeta28;

          /* Pattern-matching assignment */
          tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta31 = mmc_mk_box3(0, _irepl, tmpMeta30, mmc_mk_boolean(0 /* false */));
          tmpMeta32 = mmc_mk_box2(0, _startTimeE, tmpMeta31);
          tmpMeta33 = omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData, tmpMeta32);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 2));
          if (listEmpty(tmpMeta35)) goto goto_2;
          tmpMeta36 = MMC_CAR(tmpMeta35);
          tmpMeta37 = MMC_CDR(tmpMeta35);
          if (!listEmpty(tmpMeta37)) goto goto_2;
          _startTimeE = tmpMeta36;

          /* Pattern-matching assignment */
          tmpMeta38 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta39 = mmc_mk_box3(0, _irepl, tmpMeta38, mmc_mk_boolean(0 /* false */));
          tmpMeta40 = mmc_mk_box2(0, _finalTimeE, tmpMeta39);
          tmpMeta41 = omc_RemoveSimpleEquations_replaceOptExprTraverser(threadData, tmpMeta40);
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 2));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 2));
          if (listEmpty(tmpMeta43)) goto goto_2;
          tmpMeta44 = MMC_CAR(tmpMeta43);
          tmpMeta45 = MMC_CDR(tmpMeta43);
          if (!listEmpty(tmpMeta45)) goto goto_2;
          _finalTimeE = tmpMeta44;

          tmpMeta46 = MMC_REFSTRUCTLIT(mmc_nil);
          omc_RemoveSimpleEquations_replaceOptimicaExps(threadData, tmpMeta46, _restClassAtr, _irepl ,&_classAttributes);

          tmpMeta48 = mmc_mk_box5(3, &DAE_ClassAttributes_OPTIMIZATION__ATTRS__desc, _objetiveE, _objectiveIntegrandE, _startTimeE, _finalTimeE);
          tmpMeta47 = mmc_mk_cons(tmpMeta48, _classAttributes);
          _classAttributes = tmpMeta47;
          tmpMeta49 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta49;
          tmpMeta[0+1] = _classAttributes;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta50 = MMC_CAR(tmp4_1);
          tmpMeta51 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta50,0,1) == 0) goto tmp3_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta50), 2));
          
          _constraintLstExps = tmpMeta52;
          _rest = tmpMeta51;
          /* Pattern matching succeeded */
          _constraintLstExps = omc_RemoveSimpleEquations_replaceOptimicaContraints(threadData, _constraintLstExps, _irepl);

          _constraintLst = omc_RemoveSimpleEquations_replaceOptimicaExps(threadData, _rest, _iclassAttributes, _irepl, NULL);

          tmpMeta54 = mmc_mk_box2(3, &DAE_Constraint_CONSTRAINT__EXPS__desc, _constraintLstExps);
          tmpMeta53 = mmc_mk_cons(tmpMeta54, _constraintLst);
          _constraintLst = tmpMeta53;
          tmpMeta[0+0] = _constraintLst;
          tmpMeta[0+1] = _iclassAttributes;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _ocontraints = tmpMeta[0+0];
  _oclassAttributes = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oclassAttributes) { *out_oclassAttributes = _oclassAttributes; }
  return _ocontraints;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData_t *threadData, modelica_metatype _iVarLst, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _hs, modelica_metatype _iAcc)
{
  modelica_metatype _oVarLst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVarLst has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _iVarLst;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _varlst = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _exp = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _varlst has no default value.
      // _cr has no default value.
      // _exp has no default value.
      // _b has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _iAcc;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_boolean tmp8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          _var = tmpMeta6;
          _varlst = tmpMeta7;
          /* Pattern matching succeeded */
          _cr = omc_BackendVariable_varCref(threadData, _var);

          /* Pattern-matching assignment */
          tmp8 = omc_BaseHashSet_has(threadData, _cr, _hs);
          if (0 /* false */ != tmp8) goto goto_2;

          _var = omc_BackendVariable_getVarSingle(threadData, _cr, _aliasVars, NULL);

          _exp = omc_BackendVariable_varBindExp(threadData, _var);

          /* Pattern-matching assignment */
          tmpMeta9 = omc_Expression_extractCrefsFromExp(threadData, _exp);
          if (listEmpty(tmpMeta9)) goto goto_2;
          tmpMeta10 = MMC_CAR(tmpMeta9);
          tmpMeta11 = MMC_CDR(tmpMeta9);
          if (!listEmpty(tmpMeta11)) goto goto_2;
          _cr = tmpMeta10;

          _b = omc_BaseHashSet_has(threadData, _cr, _hs);

          _var = omc_BackendVariable_getVarSingle(threadData, _cr, _vars, NULL);

          _varlst = omc_List_consOnTrue(threadData, (!_b), _var, _iAcc);
          tmpMeta1 = omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData, _varlst, _vars, _aliasVars, _hs, _varlst);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_boolean tmp14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          _var = tmpMeta12;
          _varlst = tmpMeta13;
          /* Pattern matching succeeded */
          _cr = omc_BackendVariable_varCref(threadData, _var);

          /* Pattern-matching assignment */
          tmp14 = omc_BaseHashSet_has(threadData, _cr, _hs);
          if (1 /* true */ != tmp14) goto goto_2;
          tmpMeta1 = omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData, _varlst, _vars, _aliasVars, _hs, _iAcc);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          _var = tmpMeta15;
          _varlst = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta17 = mmc_mk_cons(_var, _iAcc);
          tmpMeta1 = omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData, _varlst, _vars, _aliasVars, _hs, tmpMeta17);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oVarLst = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oVarLst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeEqualLshRshEqns(threadData_t *threadData, modelica_metatype _iEqn, modelica_metatype _iEqns)
{
  modelica_metatype _oEqns = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oEqns has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _iEqn;
    {
      modelica_metatype _rhs = NULL;
      modelica_metatype _lhs = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rhs has no default value.
      // _lhs has no default value.
      // _b has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          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));
          
          _lhs = tmpMeta6;
          _rhs = tmpMeta7;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _b = omc_ExpressionBasics_expEqual(threadData, _lhs, _rhs);
          tmpMeta1 = omc_List_consOnTrue(threadData, (!_b), _iEqn, _iEqns);
          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), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _lhs = tmpMeta8;
          _rhs = tmpMeta9;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _b = omc_ExpressionBasics_expEqual(threadData, _lhs, _rhs);
          tmpMeta1 = omc_List_consOnTrue(threadData, (!_b), _iEqn, _iEqns);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _lhs = tmpMeta10;
          _rhs = tmpMeta11;
          /* Pattern matching succeeded */
          _b = omc_ExpressionBasics_expEqual(threadData, _lhs, _rhs);
          tmpMeta1 = omc_List_consOnTrue(threadData, (!_b), _iEqn, _iEqns);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta12;
          
          /* Pattern matching succeeded */
          tmpMeta12 = mmc_mk_cons(_iEqn, _iEqns);
          tmpMeta1 = tmpMeta12;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oEqns = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oEqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeAliasVarsStateSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iStatesetrepl, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _iAcc, modelica_boolean _inB, modelica_boolean *out_outB, modelica_metatype *out_oStatesetrepl)
{
  modelica_metatype _oStateSets = NULL;
  modelica_boolean _outB;
  modelica_metatype _oStatesetrepl = NULL;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oStateSets has no default value.
  // _outB has no default value.
  // _oStatesetrepl has no default value.
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iStateSets;
    {
      modelica_metatype _stateSets = NULL;
      modelica_integer _index;
      modelica_integer _rang;
      modelica_metatype _states = NULL;
      modelica_metatype _crA = NULL;
      modelica_metatype _crJ = NULL;
      modelica_metatype _varA = NULL;
      modelica_metatype _statescandidates = NULL;
      modelica_metatype _ovars = NULL;
      modelica_metatype _varJ = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _oeqns = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _hs = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      modelica_metatype _jac = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _stateSets has no default value.
      // _index has no default value.
      // _rang has no default value.
      // _states has no default value.
      // _crA has no default value.
      // _crJ has no default value.
      // _varA has no default value.
      // _statescandidates has no default value.
      // _ovars has no default value.
      // _varJ has no default value.
      // _eqns has no default value.
      // _oeqns has no default value.
      // _repl has no default value.
      // _hs has no default value.
      // _b has no default value.
      // _b1 has no default value.
      // _jac has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = listReverse(_iAcc);
          tmp1_c1 = _inB;
          tmpMeta[0+2] = _iStatesetrepl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 6));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 7));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 8));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 9));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 10));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 11));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 12));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 13));
          _index = tmp9  /* pattern as ty=Integer */;
          _rang = tmp11  /* pattern as ty=Integer */;
          _states = tmpMeta12;
          _crA = tmpMeta13;
          _varA = tmpMeta14;
          _statescandidates = tmpMeta15;
          _ovars = tmpMeta16;
          _eqns = tmpMeta17;
          _oeqns = tmpMeta18;
          _crJ = tmpMeta19;
          _varJ = tmpMeta20;
          _jac = tmpMeta21;
          _stateSets = tmpMeta7;
          /* Pattern matching succeeded */
          _repl = omc_RemoveSimpleEquations_getAliasReplacements(threadData, _iStatesetrepl, _aliasVars);

          _hs = omc_HashSet_emptyHashSet(threadData);

          _hs = omc_List_applyAndFold(threadData, _statescandidates, boxvar_BaseHashSet_add, boxvar_BackendVariable_varCref, _hs);

          tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
          _ovars = omc_RemoveSimpleEquations_replaceOtherStateSetVars(threadData, _ovars, _vars, _aliasVars, _hs, tmpMeta22);

          _eqns = omc_BackendVarTransform_replaceEquations(threadData, _eqns, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b);

          _oeqns = omc_BackendVarTransform_replaceEquations(threadData, _oeqns, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);

          tmpMeta23 = MMC_REFSTRUCTLIT(mmc_nil);
          _oeqns = omc_List_fold(threadData, _oeqns, boxvar_RemoveSimpleEquations_removeEqualLshRshEqns, tmpMeta23);

          _oeqns = listReverse(_oeqns);
          tmpMeta25 = mmc_mk_box13(3, &BackendDAE_StateSet_STATESET__desc, mmc_mk_integer(_index), mmc_mk_integer(_rang), _states, _crA, _varA, _statescandidates, _ovars, _eqns, _oeqns, _crJ, _varJ, _jac);
          tmpMeta24 = mmc_mk_cons(tmpMeta25, _iAcc);
          /* Tail recursive call */
          _iStateSets = _stateSets;
          _iStatesetrepl = mmc_mk_some(_repl);
          _iAcc = tmpMeta24;
          _inB = (_b || _b1);
          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:;
    }
  }
  _oStateSets = tmpMeta[0+0];
  _outB = tmp1_c1;
  _oStatesetrepl = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_outB) { *out_outB = _outB; }
  if (out_oStatesetrepl) { *out_oStatesetrepl = _oStatesetrepl; }
  return _oStateSets;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_removeAliasVarsStateSets(threadData_t *threadData, modelica_metatype _iStateSets, modelica_metatype _iStatesetrepl, modelica_metatype _vars, modelica_metatype _aliasVars, modelica_metatype _iAcc, modelica_metatype _inB, modelica_metatype *out_outB, modelica_metatype *out_oStatesetrepl)
{
  modelica_integer tmp1;
  modelica_boolean _outB;
  modelica_metatype _oStateSets = NULL;
  tmp1 = mmc_unbox_integer(_inB);
  _oStateSets = omc_RemoveSimpleEquations_removeAliasVarsStateSets(threadData, _iStateSets, _iStatesetrepl, _vars, _aliasVars, _iAcc, tmp1, &_outB, out_oStatesetrepl);
  /* skip box _oStateSets; list<BackendDAE.StateSet> */
  if (out_outB) { *out_outB = mmc_mk_icon(_outB); }
  /* skip box _oStatesetrepl; Option<BackendVarTransform.VariableReplacements> */
  return _oStateSets;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeSimpleEquationsShared1(threadData_t *threadData, modelica_metatype _inSysts, modelica_metatype _inSysts1, modelica_metatype _repl, modelica_metatype _statesetrepl, modelica_metatype _aliasVars)
{
  modelica_metatype _outSysts = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSysts has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inSysts;
    {
      modelica_metatype _rest = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      modelica_metatype _syst = NULL;
      modelica_metatype _stateSets = NULL;
      modelica_metatype _statesetrepl1 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _eqns has no default value.
      // _eqnslst has no default value.
      // _b has no default value.
      // _b1 has no default value.
      // _syst has no default value.
      // _stateSets has no default value.
      // _statesetrepl1 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inSysts1;
          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_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          _syst = tmpMeta6;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = mmc_mk_box3(0, _repl, tmpMeta8, mmc_mk_boolean(0 /* false */));
          tmpMeta10 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 3))), boxvar_RemoveSimpleEquations_replaceEquationTraverser, tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          _eqnslst = tmpMeta11;
          _b = tmp13  /* pattern as ty=Boolean */;

          tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
          _stateSets = omc_RemoveSimpleEquations_removeAliasVarsStateSets(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 8))), _statesetrepl, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 2))), _aliasVars, tmpMeta14, 0 /* false */ ,&_b1 ,&_statesetrepl1);

          if((_b || _b1))
          {
            _eqns = omc_BackendEquation_listEquation(threadData, listReverse(_eqnslst));

            tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(11));
            memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[8] = _stateSets;
            _syst = tmpMeta15;

            tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(11));
            memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[3] = _eqns;
            _syst = tmpMeta16;

            _syst = omc_BackendDAEUtil_clearEqSyst(threadData, _syst);
          }

          /* Pattern-matching assignment */
          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta18 = mmc_mk_box3(0, _repl, tmpMeta17, mmc_mk_boolean(0 /* false */));
          tmpMeta19 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_syst), 10))), boxvar_RemoveSimpleEquations_replaceEquationTraverser, tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          _eqnslst = tmpMeta20;

          _eqnslst = omc_List_select(threadData, _eqnslst, boxvar_BackendEquation_assertWithCondTrue);

          tmpMeta21 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta21), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta21))[10] = omc_BackendEquation_listEquation(threadData, _eqnslst);
          _syst = tmpMeta21;
          tmpMeta22 = mmc_mk_cons(_syst, _inSysts1);
          /* Tail recursive call */
          _inSysts = _rest;
          _inSysts1 = tmpMeta22;
          _statesetrepl = _statesetrepl1;
          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:;
    }
  }
  _outSysts = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outSysts;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceVarTraverser(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inRepl, modelica_metatype *out_repl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _repl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inRepl;
    {
      modelica_metatype _v = NULL;
      modelica_metatype _v1 = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _v1 has no default value.
      // _e has no default value.
      // _e1 has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_boolean tmp8;
          modelica_metatype tmpMeta9;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          
          _v = tmp4_1;
          _e = tmpMeta7;
          _repl = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta9 = omc_BackendVarTransform_replaceExp(threadData, _e, _repl, mmc_mk_none(), &tmp8);
          _e1 = tmpMeta9;
          if (1 /* true */ != tmp8) goto goto_2;

          _v1 = omc_BackendVariable_setBindExp(threadData, _v, mmc_mk_some(_e1));
          tmpMeta[0+0] = _v1;
          tmpMeta[0+1] = _repl;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inRepl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _repl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_repl) { *out_repl = _repl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceAliasVarTraverser(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_outTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _outTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _v = NULL;
      modelica_metatype _v1 = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _varlst = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _v1 has no default value.
      // _repl has no default value.
      // _e has no default value.
      // _e1 has no default value.
      // _varlst has no default value.
      // _b has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _v = tmp4_1;
          _e = tmpMeta7;
          _repl = tmpMeta8;
          _varlst = tmpMeta9;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta11 = omc_BackendVarTransform_replaceExp(threadData, _e, _repl, mmc_mk_none(), &tmp10);
          _e1 = tmpMeta11;
          if (1 /* true */ != tmp10) goto goto_2;

          _b = omc_Expression_isConstValue(threadData, _e1);

          _v1 = ((!_b)?omc_BackendVariable_setBindExp(threadData, _v, mmc_mk_some(_e1)):_v);

          _varlst = omc_List_consOnTrue(threadData, _b, _v1, _varlst);
          tmpMeta12 = mmc_mk_box2(0, _repl, _varlst);
          tmpMeta[0+0] = _v1;
          tmpMeta[0+1] = tmpMeta12;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inVar;
          tmpMeta[0+1] = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasConstBindings1(threadData_t *threadData, modelica_metatype _iCr, modelica_metatype _iExp, modelica_metatype _iAVars)
{
  modelica_metatype _oExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oExp has no default value.
  { /* matchcontinue expression */
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _e has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = omc_Expression_extractCrefsFromExp(threadData, _iExp);
          if (listEmpty(tmpMeta6)) goto goto_2;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          _cr = tmpMeta7;

          /* Pattern-matching tuple assignment */
          tmpMeta9 = omc_BackendVariable_getVarSingle(threadData, _cr, _iAVars, NULL);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 7));
          if (optionNone(tmpMeta10)) goto goto_2;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          _e = tmpMeta11;
          tmpMeta1 = omc_RemoveSimpleEquations_fixAliasConstBindings1(threadData, _cr, _e, _iAVars);
          goto tmp3_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          tmpMeta1 = _iExp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasConstBindings(threadData_t *threadData, modelica_metatype _iAVar, modelica_metatype _iAVars)
{
  modelica_metatype _oAVars = NULL;
  modelica_metatype _cr = NULL;
  modelica_metatype _e = NULL;
  modelica_metatype _avar = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oAVars has no default value.
  // _cr has no default value.
  // _e has no default value.
  // _avar has no default value.
  _cr = omc_BackendVariable_varCref(threadData, _iAVar);

  _e = omc_BackendVariable_varBindExp(threadData, _iAVar);

  _e = omc_RemoveSimpleEquations_fixAliasConstBindings1(threadData, _cr, _e, _iAVars);

  _avar = omc_BackendVariable_setBindExp(threadData, _iAVar, mmc_mk_some(_e));

  _oAVars = omc_BackendVariable_addVar(threadData, _avar, _iAVars);
  _return: OMC_LABEL_UNUSED
  return _oAVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData_t *threadData, modelica_boolean _b, modelica_metatype _inDAE, modelica_metatype _repl)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _b;
    tmp4_2 = _inDAE;
    {
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _externalObjects = NULL;
      modelica_metatype _aliasVars = NULL;
      modelica_metatype _constraintsLst = NULL;
      modelica_metatype _clsAttrsLst = NULL;
      modelica_metatype _systs = NULL;
      modelica_metatype _systs1 = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _varlst = NULL;
      modelica_boolean _b1;
      modelica_metatype _shared = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _globalKnownVars has no default value.
      // _externalObjects has no default value.
      // _aliasVars has no default value.
      // _constraintsLst has no default value.
      // _clsAttrsLst has no default value.
      // _systs has no default value.
      // _systs1 has no default value.
      // _eqnslst has no default value.
      // _varlst has no default value.
      // _b1 has no default value.
      // _shared has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inDAE;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          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;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 8));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 9));
          
          _systs = tmpMeta6;
          _shared = tmpMeta7;
          _globalKnownVars = tmpMeta8;
          _externalObjects = tmpMeta9;
          _aliasVars = tmpMeta10;
          _constraintsLst = tmpMeta11;
          _clsAttrsLst = tmpMeta12;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT51))
          {
            omc_BackendVarTransform_dumpReplacements(threadData, _repl);

            omc_BackendVarTransform_dumpExtendReplacements(threadData, _repl);

            omc_BackendVarTransform_dumpDerConstReplacements(threadData, _repl);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta16 = mmc_mk_box2(0, _repl, tmpMeta15);
          omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _aliasVars, boxvar_RemoveSimpleEquations_replaceAliasVarTraverser, tmpMeta16, &tmpMeta13);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          _varlst = tmpMeta14;

          _aliasVars = omc_List_fold(threadData, _varlst, boxvar_RemoveSimpleEquations_fixAliasConstBindings, _aliasVars);

          tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[5] = _aliasVars;
          _shared = tmpMeta17;

          omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _globalKnownVars, boxvar_RemoveSimpleEquations_replaceVarTraverser, _repl, NULL);

          omc_BackendVariable_traverseBackendDAEVarsWithUpdate(threadData, _externalObjects, boxvar_RemoveSimpleEquations_replaceVarTraverser, _repl, NULL);

          /* Pattern-matching assignment */
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta19 = mmc_mk_box3(0, _repl, tmpMeta18, mmc_mk_boolean(0 /* false */));
          tmpMeta20 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 6))), boxvar_RemoveSimpleEquations_replaceEquationTraverser, tmpMeta19);
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 3));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          _eqnslst = tmpMeta21;
          _b1 = tmp23  /* pattern as ty=Boolean */;

          tmpMeta24 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta24), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta24))[6] = (_b1?omc_BackendEquation_listEquation(threadData, _eqnslst):(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 6))));
          _shared = tmpMeta24;

          /* Pattern-matching assignment */
          tmpMeta25 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta26 = mmc_mk_box3(0, _repl, tmpMeta25, mmc_mk_boolean(0 /* false */));
          tmpMeta27 = omc_BackendEquation_traverseEquationArray(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_shared), 7))), boxvar_RemoveSimpleEquations_replaceEquationTraverser, tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          _eqnslst = tmpMeta28;

          _eqnslst = omc_List_select(threadData, _eqnslst, boxvar_BackendEquation_assertWithCondTrue);

          tmpMeta29 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta29), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta29))[7] = omc_BackendEquation_listEquation(threadData, _eqnslst);
          _shared = tmpMeta29;

          _constraintsLst = omc_RemoveSimpleEquations_replaceOptimicaExps(threadData, _constraintsLst, _clsAttrsLst, _repl ,&_clsAttrsLst);

          tmpMeta30 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta30), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta30))[8] = _constraintsLst;
          _shared = tmpMeta30;

          tmpMeta31 = MMC_TAGPTR(mmc_alloc_words(22));
          memcpy(MMC_UNTAGPTR(tmpMeta31), MMC_UNTAGPTR(_shared), 22*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta31))[9] = _clsAttrsLst;
          _shared = tmpMeta31;

          tmpMeta32 = MMC_REFSTRUCTLIT(mmc_nil);
          _systs1 = omc_RemoveSimpleEquations_removeSimpleEquationsShared1(threadData, _systs, tmpMeta32, _repl, mmc_mk_none(), _aliasVars);
          tmpMeta33 = mmc_mk_box3(3, &BackendDAE_BackendDAE_DAE__desc, _systs1, _shared);
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outDAE = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_removeSimpleEquationsShared(threadData_t *threadData, modelica_metatype _b, modelica_metatype _inDAE, modelica_metatype _repl)
{
  modelica_integer tmp1;
  modelica_metatype _outDAE = NULL;
  tmp1 = mmc_unbox_integer(_b);
  _outDAE = omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData, tmp1, _inDAE, _repl);
  /* skip box _outDAE; BackendDAE.BackendDAE */
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateStateOrder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inVar)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inExp;
    {
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendVariable_setStateDerivative(threadData, _inVar, mmc_mk_some(_cr));
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendVariable_setStateDerivative(threadData, _inVar, mmc_mk_none());
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl, modelica_metatype *out_oTpl)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype _oTpl = NULL;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  // _oTpl has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _repl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _e has no default value.
      // _v has no default value.
      // _vars has no default value.
      // _repl has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _v = tmp4_1;
          _cr = tmpMeta8;
          _vars = tmpMeta9;
          _repl = tmpMeta10;
          /* Pattern matching succeeded */
          _e = omc_BackendVarTransform_getReplacement(threadData, _repl, _cr);

          _v = omc_RemoveSimpleEquations_updateStateOrder(threadData, _e, _v);

          _vars = omc_BackendVariable_addVar(threadData, _v, _vars);
          tmpMeta11 = mmc_mk_box2(0, _vars, _repl);
          tmpMeta[0+0] = _v;
          tmpMeta[0+1] = tmpMeta11;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _v = tmp4_1;
          _vars = tmpMeta12;
          _repl = tmpMeta13;
          /* Pattern matching succeeded */
          _vars = omc_BackendVariable_addVar(threadData, _v, _vars);
          tmpMeta14 = mmc_mk_box2(0, _vars, _repl);
          tmpMeta[0+0] = _v;
          tmpMeta[0+1] = tmpMeta14;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta[0+0];
  _oTpl = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oTpl) { *out_oTpl = _oTpl; }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_updateSystem(threadData_t *threadData, modelica_boolean _foundSimple, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _repl, modelica_metatype _isyst)
{
  modelica_metatype _osyst = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _osyst has no default value.
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _foundSimple;
    tmp4_2 = _isyst;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _syst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _eqns has no default value.
      // _syst has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _isyst;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          _syst = tmp4_2;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = mmc_mk_box2(0, omc_BackendVariable_emptyVars(threadData, ((modelica_integer) 4013)), _repl);
          tmpMeta7 = omc_BackendVariable_traverseBackendDAEVars(threadData, _iVars, boxvar_RemoveSimpleEquations_updateVar, tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          _vars = tmpMeta8;

          _eqns = omc_BackendEquation_listEquation(threadData, listReverse(_iEqnslst));

          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[3] = _eqns;
          _syst = tmpMeta9;

          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_syst), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[2] = _vars;
          _syst = tmpMeta10;
          tmpMeta1 = omc_BackendDAEUtil_clearEqSyst(threadData, _syst);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _osyst = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _osyst;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_updateSystem(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _repl, modelica_metatype _isyst)
{
  modelica_integer tmp1;
  modelica_metatype _osyst = NULL;
  tmp1 = mmc_unbox_integer(_foundSimple);
  _osyst = omc_RemoveSimpleEquations_updateSystem(threadData, tmp1, _iEqnslst, _iVars, _repl, _isyst);
  /* skip box _osyst; BackendDAE.EqSystem */
  return _osyst;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectMinDepth(threadData_t *threadData, modelica_metatype _e, modelica_metatype _inMin, modelica_boolean *out_cont, modelica_metatype *out_outMin)
{
  modelica_metatype _eOut = NULL;
  modelica_boolean _cont;
  modelica_metatype _outMin = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eOut = _e;
  _cont = 1 /* true */;
  // _outMin has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _e;
    tmp4_2 = _inMin;
    {
      modelica_integer _i;
      modelica_integer _d;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _i has no default value.
      // _d has no default value.
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          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));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          
          _cr = tmpMeta6;
          _d = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _i = omc_ComponentReference_crefDepth(threadData, _cr);
          tmpMeta9 = mmc_mk_box2(0, mmc_mk_integer(modelica_integer_min((modelica_integer)(_i),(modelica_integer)(_d))), mmc_mk_boolean(0 /* false */));
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inMin;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outMin = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_outMin) { *out_outMin = _outMin; }
  return _eOut;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_selectMinDepth(threadData_t *threadData, modelica_metatype _e, modelica_metatype _inMin, modelica_metatype *out_cont, modelica_metatype *out_outMin)
{
  modelica_boolean _cont;
  modelica_metatype _eOut = NULL;
  _eOut = omc_RemoveSimpleEquations_selectMinDepth(threadData, _e, _inMin, &_cont, out_outMin);
  /* skip box _eOut; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  /* skip box _outMin; tuple<#Integer, #Boolean> */
  return _eOut;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectFreeValue1(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _iFavorit, modelica_string _iStr, modelica_string _iAttributeName, modelica_fnptr _inFunc, modelica_metatype _inVar, modelica_metatype _globalKnownVars)
{
  modelica_metatype _outVar = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _iZeroFreeValues;
    tmp4_2 = _iFavorit;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _es = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _crs = NULL;
      modelica_metatype _crVar = NULL;
      modelica_metatype _zerofreevalues = NULL;
      modelica_integer _i;
      modelica_integer _is;
      modelica_metatype _favorit = NULL;
      modelica_metatype _rest = NULL;
      modelica_string _s = NULL;
      modelica_string _s2 = NULL;
      modelica_boolean _b;
      modelica_boolean _hardcoded;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _e1 has no default value.
      // _es has no default value.
      // _cr has no default value.
      // _crs has no default value.
      // _crVar has no default value.
      // _zerofreevalues has no default value.
      // _i has no default value.
      // _is has no default value.
      // _favorit has no default value.
      // _rest has no default value.
      _s = (modelica_string) mmc_emptystring;
      // _s2 has no default value.
      // _b has no default value.
      // _hardcoded has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          modelica_string tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          _rest = tmp4_2;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmpMeta6 = omc_RemoveSimpleEquations_selectNonZeroExpression(threadData, _rest);
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          _e = tmpMeta7;
          _cr = tmpMeta8;

          _crVar = omc_BackendVariable_varCref(threadData, _inVar);

          if(omc_Flags_isSet(threadData, _OMC_LIT70))
          {
            _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

            _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

            tmp10 = (modelica_boolean)_b;
            if(tmp10)
            {
              tmpMeta9 = stringAppend(_OMC_LIT3,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmp11 = tmpMeta9;
            }
            else
            {
              tmp11 = _OMC_LIT1;
            }
            _s2 = tmp11;

            tmpMeta12 = stringAppend(_iStr,_OMC_LIT61);
            tmpMeta13 = stringAppend(tmpMeta12,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
            tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT62);
            tmpMeta15 = stringAppend(tmpMeta14,_iAttributeName);
            tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT3);
            tmpMeta17 = stringAppend(tmpMeta16,omc_ExpressionBasics_printExpStr(threadData, _e));
            tmpMeta18 = stringAppend(tmpMeta17,_s2);
            tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT63);
            tmpMeta20 = stringAppend(tmpMeta19,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _crVar));
            tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT21);
            _s = tmpMeta21;

            tmpMeta22 = mmc_mk_cons(_s, MMC_REFSTRUCTLIT(mmc_nil));
            omc_Error_addMessage(threadData, _OMC_LIT67, tmpMeta22);
          }
          tmpMeta1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), _inVar, _e) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _inVar, _e);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_boolean tmp34;
          modelica_string tmp35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta23 = MMC_CAR(tmp4_1);
          tmpMeta24 = MMC_CDR(tmp4_1);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 1));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          _e = tmpMeta25;
          _cr = tmpMeta26;
          _zerofreevalues = tmpMeta24;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta32 = mmc_mk_box2(0, mmc_mk_integer(omc_ComponentReference_crefDepth(threadData, _cr)), mmc_mk_boolean(1 /* true */));
          omc_Expression_traverseExpTopDown(threadData, _e, boxvar_RemoveSimpleEquations_selectMinDepth, tmpMeta32, &tmpMeta27);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 1));
          tmp29 = mmc_unbox_integer(tmpMeta28);
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          tmp31 = mmc_unbox_integer(tmpMeta30);
          _i = tmp29  /* pattern as ty=Integer */;
          _hardcoded = tmp31  /* pattern as ty=Boolean */;

          if(_hardcoded)
          {
            _i = ((modelica_integer) 5) + _i;
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT70))
          {
            _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

            _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

            tmp34 = (modelica_boolean)_b;
            if(tmp34)
            {
              tmpMeta33 = stringAppend(_OMC_LIT3,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmp35 = tmpMeta33;
            }
            else
            {
              tmp35 = _OMC_LIT1;
            }
            _s2 = tmp35;

            tmpMeta36 = stringAppend(_iStr,_OMC_LIT71);
            tmpMeta37 = stringAppend(tmpMeta36,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
            tmpMeta38 = stringAppend(tmpMeta37,_OMC_LIT62);
            tmpMeta39 = stringAppend(tmpMeta38,_iAttributeName);
            tmpMeta40 = stringAppend(tmpMeta39,_OMC_LIT3);
            tmpMeta41 = stringAppend(tmpMeta40,omc_ExpressionBasics_printExpStr(threadData, _e));
            tmpMeta42 = stringAppend(tmpMeta41,_s2);
            tmpMeta43 = stringAppend(tmpMeta42,_OMC_LIT72);
            tmpMeta44 = stringAppend(tmpMeta43,intString(_i));
            tmpMeta45 = stringAppend(tmpMeta44,_OMC_LIT73);
            _s = tmpMeta45;
          }
          tmpMeta47 = mmc_mk_box3(0, _e, _cr, mmc_mk_integer(_i));
          tmpMeta46 = mmc_mk_cons(tmpMeta47, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = omc_RemoveSimpleEquations_selectFreeValue1(threadData, _zerofreevalues, tmpMeta46, _s, _iAttributeName, ((modelica_fnptr) _inFunc), _inVar, _globalKnownVars);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_integer tmp57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_integer tmp60;
          modelica_metatype tmpMeta61;
          modelica_integer tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_boolean tmp65;
          modelica_string tmp66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_boolean tmp77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_boolean tmp86;
          modelica_metatype tmpMeta87;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta48 = MMC_CAR(tmp4_1);
          tmpMeta49 = MMC_CDR(tmp4_1);
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 1));
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 2));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta52 = MMC_CAR(tmp4_2);
          tmpMeta53 = MMC_CDR(tmp4_2);
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 1));
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 3));
          tmp57 = mmc_unbox_integer(tmpMeta56);
          _e = tmpMeta50;
          _cr = tmpMeta51;
          _zerofreevalues = tmpMeta49;
          _es = tmpMeta54;
          _crs = tmpMeta55;
          _is = tmp57  /* pattern as ty=Integer */;
          _rest = tmpMeta53;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta63 = mmc_mk_box2(0, mmc_mk_integer(omc_ComponentReference_crefDepth(threadData, _cr)), mmc_mk_boolean(1 /* true */));
          omc_Expression_traverseExpTopDown(threadData, _e, boxvar_RemoveSimpleEquations_selectMinDepth, tmpMeta63, &tmpMeta58);
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 1));
          tmp60 = mmc_unbox_integer(tmpMeta59);
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          tmp62 = mmc_unbox_integer(tmpMeta61);
          _i = tmp60  /* pattern as ty=Integer */;
          _hardcoded = tmp62  /* pattern as ty=Boolean */;

          if(_hardcoded)
          {
            _i = ((modelica_integer) 5) + _i;
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT70))
          {
            _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

            _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

            tmp65 = (modelica_boolean)_b;
            if(tmp65)
            {
              tmpMeta64 = stringAppend(_OMC_LIT3,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmp66 = tmpMeta64;
            }
            else
            {
              tmp66 = _OMC_LIT1;
            }
            _s2 = tmp66;

            tmpMeta67 = stringAppend(_iStr,_OMC_LIT71);
            tmpMeta68 = stringAppend(tmpMeta67,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
            tmpMeta69 = stringAppend(tmpMeta68,_OMC_LIT62);
            tmpMeta70 = stringAppend(tmpMeta69,_iAttributeName);
            tmpMeta71 = stringAppend(tmpMeta70,_OMC_LIT3);
            tmpMeta72 = stringAppend(tmpMeta71,omc_ExpressionBasics_printExpStr(threadData, _e));
            tmpMeta73 = stringAppend(tmpMeta72,_s2);
            tmpMeta74 = stringAppend(tmpMeta73,_OMC_LIT72);
            tmpMeta75 = stringAppend(tmpMeta74,intString(_i));
            tmpMeta76 = stringAppend(tmpMeta75,_OMC_LIT73);
            _s = tmpMeta76;
          }

          /* Pattern-matching assignment */
          tmp77 = (_i == _is);
          if (1 /* true */ != tmp77) goto goto_2;

          _crVar = omc_BackendVariable_varCref(threadData, _inVar);

          tmp86 = (modelica_boolean)omc_ComponentReferenceBasics_crefEqual(threadData, _crVar, _crs);
          if(tmp86)
          {
            tmpMeta79 = mmc_mk_box3(0, _es, _crs, mmc_mk_integer(_is));
            tmpMeta81 = mmc_mk_box3(0, _e, _cr, mmc_mk_integer(_i));
            tmpMeta80 = mmc_mk_cons(tmpMeta81, _rest);
            tmpMeta78 = mmc_mk_cons(tmpMeta79, tmpMeta80);
            tmpMeta87 = tmpMeta78;
          }
          else
          {
            tmpMeta83 = mmc_mk_box3(0, _e, _cr, mmc_mk_integer(_i));
            tmpMeta85 = mmc_mk_box3(0, _es, _crs, mmc_mk_integer(_is));
            tmpMeta84 = mmc_mk_cons(tmpMeta85, _rest);
            tmpMeta82 = mmc_mk_cons(tmpMeta83, tmpMeta84);
            tmpMeta87 = tmpMeta82;
          }
          _favorit = tmpMeta87;
          tmpMeta1 = omc_RemoveSimpleEquations_selectFreeValue1(threadData, _zerofreevalues, _favorit, _s, _iAttributeName, ((modelica_fnptr) _inFunc), _inVar, _globalKnownVars);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_integer tmp95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_integer tmp98;
          modelica_metatype tmpMeta99;
          modelica_integer tmp100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_boolean tmp103;
          modelica_string tmp104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_boolean tmp117;
          modelica_metatype tmpMeta118;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta88 = MMC_CAR(tmp4_1);
          tmpMeta89 = MMC_CDR(tmp4_1);
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta88), 1));
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta88), 2));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta92 = MMC_CAR(tmp4_2);
          tmpMeta93 = MMC_CDR(tmp4_2);
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 3));
          tmp95 = mmc_unbox_integer(tmpMeta94);
          _e = tmpMeta90;
          _cr = tmpMeta91;
          _zerofreevalues = tmpMeta89;
          _is = tmp95  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta101 = mmc_mk_box2(0, mmc_mk_integer(omc_ComponentReference_crefDepth(threadData, _cr)), mmc_mk_boolean(1 /* true */));
          omc_Expression_traverseExpTopDown(threadData, _e, boxvar_RemoveSimpleEquations_selectMinDepth, tmpMeta101, &tmpMeta96);
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta96), 1));
          tmp98 = mmc_unbox_integer(tmpMeta97);
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta96), 2));
          tmp100 = mmc_unbox_integer(tmpMeta99);
          _i = tmp98  /* pattern as ty=Integer */;
          _hardcoded = tmp100  /* pattern as ty=Boolean */;

          if(_hardcoded)
          {
            _i = ((modelica_integer) 5) + _i;
          }

          if(omc_Flags_isSet(threadData, _OMC_LIT70))
          {
            _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

            _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

            tmp103 = (modelica_boolean)_b;
            if(tmp103)
            {
              tmpMeta102 = stringAppend(_OMC_LIT3,omc_ExpressionBasics_printExpStr(threadData, _e1));
              tmp104 = tmpMeta102;
            }
            else
            {
              tmp104 = _OMC_LIT1;
            }
            _s2 = tmp104;

            tmpMeta105 = stringAppend(_iStr,_OMC_LIT71);
            tmpMeta106 = stringAppend(tmpMeta105,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
            tmpMeta107 = stringAppend(tmpMeta106,_OMC_LIT62);
            tmpMeta108 = stringAppend(tmpMeta107,_iAttributeName);
            tmpMeta109 = stringAppend(tmpMeta108,_OMC_LIT3);
            tmpMeta110 = stringAppend(tmpMeta109,omc_ExpressionBasics_printExpStr(threadData, _e));
            tmpMeta111 = stringAppend(tmpMeta110,_s2);
            tmpMeta112 = stringAppend(tmpMeta111,_OMC_LIT72);
            tmpMeta113 = stringAppend(tmpMeta112,intString(_i));
            tmpMeta114 = stringAppend(tmpMeta113,_OMC_LIT73);
            _s = tmpMeta114;
          }

          tmp117 = (modelica_boolean)(_i < _is);
          if(tmp117)
          {
            tmpMeta116 = mmc_mk_box3(0, _e, _cr, mmc_mk_integer(_i));
            tmpMeta115 = mmc_mk_cons(tmpMeta116, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta118 = tmpMeta115;
          }
          else
          {
            tmpMeta118 = _iFavorit;
          }
          _favorit = tmpMeta118;
          tmpMeta1 = omc_RemoveSimpleEquations_selectFreeValue1(threadData, _zerofreevalues, _favorit, _s, _iAttributeName, ((modelica_fnptr) _inFunc), _inVar, _globalKnownVars);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 5) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectNonZeroExpression(threadData_t *threadData, modelica_metatype _iFavorit)
{
  modelica_metatype _selected = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _selected has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iFavorit;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _tpl = NULL;
      modelica_metatype _rest = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _tpl has no default value.
      // _rest has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          _tpl = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _tpl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmp4_1);
          tmpMeta9 = MMC_CDR(tmp4_1);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          
          _tpl = tmpMeta8;
          _e = tmpMeta10;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!omc_Expression_isZero(threadData, _e))) goto tmp3_end;
          tmpMeta1 = _tpl;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta11 = MMC_CAR(tmp4_1);
          tmpMeta12 = MMC_CDR(tmp4_1);
          _rest = tmpMeta12;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _iFavorit = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _selected = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _selected;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_selectFreeValue(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVar = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  _warnAliasConflicts = 0 /* false */;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iZeroFreeValues;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          
          /* Pattern matching succeeded */
          _warnAliasConflicts = (!omc_Flags_isSet(threadData, _OMC_LIT70));
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_RemoveSimpleEquations_selectFreeValue1(threadData, _iZeroFreeValues, tmpMeta6, _OMC_LIT74, _OMC_LIT75, boxvar_BackendVariable_setVarStartValue, _inVar, _globalKnownVars);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_selectFreeValue(threadData_t *threadData, modelica_metatype _iZeroFreeValues, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_metatype *out_warnAliasConflicts)
{
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVar = NULL;
  _outVar = omc_RemoveSimpleEquations_selectFreeValue(threadData, _iZeroFreeValues, _inVar, _globalKnownVars, &_warnAliasConflicts);
  /* skip box _outVar; BackendDAE.Var */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getZeroFreeValues(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _iAcc)
{
  modelica_metatype _oAcc = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oAcc has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inTpl;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _e = tmpMeta7;
          _cr = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_box2(0, _e, _cr);
          tmpMeta9 = mmc_mk_cons(tmpMeta10, _iAcc);
          tmpMeta1 = tmpMeta9;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iAcc;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oAcc = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oAcc;
}

static modelica_metatype closure2_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *thData, modelica_metatype closure, modelica_metatype exp, modelica_metatype replaced, modelica_metatype tmp10)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype replacedCrefs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(thData, exp, replaced, vars, replacedCrefs, tmp10);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *threadData, modelica_metatype _exp, modelica_boolean _replaced, modelica_metatype _vars, modelica_metatype _replacedCrefs, modelica_boolean *out_outReplaced)
{
  modelica_metatype _outExp = NULL;
  modelica_boolean _outReplaced;
  modelica_metatype _cr = NULL;
  modelica_metatype _e = NULL;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _outReplaced has no default value.
  // _cr has no default value.
  // _e has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!omc_UnorderedSet_contains(threadData, _cr, _replacedCrefs))) goto tmp3_end;
          /* Pattern-matching tuple assignment */
          tmpMeta7 = omc_BackendVariable_getVarSingle(threadData, _cr, _vars, NULL);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 7));
          if (optionNone(tmpMeta8)) goto goto_2;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          _e = tmpMeta9;

          omc_UnorderedSet_add(threadData, _cr, _replacedCrefs);

          tmpMeta11 = mmc_mk_box2(0, _vars, _replacedCrefs);
          _e = omc_Expression_traverseExpBottomUp(threadData, _e, (modelica_fnptr) mmc_mk_box2(0,closure2_RemoveSimpleEquations_replaceCrefWithBindExp__traverser,tmpMeta11), mmc_mk_boolean(0 /* false */), NULL);
          tmpMeta[0+0] = _e;
          tmp1_c1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _exp;
          tmp1_c1 = 1 /* true */;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _exp;
          tmp1_c1 = _replaced;
          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:;
    }
  }
  _outExp = tmpMeta[0+0];
  _outReplaced = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_outReplaced) { *out_outReplaced = _outReplaced; }
  return _outExp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _replaced, modelica_metatype _vars, modelica_metatype _replacedCrefs, modelica_metatype *out_outReplaced)
{
  modelica_integer tmp1;
  modelica_boolean _outReplaced;
  modelica_metatype _outExp = NULL;
  tmp1 = mmc_unbox_integer(_replaced);
  _outExp = omc_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData, _exp, tmp1, _vars, _replacedCrefs, &_outReplaced);
  /* skip box _outExp; DAE.Exp */
  if (out_outReplaced) { *out_outReplaced = mmc_mk_icon(_outReplaced); }
  return _outExp;
}

static modelica_metatype closure3_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(threadData_t *thData, modelica_metatype closure, modelica_metatype exp, modelica_metatype replaced, modelica_metatype tmp3)
{
  modelica_metatype vars = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype replacedCrefs = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_RemoveSimpleEquations_replaceCrefWithBindExp__traverser(thData, exp, replaced, vars, replacedCrefs, tmp3);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _vars, modelica_boolean *out_replaced)
{
  modelica_metatype _outExp = NULL;
  modelica_boolean _replaced;
  modelica_metatype _replaced_crefs = NULL;
  modelica_metatype tmpMeta1;
  modelica_integer tmp2;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _replaced has no default value.
  _replaced_crefs = omc_UnorderedSet_new(threadData, boxvar_ComponentReferenceBasics_hashComponentRef, boxvar_ComponentReferenceBasics_crefEqual, ((modelica_integer) 13));
  /* Pattern-matching tuple assignment */
  tmpMeta4 = mmc_mk_box2(0, _vars, _replaced_crefs);
  tmpMeta5 = omc_Expression_traverseExpBottomUp(threadData, _exp, (modelica_fnptr) mmc_mk_box2(0,closure3_RemoveSimpleEquations_replaceCrefWithBindExp__traverser,tmpMeta4), mmc_mk_boolean(0 /* false */), &tmpMeta1);
  _outExp = tmpMeta5;
  tmp2 = mmc_unbox_integer(tmpMeta1);
  _replaced = tmp2  /* pattern as ty=Boolean */;
  _return: OMC_LABEL_UNUSED
  if (out_replaced) { *out_replaced = _replaced; }
  return _outExp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _vars, modelica_metatype *out_replaced)
{
  modelica_boolean _replaced;
  modelica_metatype _outExp = NULL;
  _outExp = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _exp, _vars, &_replaced);
  /* skip box _outExp; DAE.Exp */
  if (out_replaced) { *out_replaced = mmc_mk_icon(_replaced); }
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_equalFreeStartValues(threadData_t *threadData, modelica_metatype _iValues, modelica_metatype _globalKnownVars, modelica_metatype _iValue)
{
  modelica_metatype _oValue = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oValue has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _iValues;
    tmp4_2 = _iValue;
    {
      modelica_metatype _values = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_boolean _b;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _values has no default value.
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _b has no default value.
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iValue;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (!optionNone(tmpMeta8)) goto tmp3_end;
          
          _values = tmpMeta7;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _iValues = _values;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          if (!optionNone(tmpMeta9)) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          if (optionNone(tmpMeta12)) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          _e = tmpMeta13;
          _cr = tmpMeta14;
          _values = tmpMeta11;
          /* Pattern matching succeeded */
          _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

          _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);
          tmpMeta15 = mmc_mk_box3(0, mmc_mk_some(_e1), mmc_mk_some(_e), _cr);
          /* Tail recursive call */
          _iValues = _values;
          _iValue = tmpMeta15;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_boolean tmp22;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          if (optionNone(tmpMeta16)) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 1));
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta18 = MMC_CAR(tmp4_1);
          tmpMeta19 = MMC_CDR(tmp4_1);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 1));
          if (optionNone(tmpMeta20)) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 1));
          
          _e2 = tmpMeta17;
          _e = tmpMeta21;
          _values = tmpMeta19;
          /* Pattern matching succeeded */
          _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

          _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

          /* Pattern-matching assignment */
          tmp22 = omc_ExpressionBasics_expEqual(threadData, _e1, _e2);
          if (1 /* true */ != tmp22) goto goto_2;
          /* Tail recursive call */
          _iValues = _values;
          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:;
    }
  }
  _oValue = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oValue;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_equalNonFreeStartValues(threadData_t *threadData, modelica_metatype _iValues, modelica_metatype _globalKnownVars, modelica_metatype _iValue)
{
  modelica_metatype _oValue = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oValue has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _iValues;
    tmp4_2 = _iValue;
    {
      modelica_metatype _values = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_boolean _b;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _values has no default value.
      // _e has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _b has no default value.
      // _cr has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iValue;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (!optionNone(tmpMeta8)) goto tmp3_end;
          
          _values = tmpMeta7;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _iValues = _values;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          if (!optionNone(tmpMeta9)) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          if (!optionNone(tmpMeta12)) goto tmp3_end;
          
          _values = tmpMeta11;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _iValues = _values;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          if (optionNone(tmpMeta13)) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          if (!optionNone(tmpMeta17)) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          _e2 = tmpMeta14;
          _cr = tmpMeta18;
          _values = tmpMeta16;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _e2)) goto tmp3_end;
          tmpMeta19 = mmc_mk_box3(0, mmc_mk_none(), mmc_mk_none(), _cr);
          /* Tail recursive call */
          _iValues = _values;
          _iValue = tmpMeta19;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_boolean tmp26;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          if (optionNone(tmpMeta20)) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 1));
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta22 = MMC_CAR(tmp4_1);
          tmpMeta23 = MMC_CDR(tmp4_1);
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 1));
          if (optionNone(tmpMeta24)) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
          
          _e2 = tmpMeta21;
          _e = tmpMeta25;
          _values = tmpMeta23;
          /* Pattern matching succeeded */
          _e1 = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

          _e1 = omc_ExpressionSimplify_condsimplify(threadData, _b, _e1, NULL);

          /* Pattern-matching assignment */
          tmp26 = omc_ExpressionBasics_expEqual(threadData, _e1, _e2);
          if (1 /* true */ != tmp26) goto goto_2;
          /* Tail recursive call */
          _iValues = _values;
          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:;
    }
  }
  _oValue = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oValue;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_optExpReplaceCrefWithBindExp(threadData_t *threadData, modelica_metatype _iOExp, modelica_metatype _globalKnownVars)
{
  modelica_metatype _oOExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oOExp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iOExp;
    {
      modelica_metatype _e = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _b has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _e = tmpMeta6;
          /* Pattern matching succeeded */
          _e = omc_RemoveSimpleEquations_replaceCrefWithBindExp(threadData, _e, _globalKnownVars ,&_b);

          _e = omc_ExpressionSimplify_condsimplify(threadData, _b, _e, NULL);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iOExp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oOExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oOExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleVarSetAttributes(threadData_t *threadData, modelica_metatype _inAttributes, modelica_metatype _inVar, modelica_metatype _inVars, modelica_metatype _inShared, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVars = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  _warnAliasConflicts = 0 /* false */;
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inAttributes;
    tmp4_2 = _inShared;
    {
      modelica_boolean _fixedset;
      modelica_boolean _isdiscrete;
      modelica_boolean _b1;
      modelica_boolean _b2;
      modelica_metatype _nominalset = NULL;
      modelica_metatype _minmaxset = NULL;
      modelica_metatype _startvalues = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _min = NULL;
      modelica_metatype _max = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _fixedset has no default value.
      // _isdiscrete has no default value.
      _b1 = 0 /* false */;
      _b2 = 0 /* false */;
      // _nominalset has no default value.
      // _minmaxset has no default value.
      // _startvalues has no default value.
      _v = _inVar;
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _min has no default value.
      // _max has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _fixedset = tmp7  /* pattern as ty=Boolean */;
          _startvalues = tmpMeta8;
          _nominalset = tmpMeta9;
          _minmaxset = tmpMeta10;
          _globalKnownVars = tmpMeta11;
          /* Pattern matching succeeded */
          _isdiscrete = omc_BackendVariable_isVarDiscrete(threadData, _inVar);

          if((!_isdiscrete))
          {
            _v = omc_RemoveSimpleEquations_mergeStartFixedAttributes(threadData, _inVar, _fixedset, _startvalues, _inShared ,&_b1);
          }

          _v = omc_RemoveSimpleEquations_mergeNominalAttribute(threadData, _nominalset, _v, _globalKnownVars ,&_b2);

          /* Pattern-matching assignment */
          tmpMeta12 = _minmaxset;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          _min = tmpMeta13;
          _max = tmpMeta14;

          if(isSome(_min))
          {
            _min = mmc_mk_some(omc_ExpressionSimplify_simplify(threadData, omc_Util_getOption(threadData, _min), NULL));
          }

          if(isSome(_max))
          {
            _max = mmc_mk_some(omc_ExpressionSimplify_simplify(threadData, omc_Util_getOption(threadData, _max), NULL));
          }

          _v = omc_BackendVariable_setVarMinMax(threadData, _v, _min, _max);

          _vars = omc_BackendVariable_addVar(threadData, _v, _inVars);

          _warnAliasConflicts = (_b1 || _b2);
          tmpMeta1 = _vars;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT76),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outVars = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleVarSetAttributes(threadData_t *threadData, modelica_metatype _inAttributes, modelica_metatype _inVar, modelica_metatype _inVars, modelica_metatype _inShared, modelica_metatype *out_warnAliasConflicts)
{
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVars = NULL;
  _outVars = omc_RemoveSimpleEquations_handleVarSetAttributes(threadData, _inAttributes, _inVar, _inVars, _inShared, &_warnAliasConflicts);
  /* skip box _outVars; BackendDAE.Variables */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC void omc_RemoveSimpleEquations_checkMinMax(threadData_t *threadData, modelica_metatype _minmax, modelica_integer _mark, modelica_metatype _simpleeqnsarr)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* matchcontinue expression */
    volatile modelica_metatype tmp3_1;
    tmp3_1 = _minmax;
    {
      modelica_metatype _min = NULL;
      modelica_metatype _max = NULL;
      modelica_string _s = NULL;
      modelica_string _s4 = NULL;
      modelica_string _s5 = NULL;
      modelica_real _rmin;
      modelica_real _rmax;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _min has no default value.
      // _max has no default value.
      // _s has no default value.
      // _s4 has no default value.
      // _s5 has no default value.
      // _rmin has no default value.
      // _rmax has no default value.
      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_boolean tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 1));
          if (optionNone(tmpMeta5)) goto tmp2_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_1), 2));
          if (optionNone(tmpMeta7)) goto tmp2_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          _min = tmpMeta6;
          _max = tmpMeta8;
          /* Pattern matching succeeded */
          _rmin = omc_Expression_toReal(threadData, _min);

          _rmax = omc_Expression_toReal(threadData, _max);

          /* Pattern-matching assignment */
          tmp9 = (_rmin > _rmax);
          if (1 /* true */ != tmp9) goto goto_1;

          _s4 = omc_ExpressionBasics_printExpStr(threadData, _min);

          _s5 = omc_ExpressionBasics_printExpStr(threadData, _max);

          tmpMeta10 = mmc_mk_cons(_OMC_LIT77, mmc_mk_cons(_s4, mmc_mk_cons(_OMC_LIT78, mmc_mk_cons(_s5, MMC_REFSTRUCTLIT(mmc_nil)))));
          _s = stringAppendList(tmpMeta10);

          tmpMeta11 = mmc_mk_cons(_s, MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addMessage(threadData, _OMC_LIT67, tmpMeta11);
          goto tmp2_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}
PROTECTED_FUNCTION_STATIC void boxptr_RemoveSimpleEquations_checkMinMax(threadData_t *threadData, modelica_metatype _minmax, modelica_metatype _mark, modelica_metatype _simpleeqnsarr)
{
  modelica_integer tmp1;
  tmp1 = mmc_unbox_integer(_mark);
  omc_RemoveSimpleEquations_checkMinMax(threadData, _minmax, tmp1, _simpleeqnsarr);
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeMinMax1(threadData_t *threadData, modelica_metatype _ominmax, modelica_metatype _ominmax1)
{
  modelica_metatype _minMax = NULL;
  modelica_metatype _omin = NULL;
  modelica_metatype _omin1 = NULL;
  modelica_metatype _omin2 = NULL;
  modelica_metatype _omax = NULL;
  modelica_metatype _omax1 = NULL;
  modelica_metatype _omax2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _minMax has no default value.
  // _omin has no default value.
  // _omin1 has no default value.
  // _omin2 has no default value.
  // _omax has no default value.
  // _omax1 has no default value.
  // _omax2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _ominmax;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _omin = tmpMeta2;
  _omax = tmpMeta3;

  /* Pattern-matching assignment */
  tmpMeta4 = _ominmax1;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  _omin1 = tmpMeta5;
  _omax1 = tmpMeta6;

  _omin2 = omc_Expression_expOptMaxScalar(threadData, _omin, _omin1);

  _omax2 = omc_Expression_expOptMinScalar(threadData, _omax, _omax1);

  if((referenceEq(_omin2, _omin) && referenceEq(_omax2, _omax)))
  {
    _minMax = _ominmax;
  }
  else
  {
    if((referenceEq(_omin2, _omin1) && referenceEq(_omax2, _omax1)))
    {
      _minMax = _ominmax1;
    }
    else
    {
      tmpMeta7 = mmc_mk_box2(0, _omin2, _omax2);
      _minMax = tmpMeta7;
    }
  }
  _return: OMC_LABEL_UNUSED
  return _minMax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeMinMax(threadData_t *threadData, modelica_boolean _negate, modelica_metatype _ominmax, modelica_metatype _ominmax1, modelica_integer _mark, modelica_metatype _simpleeqnsarr)
{
  modelica_metatype _outMinMax = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outMinMax has no default value.
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _negate;
    tmp4_2 = _ominmax;
    {
      modelica_metatype _min = NULL;
      modelica_metatype _max = NULL;
      modelica_metatype _min1 = NULL;
      modelica_metatype _max1 = NULL;
      modelica_metatype _omin = NULL;
      modelica_metatype _omax = NULL;
      modelica_metatype _minMax = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _min has no default value.
      // _max has no default value.
      // _min1 has no default value.
      // _max1 has no default value.
      // _omin has no default value.
      // _omax has no default value.
      // _minMax has no default value.
      tmp4 = 0;
      for (; tmp4 < 7; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _ominmax1;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_2);
          tmpMeta7 = MMC_CDR(tmp4_2);
          if (listEmpty(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmpMeta7);
          tmpMeta9 = MMC_CDR(tmpMeta7);
          if (!listEmpty(tmpMeta9)) goto tmp3_end;
          _omin = tmpMeta6;
          _omax = tmpMeta8;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_box2(0, _omin, _omax);
          _minMax = omc_RemoveSimpleEquations_mergeMinMax1(threadData, tmpMeta10, _ominmax1);

          omc_RemoveSimpleEquations_checkMinMax(threadData, _minMax, _mark, _simpleeqnsarr);
          tmpMeta1 = _minMax;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta11 = MMC_CAR(tmp4_2);
          tmpMeta12 = MMC_CDR(tmp4_2);
          if (!optionNone(tmpMeta11)) goto tmp3_end;
          if (listEmpty(tmpMeta12)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmpMeta12);
          tmpMeta14 = MMC_CDR(tmpMeta12);
          if (!optionNone(tmpMeta13)) goto tmp3_end;
          if (!listEmpty(tmpMeta14)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _ominmax1;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_2);
          tmpMeta16 = MMC_CDR(tmp4_2);
          if (optionNone(tmpMeta15)) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          if (listEmpty(tmpMeta16)) goto tmp3_end;
          tmpMeta18 = MMC_CAR(tmpMeta16);
          tmpMeta19 = MMC_CDR(tmpMeta16);
          if (optionNone(tmpMeta18)) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 1));
          if (!listEmpty(tmpMeta19)) goto tmp3_end;
          _min = tmpMeta17;
          _max = tmpMeta20;
          /* Pattern matching succeeded */
          _min1 = omc_RemoveSimpleEquations_negateExpression(threadData, 1 /* true */, _min, _min, _OMC_LIT79);

          _max1 = omc_RemoveSimpleEquations_negateExpression(threadData, 1 /* true */, _max, _max, _OMC_LIT80);

          tmpMeta21 = mmc_mk_box2(0, mmc_mk_some(_max1), mmc_mk_some(_min1));
          _minMax = omc_RemoveSimpleEquations_mergeMinMax1(threadData, tmpMeta21, _ominmax1);

          omc_RemoveSimpleEquations_checkMinMax(threadData, _minMax, _mark, _simpleeqnsarr);
          tmpMeta1 = _minMax;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta22 = MMC_CAR(tmp4_2);
          tmpMeta23 = MMC_CDR(tmp4_2);
          if (!optionNone(tmpMeta22)) goto tmp3_end;
          if (listEmpty(tmpMeta23)) goto tmp3_end;
          tmpMeta24 = MMC_CAR(tmpMeta23);
          tmpMeta25 = MMC_CDR(tmpMeta23);
          if (optionNone(tmpMeta24)) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
          if (!listEmpty(tmpMeta25)) goto tmp3_end;
          _max = tmpMeta26;
          /* Pattern matching succeeded */
          _max1 = omc_RemoveSimpleEquations_negateExpression(threadData, 1 /* true */, _max, _max, _OMC_LIT81);

          tmpMeta27 = mmc_mk_box2(0, mmc_mk_some(_max1), mmc_mk_none());
          _minMax = omc_RemoveSimpleEquations_mergeMinMax1(threadData, tmpMeta27, _ominmax1);

          omc_RemoveSimpleEquations_checkMinMax(threadData, _minMax, _mark, _simpleeqnsarr);
          tmpMeta1 = _minMax;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta28 = MMC_CAR(tmp4_2);
          tmpMeta29 = MMC_CDR(tmp4_2);
          if (optionNone(tmpMeta28)) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          if (listEmpty(tmpMeta29)) goto tmp3_end;
          tmpMeta31 = MMC_CAR(tmpMeta29);
          tmpMeta32 = MMC_CDR(tmpMeta29);
          if (!optionNone(tmpMeta31)) goto tmp3_end;
          if (!listEmpty(tmpMeta32)) goto tmp3_end;
          _min = tmpMeta30;
          /* Pattern matching succeeded */
          _min1 = omc_RemoveSimpleEquations_negateExpression(threadData, 1 /* true */, _min, _min, _OMC_LIT82);

          tmpMeta33 = mmc_mk_box2(0, mmc_mk_none(), mmc_mk_some(_min1));
          _minMax = omc_RemoveSimpleEquations_mergeMinMax1(threadData, tmpMeta33, _ominmax1);

          omc_RemoveSimpleEquations_checkMinMax(threadData, _minMax, _mark, _simpleeqnsarr);
          tmpMeta1 = _minMax;
          goto tmp3_done;
        }
        case 6: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT83),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outMinMax = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outMinMax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeMinMax(threadData_t *threadData, modelica_metatype _negate, modelica_metatype _ominmax, modelica_metatype _ominmax1, modelica_metatype _mark, modelica_metatype _simpleeqnsarr)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _outMinMax = NULL;
  tmp1 = mmc_unbox_integer(_negate);
  tmp2 = mmc_unbox_integer(_mark);
  _outMinMax = omc_RemoveSimpleEquations_mergeMinMax(threadData, tmp1, _ominmax, _ominmax1, tmp2, _simpleeqnsarr);
  /* skip box _outMinMax; tuple<Option<DAE.Exp>, Option<DAE.Exp>> */
  return _outMinMax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addMinMaxAttribute(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMinMax)
{
  modelica_metatype _oMinMax = NULL;
  modelica_metatype _attr = NULL;
  modelica_metatype _ominmax = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oMinMax has no default value.
  // _attr has no default value.
  // _ominmax has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inVar;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 11));
  _attr = tmpMeta2;

  _ominmax = omc_DAEUtil_getMinMax(threadData, _attr);

  _oMinMax = omc_RemoveSimpleEquations_mergeMinMax(threadData, _negate, _ominmax, _iMinMax, _mark, _simpleeqnsarr);
  _return: OMC_LABEL_UNUSED
  return _oMinMax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addMinMaxAttribute(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMinMax)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _oMinMax = NULL;
  tmp1 = mmc_unbox_integer(_negate);
  tmp2 = mmc_unbox_integer(_mark);
  _oMinMax = omc_RemoveSimpleEquations_addMinMaxAttribute(threadData, _inVar, tmp1, tmp2, _simpleeqnsarr, _iMinMax);
  /* skip box _oMinMax; tuple<Option<DAE.Exp>, Option<DAE.Exp>> */
  return _oMinMax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeNominalAttribute(threadData_t *threadData, modelica_metatype _nominalList, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVar = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  _warnAliasConflicts = 0 /* false */;
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _nominalList;
    {
      modelica_metatype _e = NULL;
      modelica_metatype _allExp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _allExp has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          
          /* Pattern matching succeeded */
          _allExp = omc_List_map(threadData, _nominalList, boxvar_Util_tuple21);

          /* Pattern-matching assignment */
          tmpMeta6 = omc_List_uniqueOnTrue(threadData, _allExp, boxvar_ExpressionBasics_expEqual);
          if (listEmpty(tmpMeta6)) goto goto_2;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (!listEmpty(tmpMeta8)) goto goto_2;
          _e = tmpMeta7;
          tmpMeta1 = omc_BackendVariable_setVarNominalValue(threadData, _inVar, _e);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          
          /* Pattern matching succeeded */
          _warnAliasConflicts = (!omc_Flags_isSet(threadData, _OMC_LIT70));
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = omc_RemoveSimpleEquations_selectFreeValue1(threadData, _nominalList, tmpMeta9, _OMC_LIT84, _OMC_LIT85, boxvar_BackendVariable_setVarNominalValue, _inVar, _globalKnownVars);
          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:;
    }
  }
  _outVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeNominalAttribute(threadData_t *threadData, modelica_metatype _nominalList, modelica_metatype _inVar, modelica_metatype _globalKnownVars, modelica_metatype *out_warnAliasConflicts)
{
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVar = NULL;
  _outVar = omc_RemoveSimpleEquations_mergeNominalAttribute(threadData, _nominalList, _inVar, _globalKnownVars, &_warnAliasConflicts);
  /* skip box _outVar; BackendDAE.Var */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addNominalValue(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _iNominal)
{
  modelica_metatype _oNominal = NULL;
  modelica_metatype _nominal = NULL;
  modelica_metatype _cr = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oNominal has no default value.
  // _nominal has no default value.
  // _cr has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          /* Pattern matching succeeded */
          _nominal = omc_BackendVariable_varNominalValue(threadData, _inVar);

          _cr = omc_BackendVariable_varCref(threadData, _inVar);

          tmpMeta6 = mmc_mk_box2(0, _nominal, _cr);
          tmpMeta5 = mmc_mk_cons(tmpMeta6, _iNominal);
          _oNominal = tmpMeta5;
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          _oNominal = _iNominal;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _oNominal;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_mergeStartFixedAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _fixed, modelica_metatype _startvalues, modelica_metatype _ishared, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVar = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVar has no default value.
  _warnAliasConflicts = 0 /* false */;
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _fixed;
    tmp4_2 = _startvalues;
    tmp4_3 = _ishared;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _start = NULL;
      modelica_metatype _start1 = NULL;
      modelica_metatype _startExp = NULL;
      modelica_metatype _values = NULL;
      modelica_metatype _zerofreevalues = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_string _str = NULL;
      modelica_integer _i;
      modelica_boolean _hardcoded;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _start has no default value.
      // _start1 has no default value.
      // _startExp has no default value.
      // _values has no default value.
      // _zerofreevalues has no default value.
      // _v has no default value.
      // _globalKnownVars has no default value.
      // _str has no default value.
      // _i has no default value.
      // _hardcoded 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;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (!listEmpty(tmpMeta6)) goto tmp3_end;
          
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmpMeta1 = _inVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (listEmpty(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmpMeta7);
          tmpMeta9 = MMC_CDR(tmpMeta7);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          if (!listEmpty(tmpMeta9)) goto tmp3_end;
          
          _start = tmpMeta10;
          /* Pattern matching succeeded */
          _v = omc_BackendVariable_setVarFixed(threadData, _inVar, 1 /* true */);
          tmpMeta1 = omc_BackendVariable_setVarStartValueOption(threadData, _v, _start);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (listEmpty(tmpMeta11)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _start = tmpMeta14;
          _cr = tmpMeta15;
          _values = tmpMeta13;
          _globalKnownVars = tmpMeta16;
          /* Pattern matching succeeded */
          _v = omc_BackendVariable_setVarFixed(threadData, _inVar, 1 /* true */);

          _start1 = omc_RemoveSimpleEquations_optExpReplaceCrefWithBindExp(threadData, _start, _globalKnownVars);

          /* Pattern-matching assignment */
          tmpMeta17 = mmc_mk_box3(0, _start1, _start, _cr);
          tmpMeta18 = omc_RemoveSimpleEquations_equalNonFreeStartValues(threadData, _values, _globalKnownVars, tmpMeta17);
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          _start = tmpMeta19;

          _warnAliasConflicts = (!omc_Flags_isSet(threadData, _OMC_LIT70));
          tmpMeta1 = omc_BackendVariable_setVarStartValueOption(threadData, _v, _start);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          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;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _values = tmpMeta20;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          if((!omc_Flags_isSet(threadData, _OMC_LIT70)))
          {
            tmpMeta21 = MMC_REFSTRUCTLIT(mmc_nil);
            omc_Error_addMessage(threadData, _OMC_LIT91, tmpMeta21);
          }
          else
          {
            tmpMeta22 = MMC_REFSTRUCTLIT(mmc_nil);
            _zerofreevalues = omc_List_fold(threadData, _values, boxvar_RemoveSimpleEquations_getZeroFreeValues, tmpMeta22);

            _str = _OMC_LIT86;

            {
              modelica_metatype _value;
              for (tmpMeta23 = _zerofreevalues; !listEmpty(tmpMeta23); tmpMeta23=MMC_CDR(tmpMeta23))
              {
                _value = MMC_CAR(tmpMeta23);
                /* Pattern-matching assignment */
                tmpMeta24 = _value;
                tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 1));
                tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta24), 2));
                _startExp = tmpMeta25;
                _cr = tmpMeta26;

                /* Pattern-matching tuple assignment, wild first pattern */
                tmpMeta32 = mmc_mk_box2(0, mmc_mk_integer(omc_ComponentReference_crefDepth(threadData, _cr)), mmc_mk_boolean(1 /* true */));
                omc_Expression_traverseExpTopDown(threadData, _startExp, boxvar_RemoveSimpleEquations_selectMinDepth, tmpMeta32, &tmpMeta27);
                tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 1));
                tmp29 = mmc_unbox_integer(tmpMeta28);
                tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
                tmp31 = mmc_unbox_integer(tmpMeta30);
                _i = tmp29  /* pattern as ty=Integer */;
                _hardcoded = tmp31  /* pattern as ty=Boolean */;

                if(_hardcoded)
                {
                  _i = ((modelica_integer) 5) + _i;
                }

                tmpMeta33 = stringAppend(_str,_OMC_LIT71);
                tmpMeta34 = stringAppend(tmpMeta33,omc_ComponentReferenceBasics_printComponentRefStr(threadData, _cr));
                tmpMeta35 = stringAppend(tmpMeta34,_OMC_LIT87);
                tmpMeta36 = stringAppend(tmpMeta35,omc_ExpressionBasics_printExpStr(threadData, _startExp));
                tmpMeta37 = stringAppend(tmpMeta36,_OMC_LIT72);
                tmpMeta38 = stringAppend(tmpMeta37,intString(_i));
                tmpMeta39 = stringAppend(tmpMeta38,_OMC_LIT73);
                _str = tmpMeta39;
              }
            }

            omc_Error_addCompilerError(threadData, _str);
          }
          goto goto_2;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (listEmpty(tmpMeta41)) goto tmp3_end;
          tmpMeta42 = MMC_CAR(tmpMeta41);
          tmpMeta43 = MMC_CDR(tmpMeta41);
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta42), 1));
          if (!listEmpty(tmpMeta43)) goto tmp3_end;
          
          _start = tmpMeta44;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendVariable_setVarStartValueOption(threadData, _inVar, _start);
          goto tmp3_done;
        }
        case 5: {
          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;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (listEmpty(tmpMeta45)) goto tmp3_end;
          tmpMeta46 = MMC_CAR(tmpMeta45);
          tmpMeta47 = MMC_CDR(tmpMeta45);
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 1));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 2));
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _start = tmpMeta48;
          _cr = tmpMeta49;
          _values = tmpMeta47;
          _globalKnownVars = tmpMeta50;
          /* Pattern matching succeeded */
          _start1 = omc_RemoveSimpleEquations_optExpReplaceCrefWithBindExp(threadData, _start, _globalKnownVars);

          /* Pattern-matching assignment */
          tmpMeta51 = mmc_mk_box3(0, _start1, _start, _cr);
          tmpMeta52 = omc_RemoveSimpleEquations_equalFreeStartValues(threadData, _values, _globalKnownVars, tmpMeta51);
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          _start = tmpMeta53;
          tmpMeta1 = omc_BackendVariable_setVarStartValueOption(threadData, _inVar, _start);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _values = tmpMeta54;
          _globalKnownVars = tmpMeta55;
          /* Pattern matching succeeded */
          tmpMeta56 = MMC_REFSTRUCTLIT(mmc_nil);
          _zerofreevalues = omc_List_fold(threadData, _values, boxvar_RemoveSimpleEquations_getZeroFreeValues, tmpMeta56);

          _v = omc_RemoveSimpleEquations_selectFreeValue(threadData, _zerofreevalues, _inVar, _globalKnownVars ,&_warnAliasConflicts);
          tmpMeta1 = _v;
          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:;
    }
  }
  _outVar = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVar;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_mergeStartFixedAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _fixed, modelica_metatype _startvalues, modelica_metatype _ishared, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVar = NULL;
  tmp1 = mmc_unbox_integer(_fixed);
  _outVar = omc_RemoveSimpleEquations_mergeStartFixedAttributes(threadData, _inVar, tmp1, _startvalues, _ishared, &_warnAliasConflicts);
  /* skip box _outVar; BackendDAE.Var */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVar;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_addStartValue(threadData_t *threadData, modelica_boolean _fixed, modelica_boolean _fixedset, modelica_metatype _cr, modelica_metatype _start, modelica_metatype _origin, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iStartvalues, modelica_metatype *out_oStartvalues)
{
  modelica_boolean _oFixed;
  modelica_metatype _oStartvalues = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oFixed has no default value.
  // _oStartvalues has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_boolean tmp4_2;volatile modelica_metatype tmp4_3;volatile modelica_metatype tmp4_4;
    tmp4_1 = _fixed;
    tmp4_2 = _fixedset;
    tmp4_3 = _start;
    tmp4_4 = _iStartvalues;
    {
      modelica_metatype _startexp = NULL;
      modelica_integer _setorigin;
      modelica_integer _originvalue;
      modelica_metatype _startvalues = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _startexp has no default value.
      // _setorigin has no default value.
      // _originvalue has no default value.
      // _startvalues has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp1_c0 = _fixedset;
          tmpMeta[0+1] = _iStartvalues;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (!optionNone(tmp4_3)) goto tmp3_end;
          
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _originvalue = omc_BackendVariable_startOriginToValue(threadData, _origin);
          tmpMeta7 = mmc_mk_box2(0, _start, _cr);
          tmpMeta6 = mmc_mk_cons(tmpMeta7, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta8 = mmc_mk_box2(0, mmc_mk_integer(_originvalue), tmpMeta6);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta8;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          
          _startexp = tmpMeta9;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _startexp = omc_RemoveSimpleEquations_negateExpression(threadData, _negate, _startexp, _startexp, _OMC_LIT92);

          _originvalue = omc_BackendVariable_startOriginToValue(threadData, _origin);
          tmpMeta11 = mmc_mk_box2(0, mmc_mk_some(_startexp), _cr);
          tmpMeta10 = mmc_mk_cons(tmpMeta11, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta12 = mmc_mk_box2(0, mmc_mk_integer(_originvalue), tmpMeta10);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta12;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_boolean tmp19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          if (!optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          _setorigin = tmp14  /* pattern as ty=Integer */;
          _startvalues = tmpMeta15;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          _originvalue = omc_BackendVariable_startOriginToValue(threadData, _origin);

          if((_originvalue > _setorigin))
          {
            _setorigin = _originvalue;

            tmp19 = (modelica_boolean)_fixed;
            if(tmp19)
            {
              tmpMeta17 = mmc_mk_box2(0, _start, _cr);
              tmpMeta16 = mmc_mk_cons(tmpMeta17, MMC_REFSTRUCTLIT(mmc_nil));
              tmpMeta20 = tmpMeta16;
            }
            else
            {
              tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
              tmpMeta20 = tmpMeta18;
            }
            _startvalues = tmpMeta20;
          }
          else
          {
            if(((_originvalue == _setorigin) && _fixed))
            {
              tmpMeta22 = mmc_mk_box2(0, _start, _cr);
              tmpMeta21 = mmc_mk_cons(tmpMeta22, _startvalues);
              _startvalues = tmpMeta21;
            }
          }
          tmpMeta23 = mmc_mk_box2(0, mmc_mk_integer(_setorigin), _startvalues);
          tmp1_c0 = _fixedset;
          tmpMeta[0+1] = tmpMeta23;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          if (optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          _startexp = tmpMeta24;
          _setorigin = tmp26  /* pattern as ty=Integer */;
          _startvalues = tmpMeta27;
          /* Pattern matching succeeded */
          _startexp = omc_RemoveSimpleEquations_negateExpression(threadData, _negate, _startexp, _startexp, _OMC_LIT93);

          _originvalue = omc_BackendVariable_startOriginToValue(threadData, _origin);

          if((_originvalue > _setorigin))
          {
            _setorigin = _originvalue;

            tmpMeta29 = mmc_mk_box2(0, mmc_mk_some(_startexp), _cr);
            tmpMeta28 = mmc_mk_cons(tmpMeta29, MMC_REFSTRUCTLIT(mmc_nil));
            _startvalues = tmpMeta28;
          }
          else
          {
            if((_originvalue == _setorigin))
            {
              tmpMeta31 = mmc_mk_box2(0, mmc_mk_some(_startexp), _cr);
              tmpMeta30 = mmc_mk_cons(tmpMeta31, _startvalues);
              _startvalues = tmpMeta30;
            }
          }
          tmpMeta32 = mmc_mk_box2(0, mmc_mk_integer(_setorigin), _startvalues);
          tmp1_c0 = _fixedset;
          tmpMeta[0+1] = tmpMeta32;
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          fputs(MMC_STRINGDATA(_OMC_LIT94),stdout);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 6) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oFixed = tmp1_c0;
  _oStartvalues = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_oStartvalues) { *out_oStartvalues = _oStartvalues; }
  return _oFixed;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addStartValue(threadData_t *threadData, modelica_metatype _fixed, modelica_metatype _fixedset, modelica_metatype _cr, modelica_metatype _start, modelica_metatype _origin, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iStartvalues, modelica_metatype *out_oStartvalues)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_boolean _oFixed;
  modelica_metatype out_oFixed;
  tmp1 = mmc_unbox_integer(_fixed);
  tmp2 = mmc_unbox_integer(_fixedset);
  tmp3 = mmc_unbox_integer(_negate);
  tmp4 = mmc_unbox_integer(_mark);
  _oFixed = omc_RemoveSimpleEquations_addStartValue(threadData, tmp1, tmp2, _cr, _start, _origin, tmp3, tmp4, _simpleeqnsarr, _iStartvalues, out_oStartvalues);
  out_oFixed = mmc_mk_icon(_oFixed);
  /* skip box _oStartvalues; tuple<#Integer, list<tuple<Option<DAE.Exp>, DAE.ComponentRef>>> */
  return out_oFixed;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addVarSetAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_boolean _negate, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iAttributes)
{
  modelica_metatype _oAttributes = NULL;
  modelica_boolean _fixed;
  modelica_boolean _fixedset;
  modelica_metatype _start = NULL;
  modelica_metatype _origin = NULL;
  modelica_metatype _nominalset = NULL;
  modelica_metatype _minmaxset = NULL;
  modelica_metatype _startvalues = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oAttributes has no default value.
  // _fixed has no default value.
  // _fixedset has no default value.
  // _start has no default value.
  // _origin has no default value.
  // _nominalset has no default value.
  // _minmaxset has no default value.
  // _startvalues has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _iAttributes;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmp3 = mmc_unbox_integer(tmpMeta2);
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _fixedset = tmp3  /* pattern as ty=Boolean */;
  _startvalues = tmpMeta4;
  _nominalset = tmpMeta5;
  _minmaxset = tmpMeta6;

  _fixed = omc_BackendVariable_varFixed(threadData, _inVar);

  _start = omc_BackendVariable_varStartValueOption(threadData, _inVar);

  _origin = omc_BackendVariable_varStartOrigin(threadData, _inVar);

  _fixedset = omc_RemoveSimpleEquations_addStartValue(threadData, _fixed, _fixedset, omc_BackendVariable_varCref(threadData, _inVar), _start, _origin, _negate, _mark, _simpleeqnsarr, _startvalues ,&_startvalues);

  _nominalset = omc_RemoveSimpleEquations_addNominalValue(threadData, _inVar, _nominalset);

  _minmaxset = omc_RemoveSimpleEquations_addMinMaxAttribute(threadData, _inVar, _negate, _mark, _simpleeqnsarr, _minmaxset);

  tmpMeta7 = mmc_mk_box4(0, mmc_mk_boolean(_fixedset), _startvalues, _nominalset, _minmaxset);
  _oAttributes = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  return _oAttributes;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addVarSetAttributes(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _negate, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iAttributes)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _oAttributes = NULL;
  tmp1 = mmc_unbox_integer(_negate);
  tmp2 = mmc_unbox_integer(_mark);
  _oAttributes = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _inVar, tmp1, tmp2, _simpleeqnsarr, _iAttributes);
  /* skip box _oAttributes; tuple<#Boolean, tuple<#Integer, list<tuple<Option<DAE.Exp>, DAE.ComponentRef>>>, list<tuple<DAE.Exp, DAE.ComponentRef>>, tuple<Option<DAE.Exp>, Option<DAE.Exp>>> */
  return _oAttributes;
}

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

    _source = omc_ElementSource_addSymbolicTransformationSubstitution(threadData, 1 /* true */, _source, _exp, _e);
  }
  _return: OMC_LABEL_UNUSED
  return _source;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_negateOptExp(threadData_t *threadData, modelica_metatype _iExp)
{
  modelica_metatype _oExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oExp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iExp;
    {
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          _e = tmpMeta6;
          /* Pattern matching succeeded */
          _e = omc_RemoveSimpleEquations_negateExpression(threadData, 1 /* true */, _e, _e, _OMC_LIT95);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iExp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseAliasTree1(threadData_t *threadData, modelica_metatype _sc, modelica_integer _r, modelica_integer _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_boolean _globalnegated, modelica_metatype _derReplaceState, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oEqnslst = NULL;
  modelica_metatype _oshared = NULL;
  modelica_metatype _oRepl = NULL;
  modelica_metatype _oAttributes = NULL;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oEqnslst has no default value.
  // _oshared has no default value.
  // _oRepl has no default value.
  // _oAttributes has no default value.
  
  
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _sc;
    {
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_integer _i;
      modelica_metatype _rows = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_boolean _replaceable_;
      modelica_boolean _globalnegated1;
      modelica_boolean _replaceble1;
      modelica_boolean _negatedCr1;
      modelica_boolean _negatedCr2;
      modelica_boolean _negated;
      modelica_metatype _source = NULL;
      modelica_metatype _crexp = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _derReplacement = NULL;
      modelica_string _lhs = NULL;
      modelica_string _rhs = NULL;
      modelica_metatype _vsattr = NULL;
      modelica_metatype _eqAttr = NULL;
      int tmp4;
      // _i1 has no default value.
      // _i2 has no default value.
      // _i has no default value.
      // _rows has no default value.
      // _v has no default value.
      // _vars has no default value.
      // _eqnslst has no default value.
      // _shared has no default value.
      // _repl has no default value.
      // _cr has no default value.
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _replaceable_ has no default value.
      // _globalnegated1 has no default value.
      // _replaceble1 has no default value.
      // _negatedCr1 has no default value.
      // _negatedCr2 has no default value.
      // _negated has no default value.
      // _source has no default value.
      // _crexp has no default value.
      // _exp1 has no default value.
      // _derReplacement has no default value.
      // _lhs has no default value.
      // _rhs has no default value.
      // _vsattr has no default value.
      // _eqAttr has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_integer tmp6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp6 = mmc_unbox_integer(tmpMeta5);
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 1));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta13), 2));
          
          _negatedCr1 = tmp6  /* pattern as ty=Boolean */;
          _i1 = tmp8  /* pattern as ty=Integer */;
          _negatedCr2 = tmp10  /* pattern as ty=Boolean */;
          _i2 = tmp12  /* pattern as ty=Integer */;
          _source = tmpMeta14;
          _eqAttr = tmpMeta15;
          /* Pattern matching succeeded */
          _i = ((_i1 == _ilast)?_i2:_i1);

          _negated = (_negatedCr2 || _negatedCr1);

          /* Pattern-matching assignment */
          tmpMeta16 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          _v = tmpMeta16;
          _cr = tmpMeta17;

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _crexp = omc_Expression_crefExp(threadData, _cr);

          _globalnegated1 = (_negated?(!_globalnegated):_globalnegated);

          _exp1 = omc_RemoveSimpleEquations_negateExpression(threadData, _globalnegated1, _exp, _exp, _OMC_LIT96);

          _derReplacement = (_globalnegated1?omc_RemoveSimpleEquations_negateOptExp(threadData, _derReplaceState):_derReplaceState);

          _source = (_replaceable_?omc_RemoveSimpleEquations_addSubstitutionOption(threadData, _optExp, _crexp, _source):_source);

          tmpMeta18 = mmc_mk_box2(0, _source, _eqAttr);
          _vars = omc_RemoveSimpleEquations_handleSetVar(threadData, (_replaceable_ && _replaceble1), _derReplacement, _v, _i, tmpMeta18, _exp1, _iMT, _iVars, _iEqnslst, _ishared, _iRepl ,&_eqnslst ,&_shared ,&_repl);

          _vsattr = ((_replaceable_ && _replaceble1)?omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, _globalnegated1, _mark, _simpleeqnsarr, _iAttributes):_iAttributes);

          _crexp = omc_RemoveSimpleEquations_negateExpression(threadData, _negated, _crexp, _crexp, _OMC_LIT97);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i) /* DAE.ASUB */);

          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta19);
          tmpMeta[0+0] = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, _i, _exp, mmc_mk_some(_crexp), _globalnegated1, _derReplaceState, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl, _vsattr, &tmpMeta[0+1], &tmpMeta[0+2], &tmpMeta[0+3], &tmpMeta[0+4]);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,8) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          
          _cr1 = tmpMeta20;
          _negatedCr1 = tmp22  /* pattern as ty=Boolean */;
          _i1 = tmp24  /* pattern as ty=Integer */;
          _cr2 = tmpMeta25;
          _negatedCr2 = tmp27  /* pattern as ty=Boolean */;
          _source = tmpMeta29;
          /* Pattern matching succeeded */
          _cr = ((_i1 == _ilast)?_cr2:_cr1);

          _negated = (_negatedCr1 || _negatedCr2);

          _crexp = omc_Expression_crefExp(threadData, _cr);

          _crexp = omc_RemoveSimpleEquations_negateExpression(threadData, _negated, _crexp, _crexp, _OMC_LIT98);

          _lhs = omc_ExpressionBasics_printExpStr(threadData, _exp);

          _rhs = omc_ExpressionBasics_printExpStr(threadData, _crexp);

          tmpMeta30 = mmc_mk_cons(_lhs, mmc_mk_cons(_rhs, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addSourceMessage(threadData, _OMC_LIT100, tmpMeta30, omc_ElementSource_getElementSourceFileInfo(threadData, _source));
          goto goto_2;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta31), 1));
          
          _source = tmpMeta32;
          /* Pattern matching succeeded */
          _rhs = omc_ExpressionBasics_printExpStr(threadData, _exp);

          tmpMeta33 = mmc_mk_cons(_OMC_LIT35, mmc_mk_cons(_rhs, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addSourceMessage(threadData, _OMC_LIT100, tmpMeta33, omc_ElementSource_getElementSourceFileInfo(threadData, _source));
          goto goto_2;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 1));
          
          _exp1 = tmpMeta34;
          _source = tmpMeta36;
          /* Pattern matching succeeded */
          _lhs = omc_ExpressionBasics_printExpStr(threadData, _exp);

          _rhs = omc_ExpressionBasics_printExpStr(threadData, _exp1);

          tmpMeta37 = mmc_mk_cons(_lhs, mmc_mk_cons(_rhs, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addSourceMessage(threadData, _OMC_LIT100, tmpMeta37, omc_ElementSource_getElementSourceFileInfo(threadData, _source));
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oEqnslst = tmpMeta[0+1];
  _oshared = tmpMeta[0+2];
  _oRepl = tmpMeta[0+3];
  _oAttributes = tmpMeta[0+4];
  _return: OMC_LABEL_UNUSED
  if (out_oEqnslst) { *out_oEqnslst = _oEqnslst; }
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_oRepl) { *out_oRepl = _oRepl; }
  if (out_oAttributes) { *out_oAttributes = _oAttributes; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traverseAliasTree1(threadData_t *threadData, modelica_metatype _sc, modelica_metatype _r, modelica_metatype _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_metatype _globalnegated, modelica_metatype _derReplaceState, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_r);
  tmp2 = mmc_unbox_integer(_ilast);
  tmp3 = mmc_unbox_integer(_globalnegated);
  tmp4 = mmc_unbox_integer(_mark);
  _oVars = omc_RemoveSimpleEquations_traverseAliasTree1(threadData, _sc, tmp1, tmp2, _exp, _optExp, tmp3, _derReplaceState, tmp4, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _iAttributes, out_oEqnslst, out_oshared, out_oRepl, out_oAttributes);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oEqnslst; list<BackendDAE.Equation> */
  /* skip box _oshared; BackendDAE.Shared */
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  /* skip box _oAttributes; tuple<#Boolean, tuple<#Integer, list<tuple<Option<DAE.Exp>, DAE.ComponentRef>>>, list<tuple<DAE.Exp, DAE.ComponentRef>>, tuple<Option<DAE.Exp>, Option<DAE.Exp>>> */
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseAliasTree(threadData_t *threadData, modelica_metatype _rows, modelica_integer _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_boolean _globalnegate, modelica_metatype _derReplaceState, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oEqnslst = NULL;
  modelica_metatype _oshared = NULL;
  modelica_metatype _oRepl = NULL;
  modelica_metatype _oAttributes = NULL;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oEqnslst has no default value.
  // _oshared has no default value.
  // _oRepl has no default value.
  // _oAttributes has no default value.
  
  
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _rows;
    {
      modelica_integer _r;
      modelica_metatype _rest = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _s = NULL;
      modelica_metatype _vsattr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _r has no default value.
      // _rest has no default value.
      // _vars has no default value.
      // _eqnslst has no default value.
      // _shared has no default value.
      // _repl has no default value.
      // _s has no default value.
      // _vsattr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _iEqnslst;
          tmpMeta[0+2] = _ishared;
          tmpMeta[0+3] = _iRepl;
          tmpMeta[0+4] = _iAttributes;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmp8 = mmc_unbox_integer(tmpMeta6);
          _r = tmp8  /* pattern as ty=Integer */;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _s = arrayGet(_simpleeqnsarr,_r) /* DAE.ASUB */;

          arrayUpdate(_simpleeqnsarr, _r, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _s));

          _vars = omc_RemoveSimpleEquations_traverseAliasTree1(threadData, _s, _r, _ilast, _exp, _optExp, _globalnegate, _derReplaceState, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _iAttributes ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);
          /* Tail recursive call */
          _rows = _rest;
          _iVars = _vars;
          _iEqnslst = _eqnslst;
          _ishared = _shared;
          _iRepl = _repl;
          _iAttributes = _vsattr;
          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:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oEqnslst = tmpMeta[0+1];
  _oshared = tmpMeta[0+2];
  _oRepl = tmpMeta[0+3];
  _oAttributes = tmpMeta[0+4];
  _return: OMC_LABEL_UNUSED
  if (out_oEqnslst) { *out_oEqnslst = _oEqnslst; }
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_oRepl) { *out_oRepl = _oRepl; }
  if (out_oAttributes) { *out_oAttributes = _oAttributes; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traverseAliasTree(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _ilast, modelica_metatype _exp, modelica_metatype _optExp, modelica_metatype _globalnegate, modelica_metatype _derReplaceState, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iAttributes, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_oAttributes)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_ilast);
  tmp2 = mmc_unbox_integer(_globalnegate);
  tmp3 = mmc_unbox_integer(_mark);
  _oVars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, tmp1, _exp, _optExp, tmp2, _derReplaceState, tmp3, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _iAttributes, out_oEqnslst, out_oshared, out_oRepl, out_oAttributes);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oEqnslst; list<BackendDAE.Equation> */
  /* skip box _oshared; BackendDAE.Shared */
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  /* skip box _oAttributes; tuple<#Boolean, tuple<#Integer, list<tuple<Option<DAE.Exp>, DAE.ComponentRef>>>, list<tuple<DAE.Exp, DAE.ComponentRef>>, tuple<Option<DAE.Exp>, Option<DAE.Exp>>> */
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_moveVarShared(threadData_t *threadData, modelica_metatype _v, modelica_integer _i, modelica_metatype _source, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype *out_oshared, modelica_boolean *out_bs)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oshared = NULL;
  modelica_boolean _bs;
  modelica_metatype _cr = NULL;
  modelica_metatype _ops = NULL;
  modelica_metatype _v1 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oshared has no default value.
  // _bs has no default value.
  // _cr has no default value.
  // _ops has no default value.
  // _v1 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _v;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _cr = tmpMeta2;

  _v1 = omc_BackendVariable_setBindExp(threadData, _v, mmc_mk_some(_exp));

  _ops = omc_ElementSource_getSymbolicTransformations(threadData, _source);

  tmpMeta4 = mmc_mk_box3(10, &DAE_SymbolicOperation_SOLVED__desc, _cr, _exp);
  tmpMeta3 = mmc_mk_cons(tmpMeta4, _ops);
  _v1 = omc_BackendVariable_mergeVariableOperations(threadData, _v1, tmpMeta3);

  _bs = omc_BackendVariable_isStateVar(threadData, _v);

  _v1 = (_bs?omc_BackendVariable_setVarKind(threadData, _v1, _OMC_LIT43):_v1);

  _oVars = omc_BackendVariable_removeVar(threadData, _i, _iVars, NULL);

  _oshared = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), _v1, _ishared) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, _v1, _ishared);
  _return: OMC_LABEL_UNUSED
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_bs) { *out_bs = _bs; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_moveVarShared(threadData_t *threadData, modelica_metatype _v, modelica_metatype _i, modelica_metatype _source, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype *out_oshared, modelica_metatype *out_bs)
{
  modelica_integer tmp1;
  modelica_boolean _bs;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_i);
  _oVars = omc_RemoveSimpleEquations_moveVarShared(threadData, _v, tmp1, _source, _exp, _func, _iVars, _ishared, out_oshared, &_bs);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oshared; BackendDAE.Shared */
  if (out_bs) { *out_bs = mmc_mk_icon(_bs); }
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_optMoveVarShared(threadData_t *threadData, modelica_boolean _replaceable_, modelica_metatype _v, modelica_integer _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iEqnslst, modelica_metatype *out_oshared, modelica_boolean *out_bs, modelica_metatype *out_oEqnslst)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oshared = NULL;
  modelica_boolean _bs;
  modelica_metatype _oEqnslst = NULL;
  modelica_boolean tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oshared has no default value.
  // _bs has no default value.
  // _oEqnslst has no default value.
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _replaceable_;
    tmp4_2 = _v;
    tmp4_3 = _eqnAttributes;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _crexp = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _crexp has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          
          _source = tmpMeta6;
          /* Pattern matching succeeded */
          _oVars = omc_RemoveSimpleEquations_moveVarShared(threadData, _v, _i, _source, _exp, ((modelica_fnptr) _func), _iVars, _ishared ,&_oshared ,&_bs);
          tmpMeta[0+0] = _oVars;
          tmpMeta[0+1] = _oshared;
          tmp1_c2 = _bs;
          tmpMeta[0+3] = _iEqnslst;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _cr = tmpMeta7;
          /* Pattern matching succeeded */
          _crexp = omc_Expression_crefExp(threadData, _cr);

          /* Pattern-matching assignment */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = mmc_mk_box7(0, _iVars, _ishared, _iEqnslst, tmpMeta8, mmc_mk_integer(((modelica_integer) -1)), _iMT, mmc_mk_boolean(0 /* false */));
          tmpMeta10 = omc_RemoveSimpleEquations_generateEquation(threadData, _crexp, _exp, omc_Expression_typeof(threadData, _exp), _eqnAttributes, tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 3));
          _oVars = tmpMeta11;
          _oshared = tmpMeta12;
          _oEqnslst = tmpMeta13;
          tmpMeta[0+0] = _oVars;
          tmpMeta[0+1] = _oshared;
          tmp1_c2 = 0 /* false */;
          tmpMeta[0+3] = _oEqnslst;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oshared = tmpMeta[0+1];
  _bs = tmp1_c2;
  _oEqnslst = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_bs) { *out_bs = _bs; }
  if (out_oEqnslst) { *out_oEqnslst = _oEqnslst; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_optMoveVarShared(threadData_t *threadData, modelica_metatype _replaceable_, modelica_metatype _v, modelica_metatype _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_fnptr _func, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_bs, modelica_metatype *out_oEqnslst)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_boolean _bs;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_replaceable_);
  tmp2 = mmc_unbox_integer(_i);
  _oVars = omc_RemoveSimpleEquations_optMoveVarShared(threadData, tmp1, _v, tmp2, _eqnAttributes, _exp, _func, _iMT, _iVars, _ishared, _iEqnslst, out_oshared, &_bs, out_oEqnslst);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oshared; BackendDAE.Shared */
  if (out_bs) { *out_bs = mmc_mk_icon(_bs); }
  /* skip box _oEqnslst; list<BackendDAE.Equation> */
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addDerConstRepl(threadData_t *threadData, modelica_boolean _state, modelica_metatype _derConstRepl, modelica_metatype _cr, modelica_metatype _iRepl)
{
  modelica_metatype _oRepl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oRepl has no default value.
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _state;
    tmp4_2 = _derConstRepl;
    {
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          _e = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _e, _iRepl);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _iRepl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oRepl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oRepl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addDerConstRepl(threadData_t *threadData, modelica_metatype _state, modelica_metatype _derConstRepl, modelica_metatype _cr, modelica_metatype _iRepl)
{
  modelica_integer tmp1;
  modelica_metatype _oRepl = NULL;
  tmp1 = mmc_unbox_integer(_state);
  _oRepl = omc_RemoveSimpleEquations_addDerConstRepl(threadData, tmp1, _derConstRepl, _cr, _iRepl);
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  return _oRepl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSetVar(threadData_t *threadData, modelica_boolean _replaceable_, modelica_metatype _derReplaceState, modelica_metatype _v, modelica_integer _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oEqnslst = NULL;
  modelica_metatype _oshared = NULL;
  modelica_metatype _oRepl = NULL;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oEqnslst has no default value.
  // _oshared has no default value.
  // _oRepl has no default value.
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _replaceable_;
    tmp4_2 = _v;
    tmp4_3 = _eqnAttributes;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _crexp = NULL;
      modelica_metatype _vars = NULL;
      modelica_boolean _bs;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _crexp has no default value.
      // _vars has no default value.
      // _bs has no default value.
      // _eqnslst has no default value.
      // _shared has no default value.
      // _repl has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          
          _cr = tmpMeta6;
          _source = tmpMeta7;
          /* Pattern matching succeeded */
          _vars = omc_RemoveSimpleEquations_moveVarShared(threadData, _v, _i, _source, _exp, boxvar_BackendVariable_addAliasVarDAE, _iVars, _ishared ,&_shared ,&_bs);

          _repl = omc_BackendVarTransform_addReplacement(threadData, _iRepl, _cr, _exp, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator));

          _repl = omc_RemoveSimpleEquations_addDerConstRepl(threadData, _bs, _derReplaceState, _cr, _repl);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _iEqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _cr = tmpMeta8;
          /* Pattern matching succeeded */
          _crexp = omc_Expression_crefExp(threadData, _cr);

          /* Pattern-matching assignment */
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta10 = mmc_mk_box7(0, _iVars, _ishared, _iEqnslst, tmpMeta9, mmc_mk_integer(((modelica_integer) -1)), _iMT, mmc_mk_boolean(0 /* false */));
          tmpMeta11 = omc_RemoveSimpleEquations_generateEquation(threadData, _crexp, _exp, omc_Expression_typeof(threadData, _exp), _eqnAttributes, tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 1));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 3));
          _vars = tmpMeta12;
          _shared = tmpMeta13;
          _eqnslst = tmpMeta14;
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _iRepl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oEqnslst = tmpMeta[0+1];
  _oshared = tmpMeta[0+2];
  _oRepl = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_oEqnslst) { *out_oEqnslst = _oEqnslst; }
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_oRepl) { *out_oRepl = _oRepl; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSetVar(threadData_t *threadData, modelica_metatype _replaceable_, modelica_metatype _derReplaceState, modelica_metatype _v, modelica_metatype _i, modelica_metatype _eqnAttributes, modelica_metatype _exp, modelica_metatype _iMT, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_replaceable_);
  tmp2 = mmc_unbox_integer(_i);
  _oVars = omc_RemoveSimpleEquations_handleSetVar(threadData, tmp1, _derReplaceState, _v, tmp2, _eqnAttributes, _exp, _iMT, _iVars, _iEqnslst, _ishared, _iRepl, out_oEqnslst, out_oshared, out_oRepl);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oEqnslst; list<BackendDAE.Equation> */
  /* skip box _oshared; BackendDAE.Shared */
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_varStateDerivative(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_metatype _outExp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inVar;
    {
      modelica_metatype _dcr = NULL;
      modelica_metatype _e = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _dcr has no default value.
      // _e has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,3) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          
          _dcr = tmpMeta8;
          /* Pattern matching succeeded */
          _e = omc_Expression_crefExp(threadData, _dcr);
          tmpMeta1 = mmc_mk_some(_e);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = mmc_mk_none();
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outExp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSet(threadData_t *threadData, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oEqnslst = NULL;
  modelica_metatype _oshared = NULL;
  modelica_metatype _oRepl = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oEqnslst has no default value.
  // _oshared has no default value.
  // _oRepl has no default value.
  _warnAliasConflicts = 0 /* false */;
  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;volatile modelica_metatype tmp4_4;
    tmp4_1 = _iRmax;
    tmp4_2 = _iSmax;
    tmp4_3 = _iUnremovable;
    tmp4_4 = _iConst;
    {
      modelica_metatype _s = NULL;
      modelica_integer _r;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_integer _i;
      modelica_metatype _v = NULL;
      modelica_metatype _pv = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _eqnAttributes = NULL;
      modelica_boolean _negated;
      modelica_boolean _replaceable_;
      modelica_boolean _replaceble1;
      modelica_boolean _constExp;
      modelica_boolean _isState;
      modelica_boolean _negatedCr1;
      modelica_boolean _negatedCr2;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _expcr = NULL;
      modelica_metatype _dexp = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _repl = NULL;
      modelica_metatype _vsattr = NULL;
      modelica_metatype _rows = NULL;
      modelica_metatype _oexp = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _s has no default value.
      // _r has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _i has no default value.
      // _v has no default value.
      // _pv has no default value.
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _cr has no default value.
      // _eqnAttributes has no default value.
      // _negated has no default value.
      // _replaceable_ has no default value.
      // _replaceble1 has no default value.
      // _constExp has no default value.
      // _isState has no default value.
      // _negatedCr1 has no default value.
      // _negatedCr2 has no default value.
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _expcr has no default value.
      // _dexp has no default value.
      // _exp has no default value.
      // _vars has no default value.
      // _eqnslst has no default value.
      // _shared has no default value.
      // _repl has no default value.
      // _vsattr has no default value.
      // _rows has no default value.
      // _oexp 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_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (optionNone(tmp4_4)) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          
          _r = tmp7  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _s = arrayGet(_simpleeqnsarr,_r) /* DAE.ASUB */;

          /* Pattern-matching assignment */
          tmpMeta8 = _s;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,1,8) == 0) goto goto_2;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 5));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 6));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 7));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 8));
          _cr1 = tmpMeta9;
          _negatedCr1 = tmp11  /* pattern as ty=Boolean */;
          _i1 = tmp13  /* pattern as ty=Integer */;
          _cr2 = tmpMeta14;
          _negatedCr2 = tmp16  /* pattern as ty=Boolean */;
          _i2 = tmp18  /* pattern as ty=Integer */;
          _eqnAttributes = tmpMeta19;

          arrayUpdate(_simpleeqnsarr, _r, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _s));

          _negated = (_negatedCr1 || _negatedCr2);

          _exp = omc_Expression_crefExp(threadData, _cr2);

          _exp2 = omc_RemoveSimpleEquations_negateExpression(threadData, _negated, _exp, _exp, _OMC_LIT101);

          _v = omc_BackendVariable_getVarAt(threadData, _iVars, _i1);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _vars = omc_RemoveSimpleEquations_handleSetVar(threadData, (_replaceable_ && _replaceble1), _OMC_LIT102, _v, _i1, _eqnAttributes, _exp2, _iMT, _iVars, _iEqnslst, _ishared, _iRepl ,&_eqnslst ,&_shared ,&_repl);

          _expcr = omc_Expression_crefExp(threadData, _cr1);

          _pv = omc_BackendVariable_getVarSharedAt(threadData, _i2, _ishared);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _pv, _negated, _mark, _simpleeqnsarr, _OMC_LIT105);

          _vsattr = ((_replaceable_ && _replaceble1)?omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, _negated, _mark, _simpleeqnsarr, _vsattr):_vsattr);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i1) /* DAE.ASUB */);

          tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i1, tmpMeta20);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, _i1, _exp, mmc_mk_some(_expcr), _negated, _OMC_LIT102, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta21;
          modelica_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_integer tmp28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          if (optionNone(tmp4_4)) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          
          _r = tmp22  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _s = arrayGet(_simpleeqnsarr,_r) /* DAE.ASUB */;

          /* Pattern-matching assignment */
          tmpMeta23 = _s;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,2,8) == 0) goto goto_2;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 3));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 4));
          tmp28 = mmc_unbox_integer(tmpMeta27);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 6));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 8));
          _cr1 = tmpMeta24;
          _negatedCr1 = tmp26  /* pattern as ty=Boolean */;
          _i1 = tmp28  /* pattern as ty=Integer */;
          _negatedCr2 = tmp30  /* pattern as ty=Boolean */;
          _eqnAttributes = tmpMeta31;

          arrayUpdate(_simpleeqnsarr, _r, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _s));

          _negated = (_negatedCr1 || _negatedCr2);

          _exp = omc_Expression_crefExp(threadData, _OMC_LIT37);

          _exp1 = omc_RemoveSimpleEquations_negateExpression(threadData, _negated, _exp, _exp, _OMC_LIT106);

          _v = omc_BackendVariable_getVarAt(threadData, _iVars, _i1);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _dexp = omc_RemoveSimpleEquations_negateExpression(threadData, _negated, _exp, _OMC_LIT108, _OMC_LIT109);

          _vars = omc_RemoveSimpleEquations_handleSetVar(threadData, (_replaceable_ && _replaceble1), mmc_mk_some(_dexp), _v, _i1, _eqnAttributes, _exp1, _iMT, _iVars, _iEqnslst, _ishared, _iRepl ,&_eqnslst ,&_shared ,&_repl);

          _expcr = omc_Expression_crefExp(threadData, _cr1);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, _negated, _mark, _simpleeqnsarr, _OMC_LIT105);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i1) /* DAE.ASUB */);

          tmpMeta32 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i1, tmpMeta32);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, _i1, _exp, mmc_mk_some(_expcr), _negated, mmc_mk_some(_dexp), _mark, _simpleeqnsarr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta33;
          modelica_integer tmp34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_integer tmp38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          if (optionNone(tmp4_4)) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp34 = mmc_unbox_integer(tmpMeta33);
          
          _r = tmp34  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _s = arrayGet(_simpleeqnsarr,_r) /* DAE.ASUB */;

          /* Pattern-matching assignment */
          tmpMeta35 = _s;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,3,5) == 0) goto goto_2;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 3));
          tmp38 = mmc_unbox_integer(tmpMeta37);
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 4));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 5));
          _cr = tmpMeta36;
          _i = tmp38  /* pattern as ty=Integer */;
          _exp = tmpMeta39;
          _eqnAttributes = tmpMeta40;

          arrayUpdate(_simpleeqnsarr, _r, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _s));

          /* Pattern-matching assignment */
          tmpMeta41 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 2));
          _v = tmpMeta41;
          _cr = tmpMeta42;

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _vars = omc_RemoveSimpleEquations_optMoveVarShared(threadData, _replaceable_, _v, _i, _eqnAttributes, _exp, boxvar_BackendVariable_addGlobalKnownVarDAE, _iMT, _iVars, _ishared, _iEqnslst ,&_shared ,&_isState ,&_eqnslst);

          _constExp = omc_Expression_isConstValue(threadData, _exp);

          _repl = (((_replaceable_ && _constExp) && _replaceble1)?omc_BackendVarTransform_addReplacement(threadData, _iRepl, _cr, _exp, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator)):_iRepl);

          _repl = (_isState?omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _OMC_LIT19, _repl):_repl);

          _exp = omc_Expression_crefExp(threadData, _cr);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, 0 /* false */, _mark, _simpleeqnsarr, _OMC_LIT105);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i) /* DAE.ASUB */);

          tmpMeta43 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta43);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, _i, _exp, mmc_mk_none(), 0 /* false */, _OMC_LIT102, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta44;
          modelica_integer tmp45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_integer tmp48;
          modelica_metatype tmpMeta49;
          modelica_integer tmp50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (optionNone(tmp4_4)) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmp45 = mmc_unbox_integer(tmpMeta44);
          
          _r = tmp45  /* pattern as ty=Integer */;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _s = arrayGet(_simpleeqnsarr,_r) /* DAE.ASUB */;

          /* Pattern-matching assignment */
          tmpMeta46 = _s;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,0,8) == 0) goto goto_2;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 4));
          tmp48 = mmc_unbox_integer(tmpMeta47);
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 7));
          tmp50 = mmc_unbox_integer(tmpMeta49);
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta46), 8));
          _i = tmp48  /* pattern as ty=Integer */;
          _i2 = tmp50  /* pattern as ty=Integer */;
          _eqnAttributes = tmpMeta51;

          arrayUpdate(_simpleeqnsarr, _r, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _s));

          /* Pattern-matching assignment */
          tmpMeta52 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          _v = tmpMeta52;
          _cr = tmpMeta53;

          _exp = (omc_Types_isRealOrSubTypeReal(threadData, omc_ComponentReference_crefLastType(threadData, _cr))?_OMC_LIT19:_OMC_LIT11);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _vars = omc_RemoveSimpleEquations_optMoveVarShared(threadData, _replaceable_, _v, _i, _eqnAttributes, _exp, boxvar_BackendVariable_addGlobalKnownVarDAE, _iMT, _iVars, _ishared, _iEqnslst ,&_shared ,&_isState ,&_eqnslst);

          _constExp = omc_Expression_isConstValue(threadData, _exp);

          _repl = (((_replaceable_ && _constExp) && _replaceble1)?omc_BackendVarTransform_addReplacement(threadData, _iRepl, _cr, _exp, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator)):_iRepl);

          _repl = (_isState?omc_BackendVarTransform_addDerConstRepl(threadData, _cr, _OMC_LIT19, _repl):_repl);

          _exp = omc_Expression_crefExp(threadData, _cr);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, 0 /* false */, _mark, _simpleeqnsarr, _OMC_LIT105);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i2) /* DAE.ASUB */);

          arrayUpdate(_iMT, _i2, _rows);

          _rows = omc_List_removeOnTrue(threadData, mmc_mk_integer(_r), boxvar_intEq, arrayGet(_iMT,_i) /* DAE.ASUB */);

          tmpMeta54 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta54);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, _rows, _i, _exp, mmc_mk_none(), 0 /* false */, _OMC_LIT102, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_integer tmp57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta55), 1));
          tmp57 = mmc_unbox_integer(tmpMeta56);
          if (!optionNone(tmp4_4)) goto tmp3_end;
          
          _i = tmp57  /* pattern as ty=Integer */;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching assignment */
          tmpMeta58 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          _v = tmpMeta58;
          _cr = tmpMeta59;

          _exp = omc_Expression_crefExp(threadData, _cr);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, 0 /* false */, _mark, _simpleeqnsarr, _OMC_LIT105);

          _oexp = omc_RemoveSimpleEquations_varStateDerivative(threadData, _v);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, arrayGet(_iMT,_i) /* DAE.ASUB */, _i, _exp, mmc_mk_none(), 0 /* false */, _oexp, _mark, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);

          tmpMeta60 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta60);

          _vars = omc_RemoveSimpleEquations_handleVarSetAttributes(threadData, _vsattr, _v, _vars, _shared ,&_warnAliasConflicts);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta61;
          modelica_integer tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          if (!optionNone(tmp4_2)) goto tmp3_end;
          if (optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmp62 = mmc_unbox_integer(tmpMeta61);
          if (!optionNone(tmp4_4)) goto tmp3_end;
          
          _i = tmp62  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta63 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta63), 2));
          _v = tmpMeta63;
          _cr = tmpMeta64;

          _exp = omc_Expression_crefExp(threadData, _cr);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, 0 /* false */, _mark, _simpleeqnsarr, _OMC_LIT105);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, arrayGet(_iMT,_i) /* DAE.ASUB */, _i, _exp, mmc_mk_none(), 0 /* false */, mmc_mk_none(), _mark, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);

          tmpMeta65 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta65);

          _vars = omc_RemoveSimpleEquations_handleVarSetAttributes(threadData, _vsattr, _v, _vars, _shared ,&_warnAliasConflicts);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_integer tmp68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          if (optionNone(tmp4_1)) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta66), 1));
          tmp68 = mmc_unbox_integer(tmpMeta67);
          if (!optionNone(tmp4_2)) goto tmp3_end;
          if (!optionNone(tmp4_4)) goto tmp3_end;
          
          _i = tmp68  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta69 = omc_BackendVariable_getVarAt(threadData, _iVars, _i);
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 2));
          _v = tmpMeta69;
          _cr = tmpMeta70;

          _exp = omc_Expression_crefExp(threadData, _cr);

          _vsattr = omc_RemoveSimpleEquations_addVarSetAttributes(threadData, _v, 0 /* false */, _mark, _simpleeqnsarr, _OMC_LIT105);

          _vars = omc_RemoveSimpleEquations_traverseAliasTree(threadData, arrayGet(_iMT,_i) /* DAE.ASUB */, _i, _exp, mmc_mk_none(), 0 /* false */, mmc_mk_none(), _mark, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, _vsattr ,&_eqnslst ,&_shared ,&_repl ,&_vsattr);

          tmpMeta71 = MMC_REFSTRUCTLIT(mmc_nil);
          arrayUpdate(_iMT, _i, tmpMeta71);

          _vars = omc_RemoveSimpleEquations_handleVarSetAttributes(threadData, _vsattr, _v, _vars, _shared ,&_warnAliasConflicts);
          tmpMeta[0+0] = _vars;
          tmpMeta[0+1] = _eqnslst;
          tmpMeta[0+2] = _shared;
          tmpMeta[0+3] = _repl;
          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:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oEqnslst = tmpMeta[0+1];
  _oshared = tmpMeta[0+2];
  _oRepl = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_oEqnslst) { *out_oEqnslst = _oEqnslst; }
  if (out_oshared) { *out_oshared = _oshared; }
  if (out_oRepl) { *out_oRepl = _oRepl; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSet(threadData_t *threadData, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype _iVars, modelica_metatype _iEqnslst, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype *out_oEqnslst, modelica_metatype *out_oshared, modelica_metatype *out_oRepl, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _oVars = NULL;
  tmp1 = mmc_unbox_integer(_mark);
  _oVars = omc_RemoveSimpleEquations_handleSet(threadData, _iRmax, _iSmax, _iUnremovable, _iConst, tmp1, _simpleeqnsarr, _iMT, _unReplaceable, _iVars, _iEqnslst, _ishared, _iRepl, out_oEqnslst, out_oshared, out_oRepl, &_warnAliasConflicts);
  /* skip box _oVars; BackendDAE.Variables */
  /* skip box _oEqnslst; list<BackendDAE.Equation> */
  /* skip box _oshared; BackendDAE.Shared */
  /* skip box _oRepl; BackendVarTransform.VariableReplacements */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_replaceableAlias(threadData_t *threadData, modelica_metatype _var, modelica_metatype _unReplaceable, modelica_boolean *out_res1)
{
  modelica_boolean _res;
  modelica_boolean _res1;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _res has no default value.
  // _res1 has no default value.
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _var;
    {
      modelica_metatype _kind = NULL;
      modelica_metatype _cr = NULL;
      modelica_boolean _b;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _kind has no default value.
      // _cr has no default value.
      // _b has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_boolean tmp8;
          modelica_boolean tmp9;
          modelica_boolean tmp10;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          
          _cr = tmpMeta6;
          _kind = tmpMeta7;
          /* Pattern matching succeeded */
          omc_BackendVariable_isVarKindVariable(threadData, _kind);

          /* Pattern-matching assignment */
          tmp8 = omc_BackendVariable_isVarOnTopLevelAndOutput(threadData, _var);
          if (0 /* false */ != tmp8) goto goto_2;

          /* Pattern-matching assignment */
          tmp9 = omc_BackendVariable_isVarOnTopLevelAndInput(threadData, _var);
          if (0 /* false */ != tmp9) goto goto_2;

          /* Pattern-matching assignment */
          tmp10 = omc_BackendVariable_varHasUncertainValueRefine(threadData, _var);
          if (0 /* false */ != tmp10) goto goto_2;

          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);

          _b = (!omc_BaseHashSet_has(threadData, _cr, _unReplaceable));
          tmp1_c0 = 1 /* true */;
          tmp1_c1 = _b;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = 0 /* false */;
          tmp1_c1 = 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 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _res = tmp1_c0;
  _res1 = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_res1) { *out_res1 = _res1; }
  return _res;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_replaceableAlias(threadData_t *threadData, modelica_metatype _var, modelica_metatype _unReplaceable, modelica_metatype *out_res1)
{
  modelica_boolean _res1;
  modelica_boolean _res;
  modelica_metatype out_res;
  _res = omc_RemoveSimpleEquations_replaceableAlias(threadData, _var, _unReplaceable, &_res1);
  out_res = mmc_mk_icon(_res);
  if (out_res1) { *out_res1 = mmc_mk_icon(_res1); }
  return out_res;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_setVisited(threadData_t *threadData, modelica_integer _visited, modelica_metatype _iS)
{
  modelica_metatype _oS = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oS has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iS;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_metatype _eqnAttributes = NULL;
      modelica_boolean _negatedCr1;
      modelica_boolean _negatedCr2;
      modelica_metatype _exp = NULL;
      int tmp4;
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _eqnAttributes has no default value.
      // _negatedCr1 has no default value.
      // _negatedCr2 has no default value.
      // _exp has no default value.
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _cr1 = tmpMeta5;
          _negatedCr1 = tmp7  /* pattern as ty=Boolean */;
          _i1 = tmp9  /* pattern as ty=Integer */;
          _cr2 = tmpMeta10;
          _negatedCr2 = tmp12  /* pattern as ty=Boolean */;
          _i2 = tmp14  /* pattern as ty=Integer */;
          _eqnAttributes = tmpMeta15;
          /* Pattern matching succeeded */
          tmpMeta16 = mmc_mk_box9(3, &RemoveSimpleEquations_SimpleContainer_ALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(_visited));
          tmpMeta1 = tmpMeta16;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,8) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp26 = mmc_unbox_integer(tmpMeta25);
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _cr1 = tmpMeta17;
          _negatedCr1 = tmp19  /* pattern as ty=Boolean */;
          _i1 = tmp21  /* pattern as ty=Integer */;
          _cr2 = tmpMeta22;
          _negatedCr2 = tmp24  /* pattern as ty=Boolean */;
          _i2 = tmp26  /* pattern as ty=Integer */;
          _eqnAttributes = tmpMeta27;
          /* Pattern matching succeeded */
          tmpMeta28 = mmc_mk_box9(4, &RemoveSimpleEquations_SimpleContainer_PARAMETERALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(_visited));
          tmpMeta1 = tmpMeta28;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          modelica_integer tmp33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_integer tmp36;
          modelica_metatype tmpMeta37;
          modelica_integer tmp38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp31 = mmc_unbox_integer(tmpMeta30);
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp33 = mmc_unbox_integer(tmpMeta32);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp36 = mmc_unbox_integer(tmpMeta35);
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp38 = mmc_unbox_integer(tmpMeta37);
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          
          _cr1 = tmpMeta29;
          _negatedCr1 = tmp31  /* pattern as ty=Boolean */;
          _i1 = tmp33  /* pattern as ty=Integer */;
          _cr2 = tmpMeta34;
          _negatedCr2 = tmp36  /* pattern as ty=Boolean */;
          _i2 = tmp38  /* pattern as ty=Integer */;
          _eqnAttributes = tmpMeta39;
          /* Pattern matching succeeded */
          tmpMeta40 = mmc_mk_box9(5, &RemoveSimpleEquations_SimpleContainer_TIMEALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(_visited));
          tmpMeta1 = tmpMeta40;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_integer tmp43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp43 = mmc_unbox_integer(tmpMeta42);
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _cr1 = tmpMeta41;
          _i1 = tmp43  /* pattern as ty=Integer */;
          _exp = tmpMeta44;
          _eqnAttributes = tmpMeta45;
          /* Pattern matching succeeded */
          tmpMeta46 = mmc_mk_box6(6, &RemoveSimpleEquations_SimpleContainer_TIMEINDEPENTVAR__desc, _cr1, mmc_mk_integer(_i1), _exp, _eqnAttributes, mmc_mk_integer(_visited));
          tmpMeta1 = tmpMeta46;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oS = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oS;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_setVisited(threadData_t *threadData, modelica_metatype _visited, modelica_metatype _iS)
{
  modelica_integer tmp1;
  modelica_metatype _oS = NULL;
  tmp1 = mmc_unbox_integer(_visited);
  _oS = omc_RemoveSimpleEquations_setVisited(threadData, tmp1, _iS);
  /* skip box _oS; RemoveSimpleEquations.SimpleContainer */
  return _oS;
}

PROTECTED_FUNCTION_STATIC modelica_integer omc_RemoveSimpleEquations_getVisited(threadData_t *threadData, modelica_metatype _iS)
{
  modelica_integer _visited;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _visited has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iS;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          modelica_integer tmp6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmp6 = mmc_unbox_integer(tmpMeta5);
          _visited = tmp6  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _visited;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,8) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmp8 = mmc_unbox_integer(tmpMeta7);
          _visited = tmp8  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _visited;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          _visited = tmp10  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _visited;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta11;
          modelica_integer tmp12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp12 = mmc_unbox_integer(tmpMeta11);
          _visited = tmp12  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          tmp1 = _visited;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _visited = tmp1;
  _return: OMC_LABEL_UNUSED
  return _visited;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getVisited(threadData_t *threadData, modelica_metatype _iS)
{
  modelica_integer _visited;
  modelica_metatype out_visited;
  _visited = omc_RemoveSimpleEquations_getVisited(threadData, _iS);
  out_visited = mmc_mk_icon(_visited);
  return out_visited;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_isVisited(threadData_t *threadData, modelica_integer _mark, modelica_metatype _iS)
{
  modelica_boolean _visited;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _visited has no default value.
  _visited = (_mark == omc_RemoveSimpleEquations_getVisited(threadData, _iS));
  _return: OMC_LABEL_UNUSED
  return _visited;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_isVisited(threadData_t *threadData, modelica_metatype _mark, modelica_metatype _iS)
{
  modelica_integer tmp1;
  modelica_boolean _visited;
  modelica_metatype out_visited;
  tmp1 = mmc_unbox_integer(_mark);
  _visited = omc_RemoveSimpleEquations_isVisited(threadData, tmp1, _iS);
  out_visited = mmc_mk_icon(_visited);
  return out_visited;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias3(threadData_t *threadData, modelica_metatype _var, modelica_integer _i, modelica_boolean _state, modelica_boolean _replaceable_, modelica_integer _r, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable)
{
  modelica_metatype _oRmax = NULL;
  modelica_metatype _oSmax = NULL;
  modelica_metatype _oUnremovable = NULL;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oRmax has no default value.
  // _oSmax has no default value.
  // _oUnremovable has no default value.
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_boolean tmp4_2;modelica_metatype tmp4_3;modelica_metatype tmp4_4;modelica_metatype tmp4_5;
    tmp4_1 = _state;
    tmp4_2 = _replaceable_;
    tmp4_3 = _iRmax;
    tmp4_4 = _iSmax;
    tmp4_5 = _iUnremovable;
    {
      modelica_integer _w1;
      modelica_integer _w2;
      modelica_metatype _tpl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _w1 has no default value.
      // _w2 has no default value.
      // _tpl has no default value.
      tmp4 = 0;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (!optionNone(tmp4_5)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_calcAliasKey(threadData, _var);
          tmpMeta6 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
          tmpMeta[0+0] = mmc_mk_some(tmpMeta6);
          tmpMeta[0+1] = _iSmax;
          tmpMeta[0+2] = mmc_mk_some(mmc_mk_integer(_i));
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (!optionNone(tmp4_5)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_varStateSelectPrioAlias(threadData, _var);
          tmpMeta7 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
          tmpMeta[0+0] = _iRmax;
          tmpMeta[0+1] = mmc_mk_some(tmpMeta7);
          tmpMeta[0+2] = mmc_mk_some(mmc_mk_integer(_i));
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta8;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (!optionNone(tmp4_4)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_varStateSelectPrioAlias(threadData, _var);
          tmpMeta8 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
          tmpMeta[0+0] = _iRmax;
          tmpMeta[0+1] = mmc_mk_some(tmpMeta8);
          tmpMeta[0+2] = _iUnremovable;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_boolean tmp13;
          modelica_metatype tmpMeta14;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (optionNone(tmp4_4)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          
          _w2 = tmp11  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_varStateSelectPrioAlias(threadData, _var);

          tmp13 = (modelica_boolean)(_w1 > _w2);
          if(tmp13)
          {
            tmpMeta12 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
            tmpMeta14 = mmc_mk_some(tmpMeta12);
          }
          else
          {
            tmpMeta14 = _iSmax;
          }
          _tpl = tmpMeta14;
          tmpMeta[0+0] = _iRmax;
          tmpMeta[0+1] = _tpl;
          tmpMeta[0+2] = _iUnremovable;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta15;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (!optionNone(tmp4_3)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_calcAliasKey(threadData, _var);
          tmpMeta15 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
          tmpMeta[0+0] = mmc_mk_some(tmpMeta15);
          tmpMeta[0+1] = _iSmax;
          tmpMeta[0+2] = _iUnremovable;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_boolean tmp20;
          modelica_metatype tmpMeta21;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          
          _w2 = tmp18  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _w1 = omc_BackendVariable_calcAliasKey(threadData, _var);

          tmp20 = (modelica_boolean)(_w1 < _w2);
          if(tmp20)
          {
            tmpMeta19 = mmc_mk_box2(0, mmc_mk_integer(_i), mmc_mk_integer(_w1));
            tmpMeta21 = mmc_mk_some(tmpMeta19);
          }
          else
          {
            tmpMeta21 = _iRmax;
          }
          _tpl = tmpMeta21;
          tmpMeta[0+0] = _tpl;
          tmpMeta[0+1] = _iSmax;
          tmpMeta[0+2] = _iUnremovable;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oRmax = tmpMeta[0+0];
  _oSmax = tmpMeta[0+1];
  _oUnremovable = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_oSmax) { *out_oSmax = _oSmax; }
  if (out_oUnremovable) { *out_oUnremovable = _oUnremovable; }
  return _oRmax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias3(threadData_t *threadData, modelica_metatype _var, modelica_metatype _i, modelica_metatype _state, modelica_metatype _replaceable_, modelica_metatype _r, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_metatype _oRmax = NULL;
  tmp1 = mmc_unbox_integer(_i);
  tmp2 = mmc_unbox_integer(_state);
  tmp3 = mmc_unbox_integer(_replaceable_);
  tmp4 = mmc_unbox_integer(_r);
  _oRmax = omc_RemoveSimpleEquations_getAlias3(threadData, _var, tmp1, tmp2, tmp3, tmp4, _iRmax, _iSmax, _iUnremovable, out_oSmax, out_oUnremovable);
  /* skip box _oRmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oSmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oUnremovable; Option<#Integer> */
  return _oRmax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias2(threadData_t *threadData, modelica_metatype _containerIn, modelica_integer _currIdx, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue)
{
  modelica_metatype _oRmax = NULL;
  modelica_metatype _oSmax = NULL;
  modelica_metatype _oUnremovable = NULL;
  modelica_metatype _oConst = NULL;
  modelica_boolean _oContinue;
  modelica_boolean tmp1_c4 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oRmax has no default value.
  // _oSmax has no default value.
  // _oUnremovable has no default value.
  // _oConst has no default value.
  // _oContinue has no default value.
  
  
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _containerIn;
    tmp4_2 = _prevVar;
    {
      modelica_metatype _adjEqs = NULL;
      modelica_metatype _rmax = NULL;
      modelica_metatype _smax = NULL;
      modelica_metatype _unremovable = NULL;
      modelica_metatype _const = NULL;
      modelica_metatype _v = NULL;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_integer _i;
      modelica_integer _prevVarIdx;
      modelica_boolean _state;
      modelica_boolean _replaceable_;
      modelica_boolean _cont;
      modelica_boolean _replaceble1;
      modelica_boolean _neg;
      modelica_boolean _negatedCr1;
      modelica_boolean _negatedCr2;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _adjEqs has no default value.
      // _rmax has no default value.
      // _smax has no default value.
      // _unremovable has no default value.
      // _const has no default value.
      // _v has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _i has no default value.
      // _prevVarIdx has no default value.
      // _state has no default value.
      // _replaceable_ has no default value.
      // _cont has no default value.
      // _replaceble1 has no default value.
      // _neg has no default value.
      // _negatedCr1 has no default value.
      // _negatedCr2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 5; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_integer tmp7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp7 = mmc_unbox_integer(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          if (!optionNone(tmp4_2)) goto tmp3_end;
          _negatedCr1 = tmp7  /* pattern as ty=Boolean */;
          _i1 = tmp9  /* pattern as ty=Integer */;
          _negatedCr2 = tmp11  /* pattern as ty=Boolean */;
          _i2 = tmp13  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _neg = (_negatedCr1 || _negatedCr2);

          _adjEqs = omc_List_removeOnTrue(threadData, mmc_mk_integer(_currIdx), boxvar_intEq, arrayGet(_iMT,_i1) /* DAE.ASUB */);

          _v = omc_BackendVariable_getVarAt(threadData, _vars, _i1);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _state = (omc_BackendVariable_isStateVar(threadData, _v) || omc_BackendVariable_isClockedStateVar(threadData, _v));

          _rmax = omc_RemoveSimpleEquations_getAlias3(threadData, _v, _i1, _state, (_replaceable_ && _replaceble1), _currIdx, _iRmax, _iSmax, _iUnremovable ,&_smax ,&_unremovable);

          _neg = (_neg?(!_negate):_negate);

          _rmax = omc_RemoveSimpleEquations_getAlias(threadData, _adjEqs, mmc_mk_some(mmc_mk_integer(_i1)), _mark, _simpleeqnsarr, _iMT, _vars, _unReplaceable, _neg, _stack, _rmax, _smax, _unremovable, _iConst ,&_smax ,&_unremovable ,&_const ,&_cont);

          _adjEqs = omc_List_removeOnTrue(threadData, mmc_mk_integer(_currIdx), boxvar_intEq, arrayGet(_iMT,_i2) /* DAE.ASUB */);

          _v = omc_BackendVariable_getVarAt(threadData, _vars, _i2);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _state = (omc_BackendVariable_isStateVar(threadData, _v) || omc_BackendVariable_isClockedStateVar(threadData, _v));

          _rmax = omc_RemoveSimpleEquations_getAlias3(threadData, _v, _i2, _state, (_replaceable_ && _replaceble1), _currIdx, _rmax, _smax, _unremovable ,&_smax ,&_unremovable);

          if(_cont)
          {
            _rmax = omc_RemoveSimpleEquations_getAlias(threadData, _adjEqs, mmc_mk_some(mmc_mk_integer(_i2)), _mark, _simpleeqnsarr, _iMT, _vars, _unReplaceable, _neg, _stack, _rmax, _smax, _unremovable, _const ,&_smax ,&_unremovable ,&_const ,&_cont);
          }
          tmpMeta[0+0] = _rmax;
          tmpMeta[0+1] = _smax;
          tmpMeta[0+2] = _unremovable;
          tmpMeta[0+3] = _const;
          tmp1_c4 = _cont;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          if (optionNone(tmp4_2)) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          _negatedCr1 = tmp15  /* pattern as ty=Boolean */;
          _i1 = tmp17  /* pattern as ty=Integer */;
          _negatedCr2 = tmp19  /* pattern as ty=Boolean */;
          _i2 = tmp21  /* pattern as ty=Integer */;
          _prevVarIdx = tmp23  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _i = ((_prevVarIdx == _i1)?_i2:_i1);

          _neg = (_negatedCr1 || _negatedCr2);

          _adjEqs = omc_List_removeOnTrue(threadData, mmc_mk_integer(_currIdx), boxvar_intEq, arrayGet(_iMT,_i) /* DAE.ASUB */);

          _v = omc_BackendVariable_getVarAt(threadData, _vars, _i);

          _replaceable_ = omc_RemoveSimpleEquations_replaceableAlias(threadData, _v, _unReplaceable ,&_replaceble1);

          _state = (omc_BackendVariable_isStateVar(threadData, _v) || omc_BackendVariable_isClockedStateVar(threadData, _v));

          _rmax = omc_RemoveSimpleEquations_getAlias3(threadData, _v, _i, _state, (_replaceable_ && _replaceble1), _currIdx, _iRmax, _iSmax, _iUnremovable ,&_smax ,&_unremovable);

          _neg = (_neg?(!_negate):_negate);
          tmpMeta[0+0] = omc_RemoveSimpleEquations_getAlias(threadData, _adjEqs, mmc_mk_some(mmc_mk_integer(_i)), _mark, _simpleeqnsarr, _iMT, _vars, _unReplaceable, _neg, _stack, _rmax, _smax, _unremovable, _iConst, &tmpMeta[0+1], &tmpMeta[0+2], &tmpMeta[0+3], &tmp1_c4);
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,8) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          tmpMeta[0+2] = mmc_mk_none();
          tmpMeta[0+3] = mmc_mk_some(mmc_mk_integer(_currIdx));
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          tmpMeta[0+2] = mmc_mk_none();
          tmpMeta[0+3] = mmc_mk_some(mmc_mk_integer(_currIdx));
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 4: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          tmpMeta[0+2] = mmc_mk_none();
          tmpMeta[0+3] = mmc_mk_some(mmc_mk_integer(_currIdx));
          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:;
    }
  }
  _oRmax = tmpMeta[0+0];
  _oSmax = tmpMeta[0+1];
  _oUnremovable = tmpMeta[0+2];
  _oConst = tmpMeta[0+3];
  _oContinue = tmp1_c4;
  _return: OMC_LABEL_UNUSED
  if (out_oSmax) { *out_oSmax = _oSmax; }
  if (out_oUnremovable) { *out_oUnremovable = _oUnremovable; }
  if (out_oConst) { *out_oConst = _oConst; }
  if (out_oContinue) { *out_oContinue = _oContinue; }
  return _oRmax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias2(threadData_t *threadData, modelica_metatype _containerIn, modelica_metatype _currIdx, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _simpleeqnsarr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_boolean _oContinue;
  modelica_metatype _oRmax = NULL;
  tmp1 = mmc_unbox_integer(_currIdx);
  tmp2 = mmc_unbox_integer(_mark);
  tmp3 = mmc_unbox_integer(_negate);
  _oRmax = omc_RemoveSimpleEquations_getAlias2(threadData, _containerIn, tmp1, _prevVar, tmp2, _simpleeqnsarr, _iMT, _vars, _unReplaceable, tmp3, _stack, _iRmax, _iSmax, _iUnremovable, _iConst, out_oSmax, out_oUnremovable, out_oConst, &_oContinue);
  /* skip box _oRmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oSmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oUnremovable; Option<#Integer> */
  /* skip box _oConst; Option<#Integer> */
  if (out_oContinue) { *out_oContinue = mmc_mk_icon(_oContinue); }
  return _oRmax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVarsNames(threadData_t *threadData, modelica_metatype _iS)
{
  modelica_metatype _names = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _names has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _iS;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      int tmp4;
      // _cr1 has no default value.
      // _cr2 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,8) == 0) goto tmp3_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _cr1 = tmpMeta5;
          _cr2 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_cons(_cr1, mmc_mk_cons(_cr2, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta1 = tmpMeta7;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,8) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _cr1 = tmpMeta8;
          _cr2 = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta10 = mmc_mk_cons(_cr1, mmc_mk_cons(_cr2, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta1 = tmpMeta10;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,8) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _cr1 = tmpMeta11;
          _cr2 = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_cons(_cr1, mmc_mk_cons(_cr2, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr1 = tmpMeta14;
          /* Pattern matching succeeded */
          tmpMeta15 = mmc_mk_cons(_cr1, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _names = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _names;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData_t *threadData, modelica_metatype _stack, modelica_integer _iR, modelica_metatype _simpleeqnsarr)
{
  modelica_metatype _oMsg = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _oMsg = tmpMeta1;
  {
    modelica_metatype _r;
    for (tmpMeta2 = _stack; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _r = MMC_CAR(tmpMeta2);
      if((mmc_unbox_integer(_r) == _iR))
      {
        break;
      }

      {
        modelica_metatype _n;
        for (tmpMeta3 = omc_RemoveSimpleEquations_getVarsNames(threadData, arrayGet(_simpleeqnsarr,mmc_unbox_integer(_r)) /* DAE.ASUB */); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
        {
          _n = MMC_CAR(tmpMeta3);
          tmpMeta4 = mmc_mk_cons(omc_ComponentReferenceBasics_printComponentRefStr(threadData, _n), _oMsg);
          _oMsg = tmpMeta4;
        }
      }

      tmpMeta6 = mmc_mk_cons(_OMC_LIT110, _oMsg);
      _oMsg = tmpMeta6;
    }
  }

  listReverseInPlace(_oMsg);
  _return: OMC_LABEL_UNUSED
  return _oMsg;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData_t *threadData, modelica_metatype _stack, modelica_metatype _iR, modelica_metatype _simpleeqnsarr)
{
  modelica_integer tmp1;
  modelica_metatype _oMsg = NULL;
  modelica_metatype tmpMeta2;
  tmp1 = mmc_unbox_integer(_iR);
  _oMsg = omc_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData, _stack, tmp1, _simpleeqnsarr);
  /* skip box _oMsg; list<String> */
  return _oMsg;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_RemoveSimpleEquations_circularEqualityMsg(threadData_t *threadData, modelica_metatype _stack, modelica_integer _iR, modelica_metatype _simpleeqnsarr, modelica_string _iMsg)
{
  modelica_string _oMsg = NULL;
  modelica_metatype _lst = NULL;
  modelica_string _msg = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oMsg has no default value.
  // _lst has no default value.
  // _msg has no default value.
  _lst = omc_RemoveSimpleEquations_circularEqualityMsg__dispatch(threadData, _stack, _iR, _simpleeqnsarr);

  _msg = stringDelimitList(_lst, _OMC_LIT21);

  tmpMeta1 = mmc_mk_cons(_iMsg, mmc_mk_cons(_msg, mmc_mk_cons(_OMC_LIT21, MMC_REFSTRUCTLIT(mmc_nil))));
  _msg = stringAppendList(tmpMeta1);

  _oMsg = _msg;
  _return: OMC_LABEL_UNUSED
  return _oMsg;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_circularEqualityMsg(threadData_t *threadData, modelica_metatype _stack, modelica_metatype _iR, modelica_metatype _simpleeqnsarr, modelica_metatype _iMsg)
{
  modelica_integer tmp1;
  modelica_string _oMsg = NULL;
  tmp1 = mmc_unbox_integer(_iR);
  _oMsg = omc_RemoveSimpleEquations_circularEqualityMsg(threadData, _stack, tmp1, _simpleeqnsarr, _iMsg);
  /* skip box _oMsg; String */
  return _oMsg;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias1(threadData_t *threadData, modelica_boolean _visited, modelica_metatype _containerIn, modelica_integer _currIdx, modelica_metatype _rows, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue)
{
  modelica_metatype _oRmax = NULL;
  modelica_metatype _oSmax = NULL;
  modelica_metatype _oUnremovable = NULL;
  modelica_metatype _oConst = NULL;
  modelica_boolean _oContinue;
  modelica_boolean tmp1_c4 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oRmax has no default value.
  // _oSmax has no default value.
  // _oUnremovable has no default value.
  // _oConst has no default value.
  // _oContinue has no default value.
  
  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_boolean tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _visited;
    tmp4_2 = _negate;
    tmp4_3 = _iUnremovable;
    {
      modelica_metatype _rmax = NULL;
      modelica_metatype _smax = NULL;
      modelica_metatype _unremovable = NULL;
      modelica_metatype _const = NULL;
      modelica_boolean _cont;
      modelica_string _msg = NULL;
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rmax has no default value.
      // _smax has no default value.
      // _unremovable has no default value.
      // _const has no default value.
      // _cont has no default value.
      // _msg has no default value.
      // _cr has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          arrayUpdate(_containerArr, _currIdx, omc_RemoveSimpleEquations_setVisited(threadData, _mark, _containerIn));

          tmpMeta6 = mmc_mk_cons(mmc_mk_integer(_currIdx), _stack);
          _rmax = omc_RemoveSimpleEquations_getAlias2(threadData, _containerIn, _currIdx, _prevVar, _mark, _containerArr, _iMT, _vars, _unReplaceable, _negate, tmpMeta6, _iRmax, _iSmax, _iUnremovable, _iConst ,&_smax ,&_unremovable ,&_const ,&_cont);

          if(_cont)
          {
            _rmax = omc_RemoveSimpleEquations_getAlias(threadData, _rows, _prevVar, _mark, _containerArr, _iMT, _vars, _unReplaceable, _negate, _stack, _rmax, _smax, _unremovable, _const ,&_smax ,&_unremovable ,&_const ,&_cont);
          }
          tmpMeta[0+0] = _rmax;
          tmpMeta[0+1] = _smax;
          tmpMeta[0+2] = _unremovable;
          tmpMeta[0+3] = _const;
          tmp1_c4 = _cont;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_boolean tmp10;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          if (optionNone(tmp4_3)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta8 = arrayGet(_containerArr,_currIdx) /* DAE.ASUB */;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,0,8) == 0) goto goto_2;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          _cr = tmpMeta9;

          /* Pattern-matching assignment */
          tmp10 = omc_Types_isIntegerOrRealOrSubTypeOfEither(threadData, omc_ComponentReference_crefLastType(threadData, _cr));
          if (1 /* true */ != tmp10) goto goto_2;
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          tmpMeta[0+2] = mmc_mk_none();
          tmpMeta[0+3] = _iUnremovable;
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_boolean tmp13;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta11 = arrayGet(_containerArr,_currIdx) /* DAE.ASUB */;
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,0,8) == 0) goto goto_2;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          _cr = tmpMeta12;

          /* Pattern-matching assignment */
          tmp13 = omc_Types_isIntegerOrRealOrSubTypeOfEither(threadData, omc_ComponentReference_crefLastType(threadData, _cr));
          if (1 /* true */ != tmp13) goto goto_2;
          tmpMeta[0+0] = mmc_mk_none();
          tmpMeta[0+1] = mmc_mk_none();
          tmpMeta[0+2] = mmc_mk_none();
          tmpMeta[0+3] = mmc_mk_some(mmc_mk_integer(_currIdx));
          tmp1_c4 = 0 /* false */;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta14;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _msg = _OMC_LIT111;

          _msg = omc_RemoveSimpleEquations_circularEqualityMsg(threadData, _stack, _currIdx, _containerArr, _msg);

          tmpMeta14 = mmc_mk_cons(_msg, MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addMessage(threadData, _OMC_LIT113, tmpMeta14);
          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 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _oRmax = tmpMeta[0+0];
  _oSmax = tmpMeta[0+1];
  _oUnremovable = tmpMeta[0+2];
  _oConst = tmpMeta[0+3];
  _oContinue = tmp1_c4;
  _return: OMC_LABEL_UNUSED
  if (out_oSmax) { *out_oSmax = _oSmax; }
  if (out_oUnremovable) { *out_oUnremovable = _oUnremovable; }
  if (out_oConst) { *out_oConst = _oConst; }
  if (out_oContinue) { *out_oContinue = _oContinue; }
  return _oRmax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias1(threadData_t *threadData, modelica_metatype _visited, modelica_metatype _containerIn, modelica_metatype _currIdx, modelica_metatype _rows, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_boolean _oContinue;
  modelica_metatype _oRmax = NULL;
  tmp1 = mmc_unbox_integer(_visited);
  tmp2 = mmc_unbox_integer(_currIdx);
  tmp3 = mmc_unbox_integer(_mark);
  tmp4 = mmc_unbox_integer(_negate);
  _oRmax = omc_RemoveSimpleEquations_getAlias1(threadData, tmp1, _containerIn, tmp2, _rows, _prevVar, tmp3, _containerArr, _iMT, _vars, _unReplaceable, tmp4, _stack, _iRmax, _iSmax, _iUnremovable, _iConst, out_oSmax, out_oUnremovable, out_oConst, &_oContinue);
  /* skip box _oRmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oSmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oUnremovable; Option<#Integer> */
  /* skip box _oConst; Option<#Integer> */
  if (out_oContinue) { *out_oContinue = mmc_mk_icon(_oContinue); }
  return _oRmax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getAlias(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _prevVar, modelica_integer _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_boolean _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_boolean *out_oContinue)
{
  modelica_metatype _oRmax = NULL;
  modelica_metatype _oSmax = NULL;
  modelica_metatype _oUnremovable = NULL;
  modelica_metatype _oConst = NULL;
  modelica_boolean _oContinue;
  modelica_boolean tmp1_c4 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oRmax has no default value.
  // _oSmax has no default value.
  // _oUnremovable has no default value.
  // _oConst has no default value.
  // _oContinue has no default value.
  
  
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _rows;
    {
      modelica_integer _r;
      modelica_metatype _rest = NULL;
      modelica_metatype _container = NULL;
      modelica_boolean _visited;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _r has no default value.
      // _rest has no default value.
      // _container has no default value.
      // _visited has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iRmax;
          tmpMeta[0+1] = _iSmax;
          tmpMeta[0+2] = _iUnremovable;
          tmpMeta[0+3] = _iConst;
          tmp1_c4 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_integer tmp8;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmp8 = mmc_unbox_integer(tmpMeta6);
          _r = tmp8  /* pattern as ty=Integer */;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _container = arrayGet(_containerArr,_r) /* DAE.ASUB */;

          _visited = omc_RemoveSimpleEquations_isVisited(threadData, _mark, _container);
          tmpMeta[0+0] = omc_RemoveSimpleEquations_getAlias1(threadData, _visited, _container, _r, _rest, _prevVar, _mark, _containerArr, _iMT, _vars, _unReplaceable, _negate, _stack, _iRmax, _iSmax, _iUnremovable, _iConst, &tmpMeta[0+1], &tmpMeta[0+2], &tmpMeta[0+3], &tmp1_c4);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oRmax = tmpMeta[0+0];
  _oSmax = tmpMeta[0+1];
  _oUnremovable = tmpMeta[0+2];
  _oConst = tmpMeta[0+3];
  _oContinue = tmp1_c4;
  _return: OMC_LABEL_UNUSED
  if (out_oSmax) { *out_oSmax = _oSmax; }
  if (out_oUnremovable) { *out_oUnremovable = _oUnremovable; }
  if (out_oConst) { *out_oConst = _oConst; }
  if (out_oContinue) { *out_oContinue = _oContinue; }
  return _oRmax;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getAlias(threadData_t *threadData, modelica_metatype _rows, modelica_metatype _prevVar, modelica_metatype _mark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _vars, modelica_metatype _unReplaceable, modelica_metatype _negate, modelica_metatype _stack, modelica_metatype _iRmax, modelica_metatype _iSmax, modelica_metatype _iUnremovable, modelica_metatype _iConst, modelica_metatype *out_oSmax, modelica_metatype *out_oUnremovable, modelica_metatype *out_oConst, modelica_metatype *out_oContinue)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_boolean _oContinue;
  modelica_metatype _oRmax = NULL;
  tmp1 = mmc_unbox_integer(_mark);
  tmp2 = mmc_unbox_integer(_negate);
  _oRmax = omc_RemoveSimpleEquations_getAlias(threadData, _rows, _prevVar, tmp1, _containerArr, _iMT, _vars, _unReplaceable, tmp2, _stack, _iRmax, _iSmax, _iUnremovable, _iConst, out_oSmax, out_oUnremovable, out_oConst, &_oContinue);
  /* skip box _oRmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oSmax; Option<tuple<#Integer, #Integer>> */
  /* skip box _oUnremovable; Option<#Integer> */
  /* skip box _oConst; Option<#Integer> */
  if (out_oContinue) { *out_oContinue = mmc_mk_icon(_oContinue); }
  return _oRmax;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_handleSets(threadData_t *threadData, modelica_integer _containerIdx, modelica_integer _inMark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype __omcQ_24in_5Fvars, modelica_metatype __omcQ_24in_5Feqnslst, modelica_metatype __omcQ_24in_5Fshared, modelica_metatype __omcQ_24in_5Frepl, modelica_metatype *out_eqnslst, modelica_metatype *out_shared, modelica_metatype *out_repl, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _vars = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _repl = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _rmax = NULL;
  modelica_metatype _smax = NULL;
  modelica_metatype _unremovable = NULL;
  modelica_metatype _const = NULL;
  modelica_integer _mark;
  modelica_boolean _b;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _vars = __omcQ_24in_5Fvars;
  _eqnslst = __omcQ_24in_5Feqnslst;
  _shared = __omcQ_24in_5Fshared;
  _repl = __omcQ_24in_5Frepl;
  _warnAliasConflicts = 0 /* false */;
  // _rmax has no default value.
  // _smax has no default value.
  // _unremovable has no default value.
  // _const has no default value.
  _mark = _inMark;
  // _b has no default value.
  tmp3 = _containerIdx; tmp4 = ((modelica_integer) -1); tmp5 = ((modelica_integer) 1);
  if(!(((tmp4 > 0) && (tmp3 > tmp5)) || ((tmp4 < 0) && (tmp3 < tmp5))))
  {
    modelica_integer _idx;
    for(_idx = _containerIdx; in_range_integer(_idx, tmp3, tmp5); _idx += tmp4)
    {
      if((!(omc_RemoveSimpleEquations_getVisited(threadData, arrayGet(_containerArr,_idx) /* DAE.ASUB */) > ((modelica_integer) 0))))
      {
        tmpMeta1 = mmc_mk_cons(mmc_mk_integer(_idx), MMC_REFSTRUCTLIT(mmc_nil));
        tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
        _rmax = omc_RemoveSimpleEquations_getAlias(threadData, tmpMeta1, mmc_mk_none(), _mark, _containerArr, _iMT, _vars, _unReplaceable, 0 /* false */, tmpMeta2, mmc_mk_none(), mmc_mk_none(), mmc_mk_none(), mmc_mk_none() ,&_smax ,&_unremovable ,&_const ,NULL);

        _vars = omc_RemoveSimpleEquations_handleSet(threadData, _rmax, _smax, _unremovable, _const, ((modelica_integer) 1) + _mark, _containerArr, _iMT, _unReplaceable, _vars, _eqnslst, _shared, _repl ,&_eqnslst ,&_shared ,&_repl ,&_b);

        _mark = ((modelica_integer) 2) + _mark;

        _warnAliasConflicts = (_warnAliasConflicts || _b);
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_eqnslst) { *out_eqnslst = _eqnslst; }
  if (out_shared) { *out_shared = _shared; }
  if (out_repl) { *out_repl = _repl; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _vars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_handleSets(threadData_t *threadData, modelica_metatype _containerIdx, modelica_metatype _inMark, modelica_metatype _containerArr, modelica_metatype _iMT, modelica_metatype _unReplaceable, modelica_metatype __omcQ_24in_5Fvars, modelica_metatype __omcQ_24in_5Feqnslst, modelica_metatype __omcQ_24in_5Fshared, modelica_metatype __omcQ_24in_5Frepl, modelica_metatype *out_eqnslst, modelica_metatype *out_shared, modelica_metatype *out_repl, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _vars = NULL;
  tmp1 = mmc_unbox_integer(_containerIdx);
  tmp2 = mmc_unbox_integer(_inMark);
  _vars = omc_RemoveSimpleEquations_handleSets(threadData, tmp1, tmp2, _containerArr, _iMT, _unReplaceable, __omcQ_24in_5Fvars, __omcQ_24in_5Feqnslst, __omcQ_24in_5Fshared, __omcQ_24in_5Frepl, out_eqnslst, out_shared, out_repl, &_warnAliasConflicts);
  /* skip box _vars; BackendDAE.Variables */
  /* skip box _eqnslst; list<BackendDAE.Equation> */
  /* skip box _shared; BackendDAE.Shared */
  /* skip box _repl; BackendVarTransform.VariableReplacements */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _vars;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_aliasExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype *out_outCr)
{
  modelica_boolean _negate;
  modelica_metatype _outCr = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _negate has no default value.
  // _outCr has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _cr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr 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,6,2) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          tmp1_c0 = 0 /* false */;
          tmpMeta[0+1] = _cr;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,5,1) == 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));
          
          _cr = tmpMeta9;
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _cr;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,6,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,6,2) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          
          _cr = tmpMeta12;
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _cr;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta13,24,1) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,6,2) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          
          _cr = tmpMeta15;
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _cr;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _negate = tmp1_c0;
  _outCr = tmpMeta[0+1];
  _return: OMC_LABEL_UNUSED
  if (out_outCr) { *out_outCr = _outCr; }
  return _negate;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_aliasExp(threadData_t *threadData, modelica_metatype _exp, modelica_metatype *out_outCr)
{
  modelica_boolean _negate;
  modelica_metatype out_negate;
  _negate = omc_RemoveSimpleEquations_aliasExp(threadData, _exp, out_outCr);
  out_negate = mmc_mk_icon(_negate);
  /* skip box _outCr; DAE.ComponentRef */
  return out_negate;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_constOrAliasAcausal(threadData_t *threadData, modelica_metatype _var, modelica_integer _i, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inTpl;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _seqns = NULL;
      modelica_integer _index;
      modelica_metatype _mT = NULL;
      modelica_metatype _cra = NULL;
      modelica_metatype _vars2 = NULL;
      modelica_metatype _ilst2 = NULL;
      modelica_boolean _negated;
      modelica_metatype _colum = NULL;
      modelica_metatype _functions = NULL;
      modelica_metatype _exp2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _shared has no default value.
      // _eqns has no default value.
      // _seqns has no default value.
      // _index has no default value.
      // _mT has no default value.
      // _cra has no default value.
      // _vars2 has no default value.
      // _ilst2 has no default value.
      // _negated has no default value.
      // _colum has no default value.
      // _functions has no default value.
      // _exp2 has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _vars = tmpMeta6;
          _shared = tmpMeta7;
          _eqns = tmpMeta8;
          _seqns = tmpMeta9;
          _index = tmp11  /* pattern as ty=Integer */;
          _mT = tmpMeta12;
          /* Pattern matching succeeded */
          _negated = omc_RemoveSimpleEquations_aliasExp(threadData, _exp ,&_cra);

          _globalKnownVars = omc_BackendVariable_daeGlobalKnownVars(threadData, _shared);

          _vars2 = omc_BackendVariable_getVar(threadData, _cra, _globalKnownVars ,&_ilst2);

          tmpMeta13 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta14 = mmc_mk_cons(mmc_mk_integer(_i), MMC_REFSTRUCTLIT(mmc_nil));
          _seqns = omc_RemoveSimpleEquations_generateSimpleContainters(threadData, tmpMeta13, 0 /* false */, tmpMeta14, 0 /* false */, 0 /* false */, _vars2, _negated, _ilst2, 1 /* true */, 0 /* false */, _eqnAttributes, _seqns, _index, _mT ,&_index ,&_mT);
          tmpMeta15 = mmc_mk_box7(0, _vars, _shared, _eqns, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = tmpMeta15;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _vars = tmpMeta16;
          _shared = tmpMeta17;
          _eqns = tmpMeta18;
          _seqns = tmpMeta19;
          _index = tmp21  /* pattern as ty=Integer */;
          _mT = tmpMeta22;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isConstValue(threadData, _exp)) goto tmp3_end;
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrCrefStrExpStr(threadData, _OMC_LIT114, _cr, _OMC_LIT3, _exp, _OMC_LIT115);
          }

          _colum = arrayGet(_mT,_i) /* DAE.ASUB */;

          tmpMeta23 = mmc_mk_cons(mmc_mk_integer(_index), _colum);
          arrayUpdate(_mT, _i, tmpMeta23);
          tmpMeta25 = mmc_mk_box6(6, &RemoveSimpleEquations_SimpleContainer_TIMEINDEPENTVAR__desc, _cr, mmc_mk_integer(_i), _exp, _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta24 = mmc_mk_cons(tmpMeta25, _seqns);
          tmpMeta26 = mmc_mk_box7(0, _vars, _shared, _eqns, tmpMeta24, mmc_mk_integer(((modelica_integer) 1) + _index), _mT, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = tmpMeta26;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_integer tmp33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 12));
          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));
          tmp33 = mmc_unbox_integer(tmpMeta32);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _vars = tmpMeta27;
          _shared = tmpMeta28;
          _functions = tmpMeta29;
          _eqns = tmpMeta30;
          _seqns = tmpMeta31;
          _index = tmp33  /* pattern as ty=Integer */;
          _mT = tmpMeta34;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((!omc_Expression_isImpure(threadData, _exp)) && (!omc_Expression_containsRecordType(threadData, _exp)))) goto tmp3_end;
          _exp2 = omc_EvaluateFunctions_evaluateConstantFunctionCallExp(threadData, _exp, _functions, 0 /* false */, omc_Flags_getConfigInt(threadData, _OMC_LIT120));

          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrCrefStrExpStr(threadData, _OMC_LIT121, _cr, _OMC_LIT3, _exp, _OMC_LIT115);
          }

          _colum = arrayGet(_mT,_i) /* DAE.ASUB */;

          tmpMeta35 = mmc_mk_cons(mmc_mk_integer(_index), _colum);
          arrayUpdate(_mT, _i, tmpMeta35);
          tmpMeta37 = mmc_mk_box6(6, &RemoveSimpleEquations_SimpleContainer_TIMEINDEPENTVAR__desc, _cr, mmc_mk_integer(_i), _exp2, _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta36 = mmc_mk_cons(tmpMeta37, _seqns);
          tmpMeta38 = mmc_mk_box7(0, _vars, _shared, _eqns, tmpMeta36, mmc_mk_integer(((modelica_integer) 1) + _index), _mT, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = tmpMeta38;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_integer tmp44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          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));
          tmp44 = mmc_unbox_integer(tmpMeta43);
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _vars = tmpMeta39;
          _shared = tmpMeta40;
          _eqns = tmpMeta41;
          _seqns = tmpMeta42;
          _index = tmp44  /* pattern as ty=Integer */;
          _mT = tmpMeta45;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!((!omc_Expression_isImpure(threadData, _exp)) && (!omc_Expression_containsRecordType(threadData, _exp)))) goto tmp3_end;
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrCrefStrExpStr(threadData, _OMC_LIT122, _cr, _OMC_LIT3, _exp, _OMC_LIT115);
          }

          _colum = arrayGet(_mT,_i) /* DAE.ASUB */;

          tmpMeta46 = mmc_mk_cons(mmc_mk_integer(_index), _colum);
          arrayUpdate(_mT, _i, tmpMeta46);
          tmpMeta48 = mmc_mk_box6(6, &RemoveSimpleEquations_SimpleContainer_TIMEINDEPENTVAR__desc, _cr, mmc_mk_integer(_i), _exp, _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta47 = mmc_mk_cons(tmpMeta48, _seqns);
          tmpMeta49 = mmc_mk_box7(0, _vars, _shared, _eqns, tmpMeta47, mmc_mk_integer(((modelica_integer) 1) + _index), _mT, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = tmpMeta49;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_constOrAliasAcausal(threadData_t *threadData, modelica_metatype _var, modelica_metatype _i, modelica_metatype _cr, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_i);
  _outTpl = omc_RemoveSimpleEquations_constOrAliasAcausal(threadData, _var, tmp1, _cr, _exp, _eqnAttributes, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_constOrAliasArrayAcausal(threadData_t *threadData, modelica_metatype _vars, modelica_metatype _indxs, modelica_metatype _exp, modelica_metatype _eqnAttributes, 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 = _vars;
    tmp4_2 = _indxs;
    {
      modelica_metatype _v = NULL;
      modelica_metatype _vlst = NULL;
      modelica_integer _i;
      modelica_metatype _ilst = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _e = NULL;
      modelica_metatype _subs = NULL;
      modelica_metatype _tpl = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v has no default value.
      // _vlst has no default value.
      // _i has no default value.
      // _ilst has no default value.
      // _cr has no default value.
      // _e has no default value.
      // _subs has no default value.
      // _tpl has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          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));
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_2);
          tmpMeta10 = MMC_CDR(tmp4_2);
          tmp11 = mmc_unbox_integer(tmpMeta9);
          _v = tmpMeta6;
          _cr = tmpMeta8;
          _vlst = tmpMeta7;
          _i = tmp11  /* pattern as ty=Integer */;
          _ilst = tmpMeta10;
          /* Pattern matching succeeded */
          _subs = omc_ComponentReference_crefLastSubs(threadData, _cr);

          _e = omc_Expression_applyExpSubscripts(threadData, _exp, _subs);

          _tpl = omc_RemoveSimpleEquations_constOrAliasAcausal(threadData, _v, _i, _cr, _e, _eqnAttributes, _inTpl);
          /* Tail recursive call */
          _vars = _vlst;
          _indxs = _ilst;
          _inTpl = _tpl;
          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:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

static modelica_metatype closure4_ComponentReferenceBasics_crefPrefixOf(threadData_t *thData, modelica_metatype closure, modelica_metatype fullCref)
{
  modelica_metatype prefixCref = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_ComponentReferenceBasics_crefPrefixOf(thData, prefixCref, fullCref);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveTimeIndependentAcausal1(threadData_t *threadData, modelica_metatype _vlst, modelica_metatype _ilst, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, 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 _cr = NULL;
      modelica_metatype _cre = NULL;
      modelica_metatype _es = NULL;
      modelica_metatype _crlst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _cre has no default value.
      // _es has no default value.
      // _crlst 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_boolean tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = omc_List_map(threadData, _vlst, boxvar_BackendVariable_varCref);
          if (listEmpty(tmpMeta6)) goto goto_2;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          _cr = tmpMeta7;
          _crlst = tmpMeta8;

          _cr = omc_ComponentReferenceBasics_crefStripLastSubs(threadData, _cr);

          /* Pattern-matching assignment */
          tmpMeta9 = mmc_mk_box1(0, _cr);
          tmp10 = omc_List_all(threadData, _crlst, (modelica_fnptr) mmc_mk_box2(0,closure4_ComponentReferenceBasics_crefPrefixOf,tmpMeta9));
          if (1 /* true */ != tmp10) goto goto_2;

          _cre = omc_Expression_crefExp(threadData, _cr);

          /* Pattern-matching tuple assignment */
          tmpMeta12 = omc_ExpressionSolve_solve(threadData, _lhs, _rhs, _cre, mmc_mk_none(), &tmpMeta11);
          _es = tmpMeta12;
          if (!listEmpty(tmpMeta11)) goto goto_2;
          tmpMeta1 = omc_RemoveSimpleEquations_constOrAliasArrayAcausal(threadData, _vlst, _ilst, _es, _eqnAttributes, _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
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_solveTimeIndependentAcausal(threadData_t *threadData, modelica_metatype _vlst, modelica_metatype _ilst, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, 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;modelica_metatype tmp4_3;modelica_metatype tmp4_4;
    tmp4_1 = _vlst;
    tmp4_2 = _ilst;
    tmp4_3 = _eqnAttributes;
    tmp4_4 = _inTpl;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _cre = NULL;
      modelica_metatype _es = NULL;
      modelica_metatype _v = NULL;
      modelica_integer _i;
      modelica_integer _size;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _cre has no default value.
      // _es has no default value.
      // _v has no default value.
      // _i has no default value.
      // _size has no default value.
      // _source has no default value.
      // _eqAttr has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_2);
          tmpMeta10 = MMC_CDR(tmp4_2);
          tmp11 = mmc_unbox_integer(tmpMeta9);
          if (!listEmpty(tmpMeta10)) goto tmp3_end;
          
          _v = tmpMeta6;
          _cr = tmpMeta8;
          _i = tmp11  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _cre = omc_Expression_crefExp(threadData, _cr);

          /* Pattern-matching tuple assignment */
          tmpMeta13 = omc_ExpressionSolve_solve(threadData, _lhs, _rhs, _cre, mmc_mk_none(), &tmpMeta12);
          _es = tmpMeta13;
          if (!listEmpty(tmpMeta12)) goto goto_2;
          tmpMeta1 = omc_RemoveSimpleEquations_constOrAliasAcausal(threadData, _v, _i, _cr, _es, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_boolean tmp17;
          modelica_metatype tmpMeta18;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 1));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_4), 2));
          
          _source = tmpMeta14;
          _eqAttr = tmpMeta15;
          /* Pattern matching succeeded */
          _size = omc_Expression_sizeOf(threadData, omc_Expression_typeof(threadData, _lhs));

          /* Pattern-matching assignment */
          tmp17 = (_size == listLength(_vlst));
          if (1 /* true */ != tmp17) goto goto_2;
          tmpMeta18 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_solveTimeIndependentAcausal1(threadData, _vlst, _ilst, _lhs, _rhs, tmpMeta18, _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
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traversingTimeVarsFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_boolean *out_cont, modelica_metatype *out_outTuple)
{
  modelica_metatype _outExp = NULL;
  modelica_boolean _cont;
  modelica_metatype _outTuple = NULL;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outExp has no default value.
  // _cont 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_boolean _b;
      modelica_boolean _b1;
      modelica_boolean _b2;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _ilst = NULL;
      modelica_metatype _vlst = NULL;
      modelica_metatype _varlst = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _b has no default value.
      // _b1 has no default value.
      // _b2 has no default value.
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _cr has no default value.
      // _ilst has no default value.
      // _vlst 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 < 8; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_boolean tmp19;
          modelica_metatype tmpMeta20;
          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_LIT35), MMC_STRINGDATA(tmpMeta7)) != 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _b = tmp10  /* pattern as ty=Boolean */;
          _vars = tmpMeta11;
          _globalKnownVars = tmpMeta12;
          _b1 = tmp14  /* pattern as ty=Boolean */;
          _b2 = tmp16  /* pattern as ty=Boolean */;
          _ilst = tmpMeta17;
          /* Pattern matching succeeded */
          tmp19 = (modelica_boolean)_b;
          if(tmp19)
          {
            tmpMeta20 = _inTuple;
          }
          else
          {
            tmpMeta18 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta20 = tmpMeta18;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta20;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_integer tmp23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_boolean tmp35;
          modelica_metatype tmpMeta36;
          modelica_boolean tmp37;
          modelica_metatype tmpMeta38;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp23 = mmc_unbox_integer(tmpMeta22);
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp29 = mmc_unbox_integer(tmpMeta28);
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _cr = tmpMeta21;
          _b = tmp23  /* pattern as ty=Boolean */;
          _vars = tmpMeta24;
          _globalKnownVars = tmpMeta25;
          _b1 = tmp27  /* pattern as ty=Boolean */;
          _b2 = tmp29  /* pattern as ty=Boolean */;
          _ilst = tmpMeta30;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta34 = omc_BackendVariable_getVar(threadData, _cr, _globalKnownVars, &tmpMeta31);
          _varlst = tmpMeta34;
          if (listEmpty(tmpMeta31)) goto goto_2;
          tmpMeta32 = MMC_CAR(tmpMeta31);
          tmpMeta33 = MMC_CDR(tmpMeta31);

          /* Pattern-matching assignment */
          tmp35 = omc_List_none(threadData, _varlst, boxvar_RemoveSimpleEquations_toplevelInputOrUnfixed);
          if (0 /* false */ != tmp35) goto goto_2;
          tmp37 = (modelica_boolean)_b;
          if(tmp37)
          {
            tmpMeta38 = _inTuple;
          }
          else
          {
            tmpMeta36 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta38 = tmpMeta36;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta38;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_integer tmp42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_integer tmp46;
          modelica_metatype tmpMeta47;
          modelica_integer tmp48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_boolean tmp51;
          modelica_metatype tmpMeta52;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,1,1) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          if (3 != MMC_STRLEN(tmpMeta40) || strcmp(MMC_STRINGDATA(_OMC_LIT57), MMC_STRINGDATA(tmpMeta40)) != 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp42 = mmc_unbox_integer(tmpMeta41);
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp46 = mmc_unbox_integer(tmpMeta45);
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp48 = mmc_unbox_integer(tmpMeta47);
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _b = tmp42  /* pattern as ty=Boolean */;
          _vars = tmpMeta43;
          _globalKnownVars = tmpMeta44;
          _b1 = tmp46  /* pattern as ty=Boolean */;
          _b2 = tmp48  /* pattern as ty=Boolean */;
          _ilst = tmpMeta49;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp51 = (modelica_boolean)_b;
          if(tmp51)
          {
            tmpMeta52 = _inTuple;
          }
          else
          {
            tmpMeta50 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta52 = tmpMeta50;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta52;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_integer tmp56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_integer tmp60;
          modelica_metatype tmpMeta61;
          modelica_integer tmp62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_boolean tmp65;
          modelica_metatype tmpMeta66;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta53,1,1) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta53), 2));
          if (8 != MMC_STRLEN(tmpMeta54) || strcmp(MMC_STRINGDATA(_OMC_LIT123), MMC_STRINGDATA(tmpMeta54)) != 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp56 = mmc_unbox_integer(tmpMeta55);
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp60 = mmc_unbox_integer(tmpMeta59);
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp62 = mmc_unbox_integer(tmpMeta61);
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _b = tmp56  /* pattern as ty=Boolean */;
          _vars = tmpMeta57;
          _globalKnownVars = tmpMeta58;
          _b1 = tmp60  /* pattern as ty=Boolean */;
          _b2 = tmp62  /* pattern as ty=Boolean */;
          _ilst = tmpMeta63;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp65 = (modelica_boolean)_b;
          if(tmp65)
          {
            tmpMeta66 = _inTuple;
          }
          else
          {
            tmpMeta64 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta66 = tmpMeta64;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta66;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_integer tmp70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_integer tmp74;
          modelica_metatype tmpMeta75;
          modelica_integer tmp76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_boolean tmp79;
          modelica_metatype tmpMeta80;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta67,1,1) == 0) goto tmp3_end;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta67), 2));
          if (6 != MMC_STRLEN(tmpMeta68) || strcmp(MMC_STRINGDATA(_OMC_LIT124), MMC_STRINGDATA(tmpMeta68)) != 0) goto tmp3_end;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp70 = mmc_unbox_integer(tmpMeta69);
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp74 = mmc_unbox_integer(tmpMeta73);
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp76 = mmc_unbox_integer(tmpMeta75);
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _b = tmp70  /* pattern as ty=Boolean */;
          _vars = tmpMeta71;
          _globalKnownVars = tmpMeta72;
          _b1 = tmp74  /* pattern as ty=Boolean */;
          _b2 = tmp76  /* pattern as ty=Boolean */;
          _ilst = tmpMeta77;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp79 = (modelica_boolean)_b;
          if(tmp79)
          {
            tmpMeta80 = _inTuple;
          }
          else
          {
            tmpMeta78 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta80 = tmpMeta78;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta80;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_integer tmp84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_integer tmp88;
          modelica_metatype tmpMeta89;
          modelica_integer tmp90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_boolean tmp93;
          modelica_metatype tmpMeta94;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta81,1,1) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta81), 2));
          if (4 != MMC_STRLEN(tmpMeta82) || strcmp(MMC_STRINGDATA(_OMC_LIT125), MMC_STRINGDATA(tmpMeta82)) != 0) goto tmp3_end;
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp84 = mmc_unbox_integer(tmpMeta83);
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp88 = mmc_unbox_integer(tmpMeta87);
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp90 = mmc_unbox_integer(tmpMeta89);
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _b = tmp84  /* pattern as ty=Boolean */;
          _vars = tmpMeta85;
          _globalKnownVars = tmpMeta86;
          _b1 = tmp88  /* pattern as ty=Boolean */;
          _b2 = tmp90  /* pattern as ty=Boolean */;
          _ilst = tmpMeta91;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          tmp93 = (modelica_boolean)_b;
          if(tmp93)
          {
            tmpMeta94 = _inTuple;
          }
          else
          {
            tmpMeta92 = mmc_mk_box6(0, mmc_mk_boolean(1 /* true */), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _ilst);
            tmpMeta94 = tmpMeta92;
          }
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 0 /* false */;
          tmpMeta[0+2] = tmpMeta94;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_integer tmp97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_integer tmp101;
          modelica_metatype tmpMeta102;
          modelica_integer tmp103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp97 = mmc_unbox_integer(tmpMeta96);
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp101 = mmc_unbox_integer(tmpMeta100);
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp103 = mmc_unbox_integer(tmpMeta102);
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          _cr = tmpMeta95;
          _b = tmp97  /* pattern as ty=Boolean */;
          _vars = tmpMeta98;
          _globalKnownVars = tmpMeta99;
          _b1 = tmp101  /* pattern as ty=Boolean */;
          _b2 = tmp103  /* pattern as ty=Boolean */;
          _ilst = tmpMeta104;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta106 = omc_BackendVariable_getVar(threadData, _cr, _vars, &tmpMeta105);
          if (listEmpty(tmpMeta106)) goto goto_2;
          tmpMeta107 = MMC_CAR(tmpMeta106);
          tmpMeta108 = MMC_CDR(tmpMeta106);
          _vlst = tmpMeta105;

          _vlst = listAppend(_ilst, _vlst);
          tmpMeta109 = mmc_mk_box6(0, mmc_mk_boolean(_b), _vars, _globalKnownVars, mmc_mk_boolean(_b1), mmc_mk_boolean(_b2), _vlst);
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = 1 /* true */;
          tmpMeta[0+2] = tmpMeta109;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta110;
          modelica_integer tmp111;
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmp111 = mmc_unbox_integer(tmpMeta110);
          
          _b = tmp111  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _inExp;
          tmp1_c1 = (!_b);
          tmpMeta[0+2] = _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 < 8) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outExp = tmpMeta[0+0];
  _cont = tmp1_c1;
  _outTuple = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_cont) { *out_cont = _cont; }
  if (out_outTuple) { *out_outTuple = _outTuple; }
  return _outExp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_traversingTimeVarsFinder(threadData_t *threadData, modelica_metatype _inExp, modelica_metatype _inTuple, modelica_metatype *out_cont, modelica_metatype *out_outTuple)
{
  modelica_boolean _cont;
  modelica_metatype _outExp = NULL;
  _outExp = omc_RemoveSimpleEquations_traversingTimeVarsFinder(threadData, _inExp, _inTuple, &_cont, out_outTuple);
  /* skip box _outExp; DAE.Exp */
  if (out_cont) { *out_cont = mmc_mk_icon(_cont); }
  /* skip box _outTuple; tuple<#Boolean, BackendDAE.Variables, BackendDAE.Variables, #Boolean, #Boolean, list<#Integer>> */
  return _outExp;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_RemoveSimpleEquations_toplevelInputOrUnfixed(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  _b = ((omc_BackendVariable_isVarOnTopLevelAndInput(threadData, _inVar) || omc_BackendVariable_varUnreplaceable(threadData, _inVar)) || (omc_BackendVariable_isParam(threadData, _inVar) && (!omc_BackendVariable_varFixed(threadData, _inVar))));
  _return: OMC_LABEL_UNUSED
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_toplevelInputOrUnfixed(threadData_t *threadData, modelica_metatype _inVar)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_RemoveSimpleEquations_toplevelInputOrUnfixed(threadData, _inVar);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _selfCalled;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _ilst = NULL;
      modelica_metatype _vlst = NULL;
      modelica_metatype _tree = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e2 has no default value.
      // _ty has no default value.
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _ilst has no default value.
      // _vlst has no default value.
      // _tree has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          
          _vars = tmpMeta6;
          _globalKnownVars = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta14 = mmc_mk_box6(0, mmc_mk_boolean(0 /* false */), _vars, _globalKnownVars, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), tmpMeta13);
          omc_Expression_traverseExpTopDown(threadData, _exp, boxvar_RemoveSimpleEquations_traversingTimeVarsFinder, tmpMeta14, &tmpMeta9);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          if (0 /* false */ != tmp11) goto goto_2;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 6));
          _ilst = tmpMeta12;

          _tree = omc_AvlSetInt_new(threadData);

          _tree = omc_AvlSetInt_addList(threadData, _tree, _ilst);

          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          _ilst = omc_AvlSetInt_listKeys(threadData, _tree, tmpMeta15);

          _vlst = omc_List_map1r(threadData, _ilst, boxvar_BackendVariable_getVarAt, _vars);

          _ty = omc_Expression_typeof(threadData, _exp);

          _e2 = omc_Expression_makeConstZero(threadData, _ty);
          tmpMeta1 = omc_RemoveSimpleEquations_solveTimeIndependentAcausal(threadData, _vlst, _ilst, _exp, _e2, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 1: {
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _ty = omc_Expression_typeof(threadData, _exp);

          _e2 = omc_Expression_makeConstZero(threadData, _ty);
          tmpMeta1 = omc_RemoveSimpleEquations_generateEquation(threadData, _exp, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData, _exp, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _selfCalled;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _ty = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _globalKnownVars = NULL;
      modelica_metatype _ilst = NULL;
      modelica_metatype _vlst = NULL;
      modelica_metatype _tree = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _ty has no default value.
      // _vars has no default value.
      // _globalKnownVars has no default value.
      // _ilst has no default value.
      // _vlst has no default value.
      // _tree has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          
          _vars = tmpMeta6;
          _globalKnownVars = tmpMeta8;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta14 = mmc_mk_box6(0, mmc_mk_boolean(0 /* false */), _vars, _globalKnownVars, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), tmpMeta13);
          omc_Expression_traverseExpTopDown(threadData, _lhs, boxvar_RemoveSimpleEquations_traversingTimeVarsFinder, tmpMeta14, &tmpMeta9);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          if (0 /* false */ != tmp11) goto goto_2;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 6));
          _ilst = tmpMeta12;

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta19 = mmc_mk_box6(0, mmc_mk_boolean(0 /* false */), _vars, _globalKnownVars, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */), _ilst);
          omc_Expression_traverseExpTopDown(threadData, _rhs, boxvar_RemoveSimpleEquations_traversingTimeVarsFinder, tmpMeta19, &tmpMeta15);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 1));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          if (0 /* false */ != tmp17) goto goto_2;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 6));
          _ilst = tmpMeta18;

          _tree = omc_AvlSetInt_new(threadData);

          _tree = omc_AvlSetInt_addList(threadData, _tree, _ilst);

          tmpMeta20 = MMC_REFSTRUCTLIT(mmc_nil);
          _ilst = omc_AvlSetInt_listKeys(threadData, _tree, tmpMeta20);

          _vlst = omc_List_map1r(threadData, _ilst, boxvar_BackendVariable_getVarAt, _vars);
          tmpMeta1 = omc_RemoveSimpleEquations_solveTimeIndependentAcausal(threadData, _vlst, _ilst, _lhs, _rhs, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 1: {
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _ty = omc_Expression_typeof(threadData, _lhs);
          tmpMeta1 = omc_RemoveSimpleEquations_generateEquation(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData, _lhs, _rhs, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC void omc_RemoveSimpleEquations_checkEqualAlias(threadData_t *threadData, modelica_boolean _equal, modelica_metatype _v1, modelica_boolean _negatedCr1, modelica_metatype _v2, modelica_boolean _negatedCr2, modelica_metatype _eqnAttributes)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* match expression */
    modelica_boolean tmp3_1;modelica_metatype tmp3_2;modelica_metatype tmp3_3;modelica_metatype tmp3_4;
    tmp3_1 = _equal;
    tmp3_2 = _v1;
    tmp3_3 = _v2;
    tmp3_4 = _eqnAttributes;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _crexp1 = NULL;
      modelica_metatype _crexp2 = NULL;
      modelica_string _eqn_str = NULL;
      modelica_string _var_str = NULL;
      modelica_metatype _info = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _crexp1 has no default value.
      // _crexp2 has no default value.
      // _eqn_str has no default value.
      // _var_str has no default value.
      // _info has no default value.
      // _source has no default value.
      tmp3 = 0;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          if (0 /* false */ != tmp3_1) goto tmp2_end;
          
          /* Pattern matching succeeded */
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (1 /* true */ != tmp3_1) goto tmp2_end;
          tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_2), 2));
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_3), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp3_4), 1));
          
          _cr1 = tmpMeta5;
          _cr2 = tmpMeta6;
          _source = tmpMeta7;
          /* Pattern matching succeeded */
          _var_str = omc_BackendDump_varString(threadData, _v1);

          _crexp1 = omc_Expression_crefExp(threadData, _cr1);

          _crexp2 = omc_Expression_crefExp(threadData, _cr2);

          _crexp1 = omc_RemoveSimpleEquations_negateExpression(threadData, _negatedCr1, _crexp1, _crexp1, _OMC_LIT126);

          _crexp2 = omc_RemoveSimpleEquations_negateExpression(threadData, _negatedCr2, _crexp2, _crexp2, _OMC_LIT126);

          tmpMeta8 = stringAppend(omc_ExpressionBasics_printExpStr(threadData, _crexp1),_OMC_LIT3);
          tmpMeta9 = stringAppend(tmpMeta8,omc_ExpressionBasics_printExpStr(threadData, _crexp2));
          tmpMeta10 = stringAppend(tmpMeta9,_OMC_LIT21);
          _eqn_str = tmpMeta10;

          _info = omc_ElementSource_getElementSourceFileInfo(threadData, _source);

          tmpMeta11 = mmc_mk_cons(_eqn_str, mmc_mk_cons(_var_str, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addSourceMessage(threadData, _OMC_LIT128, tmpMeta11, _info);
          goto goto_1;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      goto_1:;
      MMC_THROW_INTERNAL();
      goto tmp2_done;
      tmp2_done:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return;
}
PROTECTED_FUNCTION_STATIC void boxptr_RemoveSimpleEquations_checkEqualAlias(threadData_t *threadData, modelica_metatype _equal, modelica_metatype _v1, modelica_metatype _negatedCr1, modelica_metatype _v2, modelica_metatype _negatedCr2, modelica_metatype _eqnAttributes)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  tmp1 = mmc_unbox_integer(_equal);
  tmp2 = mmc_unbox_integer(_negatedCr1);
  tmp3 = mmc_unbox_integer(_negatedCr2);
  omc_RemoveSimpleEquations_checkEqualAlias(threadData, tmp1, _v1, tmp2, _v2, tmp3, _eqnAttributes);
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateSimpleContainter(threadData_t *threadData, modelica_metatype _v1, modelica_boolean _negatedCr1, modelica_integer _i1, modelica_boolean _varskn1, modelica_metatype _v2, modelica_boolean _negatedCr2, modelica_integer _i2, modelica_boolean _varskn2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_integer _iIndex, modelica_metatype _iMT, modelica_integer *out_oIndex, modelica_metatype *out_oMT)
{
  modelica_metatype _oSeqns = NULL;
  modelica_integer _oIndex;
  modelica_metatype _oMT = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSeqns has no default value.
  // _oIndex has no default value.
  // _oMT has no default value.
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_boolean tmp4_2;modelica_metatype tmp4_3;modelica_boolean tmp4_4;modelica_metatype tmp4_5;
    tmp4_1 = _v1;
    tmp4_2 = _varskn1;
    tmp4_3 = _v2;
    tmp4_4 = _varskn2;
    tmp4_5 = _eqnAttributes;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _colum = NULL;
      modelica_metatype _crexp1 = NULL;
      modelica_metatype _crexp2 = NULL;
      modelica_string _lhs = NULL;
      modelica_string _rhs = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr1 has no default value.
      // _cr2 has no default value.
      // _colum has no default value.
      // _crexp1 has no default value.
      // _crexp2 has no default value.
      // _lhs has no default value.
      // _rhs has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (0 /* false */ != tmp4_4) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _cr1 = tmpMeta6;
          _cr2 = tmpMeta7;
          /* Pattern matching succeeded */
          omc_RemoveSimpleEquations_checkEqualAlias(threadData, (_i1 == _i2), _v1, _negatedCr1, _v2, _negatedCr2, _eqnAttributes);

          _colum = arrayGet(_iMT,_i1) /* DAE.ASUB */;

          tmpMeta8 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i1, tmpMeta8);

          _colum = arrayGet(_iMT,_i2) /* DAE.ASUB */;

          tmpMeta9 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i2, tmpMeta9);
          tmpMeta11 = mmc_mk_box9(3, &RemoveSimpleEquations_SimpleContainer_ALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta10 = mmc_mk_cons(tmpMeta11, _iSeqns);
          tmpMeta[0+0] = tmpMeta10;
          tmp1_c1 = ((modelica_integer) 1) + _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          if (0 /* false */ != tmp4_4) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _cr1 = tmpMeta12;
          _cr2 = tmpMeta13;
          /* Pattern matching succeeded */
          _colum = arrayGet(_iMT,_i2) /* DAE.ASUB */;

          tmpMeta14 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i2, tmpMeta14);
          tmpMeta16 = mmc_mk_box9(4, &RemoveSimpleEquations_SimpleContainer_PARAMETERALIAS__desc, _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta15 = mmc_mk_cons(tmpMeta16, _iSeqns);
          tmpMeta[0+0] = tmpMeta15;
          tmp1_c1 = ((modelica_integer) 1) + _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (1 /* true */ != tmp4_4) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          
          _cr1 = tmpMeta17;
          _cr2 = tmpMeta18;
          /* Pattern matching succeeded */
          _colum = arrayGet(_iMT,_i1) /* DAE.ASUB */;

          tmpMeta19 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i1, tmpMeta19);
          tmpMeta21 = mmc_mk_box9(4, &RemoveSimpleEquations_SimpleContainer_PARAMETERALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta20 = mmc_mk_cons(tmpMeta21, _iSeqns);
          tmpMeta[0+0] = tmpMeta20;
          tmp1_c1 = ((modelica_integer) 1) + _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          if (1 /* true */ != tmp4_4) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_3), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_5), 1));
          
          _cr1 = tmpMeta22;
          _cr2 = tmpMeta23;
          _source = tmpMeta24;
          /* Pattern matching succeeded */
          _crexp1 = omc_Expression_crefExp(threadData, _cr1);

          _crexp2 = omc_Expression_crefExp(threadData, _cr2);

          _crexp1 = omc_RemoveSimpleEquations_negateExpression(threadData, _negatedCr1, _crexp1, _crexp1, _OMC_LIT129);

          _crexp2 = omc_RemoveSimpleEquations_negateExpression(threadData, _negatedCr2, _crexp2, _crexp2, _OMC_LIT129);

          _lhs = omc_ExpressionBasics_printExpStr(threadData, _crexp1);

          _rhs = omc_ExpressionBasics_printExpStr(threadData, _crexp2);

          tmpMeta25 = mmc_mk_cons(_lhs, mmc_mk_cons(_rhs, MMC_REFSTRUCTLIT(mmc_nil)));
          omc_Error_addSourceMessage(threadData, _OMC_LIT100, tmpMeta25, omc_ElementSource_getElementSourceFileInfo(threadData, _source));
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oSeqns = tmpMeta[0+0];
  _oIndex = tmp1_c1;
  _oMT = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_oIndex) { *out_oIndex = _oIndex; }
  if (out_oMT) { *out_oMT = _oMT; }
  return _oSeqns;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_generateSimpleContainter(threadData_t *threadData, modelica_metatype _v1, modelica_metatype _negatedCr1, modelica_metatype _i1, modelica_metatype _varskn1, modelica_metatype _v2, modelica_metatype _negatedCr2, modelica_metatype _i2, modelica_metatype _varskn2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_metatype _iIndex, modelica_metatype _iMT, modelica_metatype *out_oIndex, modelica_metatype *out_oMT)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  modelica_integer tmp7;
  modelica_integer _oIndex;
  modelica_metatype _oSeqns = NULL;
  tmp1 = mmc_unbox_integer(_negatedCr1);
  tmp2 = mmc_unbox_integer(_i1);
  tmp3 = mmc_unbox_integer(_varskn1);
  tmp4 = mmc_unbox_integer(_negatedCr2);
  tmp5 = mmc_unbox_integer(_i2);
  tmp6 = mmc_unbox_integer(_varskn2);
  tmp7 = mmc_unbox_integer(_iIndex);
  _oSeqns = omc_RemoveSimpleEquations_generateSimpleContainter(threadData, _v1, tmp1, tmp2, tmp3, _v2, tmp4, tmp5, tmp6, _eqnAttributes, _iSeqns, tmp7, _iMT, &_oIndex, out_oMT);
  /* skip box _oSeqns; list<RemoveSimpleEquations.SimpleContainer> */
  if (out_oIndex) { *out_oIndex = mmc_mk_icon(_oIndex); }
  /* skip box _oMT; array<list<#Integer>> */
  return _oSeqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateSimpleContainters(threadData_t *threadData, modelica_metatype _vars1, modelica_boolean _negatedCr1, modelica_metatype _ilst1, modelica_boolean _varskn1, modelica_boolean _time1, modelica_metatype _vars2, modelica_boolean _negatedCr2, modelica_metatype _ilst2, modelica_boolean _varskn2, modelica_boolean _time2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_integer _iIndex, modelica_metatype _iMT, modelica_integer *out_oIndex, modelica_metatype *out_oMT)
{
  modelica_metatype _oSeqns = NULL;
  modelica_integer _oIndex;
  modelica_metatype _oMT = NULL;
  modelica_integer tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oSeqns has no default value.
  // _oIndex has no default value.
  // _oMT has no default value.
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;modelica_boolean tmp4_3;modelica_boolean tmp4_4;modelica_metatype tmp4_5;modelica_metatype tmp4_6;modelica_boolean tmp4_7;modelica_boolean tmp4_8;
    tmp4_1 = _vars1;
    tmp4_2 = _ilst1;
    tmp4_3 = _varskn1;
    tmp4_4 = _time1;
    tmp4_5 = _vars2;
    tmp4_6 = _ilst2;
    tmp4_7 = _varskn2;
    tmp4_8 = _time2;
    {
      modelica_metatype _v1 = NULL;
      modelica_metatype _v2 = NULL;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_metatype _vlst1 = NULL;
      modelica_metatype _vlst2 = NULL;
      modelica_metatype _irest1 = NULL;
      modelica_metatype _irest2 = NULL;
      modelica_metatype _colum = NULL;
      modelica_metatype _seqns = NULL;
      modelica_integer _index;
      modelica_metatype _mT = NULL;
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _v1 has no default value.
      // _v2 has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _vlst1 has no default value.
      // _vlst2 has no default value.
      // _irest1 has no default value.
      // _irest2 has no default value.
      // _colum has no default value.
      // _seqns has no default value.
      // _index has no default value.
      // _mT has no default value.
      // _cr1 has no default value.
      // _cr2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (1 /* true */ != tmp4_3) goto tmp3_end;
          if (1 /* true */ != tmp4_4) goto tmp3_end;
          if (0 /* false */ != tmp4_7) goto tmp3_end;
          if (0 /* false */ != tmp4_8) goto tmp3_end;
          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));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta9 = MMC_CAR(tmp4_2);
          tmpMeta10 = MMC_CDR(tmp4_2);
          tmp11 = mmc_unbox_integer(tmpMeta9);
          if (!listEmpty(tmpMeta10)) goto tmp3_end;
          if (listEmpty(tmp4_5)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_5);
          tmpMeta13 = MMC_CDR(tmp4_5);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          if (!listEmpty(tmpMeta13)) goto tmp3_end;
          if (listEmpty(tmp4_6)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_6);
          tmpMeta16 = MMC_CDR(tmp4_6);
          tmp17 = mmc_unbox_integer(tmpMeta15);
          if (!listEmpty(tmpMeta16)) goto tmp3_end;
          _cr1 = tmpMeta8;
          _i1 = tmp11  /* pattern as ty=Integer */;
          _cr2 = tmpMeta14;
          _i2 = tmp17  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _colum = arrayGet(_iMT,_i2) /* DAE.ASUB */;

          tmpMeta18 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i2, tmpMeta18);
          tmpMeta20 = mmc_mk_box9(5, &RemoveSimpleEquations_SimpleContainer_TIMEALIAS__desc, _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta19 = mmc_mk_cons(tmpMeta20, _iSeqns);
          tmpMeta[0+0] = tmpMeta19;
          tmp1_c1 = ((modelica_integer) 1) + _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_integer tmp26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_integer tmp32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          if (0 /* false */ != tmp4_3) goto tmp3_end;
          if (0 /* false */ != tmp4_4) goto tmp3_end;
          if (1 /* true */ != tmp4_7) goto tmp3_end;
          if (1 /* true */ != tmp4_8) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta21 = MMC_CAR(tmp4_1);
          tmpMeta22 = MMC_CDR(tmp4_1);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          if (!listEmpty(tmpMeta22)) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta24 = MMC_CAR(tmp4_2);
          tmpMeta25 = MMC_CDR(tmp4_2);
          tmp26 = mmc_unbox_integer(tmpMeta24);
          if (!listEmpty(tmpMeta25)) goto tmp3_end;
          if (listEmpty(tmp4_5)) goto tmp3_end;
          tmpMeta27 = MMC_CAR(tmp4_5);
          tmpMeta28 = MMC_CDR(tmp4_5);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          if (!listEmpty(tmpMeta28)) goto tmp3_end;
          if (listEmpty(tmp4_6)) goto tmp3_end;
          tmpMeta30 = MMC_CAR(tmp4_6);
          tmpMeta31 = MMC_CDR(tmp4_6);
          tmp32 = mmc_unbox_integer(tmpMeta30);
          if (!listEmpty(tmpMeta31)) goto tmp3_end;
          _cr1 = tmpMeta23;
          _i1 = tmp26  /* pattern as ty=Integer */;
          _cr2 = tmpMeta29;
          _i2 = tmp32  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          _colum = arrayGet(_iMT,_i1) /* DAE.ASUB */;

          tmpMeta33 = mmc_mk_cons(mmc_mk_integer(_iIndex), _colum);
          arrayUpdate(_iMT, _i1, tmpMeta33);
          tmpMeta35 = mmc_mk_box9(5, &RemoveSimpleEquations_SimpleContainer_TIMEALIAS__desc, _cr1, mmc_mk_boolean(_negatedCr1), mmc_mk_integer(_i1), _cr2, mmc_mk_boolean(_negatedCr2), mmc_mk_integer(_i2), _eqnAttributes, mmc_mk_integer(((modelica_integer) -1)));
          tmpMeta34 = mmc_mk_cons(tmpMeta35, _iSeqns);
          tmpMeta[0+0] = tmpMeta34;
          tmp1_c1 = ((modelica_integer) 1) + _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 2: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          if (!listEmpty(tmp4_5)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iSeqns;
          tmp1_c1 = _iIndex;
          tmpMeta[0+2] = _iMT;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_integer tmp40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_integer tmp45;
          if (0 /* false */ != tmp4_4) goto tmp3_end;
          if (0 /* false */ != tmp4_8) goto tmp3_end;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta36 = MMC_CAR(tmp4_1);
          tmpMeta37 = MMC_CDR(tmp4_1);
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta38 = MMC_CAR(tmp4_2);
          tmpMeta39 = MMC_CDR(tmp4_2);
          tmp40 = mmc_unbox_integer(tmpMeta38);
          if (listEmpty(tmp4_5)) goto tmp3_end;
          tmpMeta41 = MMC_CAR(tmp4_5);
          tmpMeta42 = MMC_CDR(tmp4_5);
          if (listEmpty(tmp4_6)) goto tmp3_end;
          tmpMeta43 = MMC_CAR(tmp4_6);
          tmpMeta44 = MMC_CDR(tmp4_6);
          tmp45 = mmc_unbox_integer(tmpMeta43);
          
          _v1 = tmpMeta36;
          _vlst1 = tmpMeta37;
          _i1 = tmp40  /* pattern as ty=Integer */;
          _irest1 = tmpMeta39;
          _v2 = tmpMeta41;
          _vlst2 = tmpMeta42;
          _i2 = tmp45  /* pattern as ty=Integer */;
          _irest2 = tmpMeta44;
          /* Pattern matching succeeded */
          _seqns = omc_RemoveSimpleEquations_generateSimpleContainter(threadData, _v1, _negatedCr1, _i1, _varskn1, _v2, _negatedCr2, _i2, _varskn2, _eqnAttributes, _iSeqns, _iIndex, _iMT ,&_index ,&_mT);
          /* Tail recursive call */
          _vars1 = _vlst1;
          _ilst1 = _irest1;
          _vars2 = _vlst2;
          _ilst2 = _irest2;
          _iSeqns = _seqns;
          _iIndex = _index;
          _iMT = _mT;
          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:;
    }
  }
  _oSeqns = tmpMeta[0+0];
  _oIndex = tmp1_c1;
  _oMT = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_oIndex) { *out_oIndex = _oIndex; }
  if (out_oMT) { *out_oMT = _oMT; }
  return _oSeqns;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_generateSimpleContainters(threadData_t *threadData, modelica_metatype _vars1, modelica_metatype _negatedCr1, modelica_metatype _ilst1, modelica_metatype _varskn1, modelica_metatype _time1, modelica_metatype _vars2, modelica_metatype _negatedCr2, modelica_metatype _ilst2, modelica_metatype _varskn2, modelica_metatype _time2, modelica_metatype _eqnAttributes, modelica_metatype _iSeqns, modelica_metatype _iIndex, modelica_metatype _iMT, modelica_metatype *out_oIndex, modelica_metatype *out_oMT)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  modelica_integer tmp7;
  modelica_integer _oIndex;
  modelica_metatype _oSeqns = NULL;
  tmp1 = mmc_unbox_integer(_negatedCr1);
  tmp2 = mmc_unbox_integer(_varskn1);
  tmp3 = mmc_unbox_integer(_time1);
  tmp4 = mmc_unbox_integer(_negatedCr2);
  tmp5 = mmc_unbox_integer(_varskn2);
  tmp6 = mmc_unbox_integer(_time2);
  tmp7 = mmc_unbox_integer(_iIndex);
  _oSeqns = omc_RemoveSimpleEquations_generateSimpleContainters(threadData, _vars1, tmp1, _ilst1, tmp2, tmp3, _vars2, tmp4, _ilst2, tmp5, tmp6, _eqnAttributes, _iSeqns, tmp7, _iMT, &_oIndex, out_oMT);
  /* skip box _oSeqns; list<RemoveSimpleEquations.SimpleContainer> */
  if (out_oIndex) { *out_oIndex = mmc_mk_icon(_oIndex); }
  /* skip box _oMT; array<list<#Integer>> */
  return _oSeqns;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVars(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars, modelica_metatype _shared, modelica_metatype *out_oIndexs, modelica_boolean *out_varskn, modelica_boolean *out_time_)
{
  modelica_metatype _oVars = NULL;
  modelica_metatype _oIndexs = NULL;
  modelica_boolean _varskn;
  modelica_boolean _time_;
  modelica_boolean tmp1_c2 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c3 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oVars has no default value.
  // _oIndexs has no default value.
  // _varskn has no default value.
  // _time_ has no default value.
  
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _cr;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (4 != MMC_STRLEN(tmpMeta6) || strcmp(MMC_STRINGDATA(_OMC_LIT35), MMC_STRINGDATA(tmpMeta6)) != 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta8;
          tmpMeta[0+1] = tmpMeta9;
          tmp1_c2 = 1 /* true */;
          tmp1_c3 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta11 = omc_BackendVariable_getVar(threadData, _cr, _vars, &tmpMeta10);
          if (listEmpty(tmpMeta11)) goto goto_2;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          _oVars = tmpMeta11;
          _oIndexs = tmpMeta10;
          tmpMeta[0+0] = _oVars;
          tmpMeta[0+1] = _oIndexs;
          tmp1_c2 = 0 /* false */;
          tmp1_c3 = 0 /* false */;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta15 = omc_BackendVariable_getVarShared(threadData, _cr, _shared, &tmpMeta14);
          if (listEmpty(tmpMeta15)) goto goto_2;
          tmpMeta16 = MMC_CAR(tmpMeta15);
          tmpMeta17 = MMC_CDR(tmpMeta15);
          _oVars = tmpMeta15;
          _oIndexs = tmpMeta14;

          if(omc_ComponentReference_crefIsScalarWithVariableSubs(threadData, _cr))
          {
            tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
            _oVars = tmpMeta18;

            tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
            _oIndexs = tmpMeta19;
          }
          tmpMeta[0+0] = _oVars;
          tmpMeta[0+1] = _oIndexs;
          tmp1_c2 = 1 /* true */;
          tmp1_c3 = 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:;
    }
  }
  _oVars = tmpMeta[0+0];
  _oIndexs = tmpMeta[0+1];
  _varskn = tmp1_c2;
  _time_ = tmp1_c3;
  _return: OMC_LABEL_UNUSED
  if (out_oIndexs) { *out_oIndexs = _oIndexs; }
  if (out_varskn) { *out_varskn = _varskn; }
  if (out_time_) { *out_time_ = _time_; }
  return _oVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_getVars(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars, modelica_metatype _shared, modelica_metatype *out_oIndexs, modelica_metatype *out_varskn, modelica_metatype *out_time_)
{
  modelica_boolean _varskn;
  modelica_boolean _time_;
  modelica_metatype _oVars = NULL;
  _oVars = omc_RemoveSimpleEquations_getVars(threadData, _cr, _vars, _shared, out_oIndexs, &_varskn, &_time_);
  /* skip box _oVars; list<BackendDAE.Var> */
  /* skip box _oIndexs; list<#Integer> */
  if (out_varskn) { *out_varskn = mmc_mk_icon(_varskn); }
  if (out_time_) { *out_time_ = mmc_mk_icon(_time_); }
  return _oVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _inE1, modelica_boolean _negatedCr1, modelica_metatype _cr2, modelica_metatype _inE2, modelica_boolean _negatedCr2, modelica_metatype _eqnAttributes, modelica_boolean _genEqn, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_boolean tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _genEqn;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _shared = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _seqns = NULL;
      modelica_integer _index;
      modelica_metatype _mT = NULL;
      modelica_metatype _vars1 = NULL;
      modelica_metatype _vars2 = NULL;
      modelica_metatype _ilst1 = NULL;
      modelica_metatype _ilst2 = NULL;
      modelica_boolean _varskn1;
      modelica_boolean _varskn2;
      modelica_boolean _time1;
      modelica_boolean _time2;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _shared has no default value.
      // _eqns has no default value.
      // _seqns has no default value.
      // _index has no default value.
      // _mT has no default value.
      // _vars1 has no default value.
      // _vars2 has no default value.
      // _ilst1 has no default value.
      // _ilst2 has no default value.
      // _varskn1 has no default value.
      // _varskn2 has no default value.
      // _time1 has no default value.
      // _time2 has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _ty has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_boolean tmp17;
          modelica_metatype tmpMeta18;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          
          _vars = tmpMeta6;
          _shared = tmpMeta7;
          _eqns = tmpMeta8;
          _seqns = tmpMeta9;
          _index = tmp11  /* pattern as ty=Integer */;
          _mT = tmpMeta12;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            tmpMeta13 = stringAppend(_OMC_LIT131,(_negatedCr1?_OMC_LIT132:_OMC_LIT133));
            tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT134);
            tmpMeta15 = stringAppend(tmpMeta14,(_negatedCr2?_OMC_LIT132:_OMC_LIT133));
            tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT135);
            omc_BackendDump_debugStrCrefStrCrefStr(threadData, _OMC_LIT130, _cr1, _OMC_LIT3, _cr2, tmpMeta16);
          }

          _vars1 = omc_RemoveSimpleEquations_getVars(threadData, _cr1, _vars, _shared ,&_ilst1 ,&_varskn1 ,&_time1);

          _vars2 = omc_RemoveSimpleEquations_getVars(threadData, _cr2, _vars, _shared ,&_ilst2 ,&_varskn2 ,&_time2);

          /* Pattern-matching assignment */
          tmp17 = (listLength(_vars1) == listLength(_vars2));
          if (1 /* true */ != tmp17) goto goto_2;

          _seqns = omc_RemoveSimpleEquations_generateSimpleContainters(threadData, _vars1, _negatedCr1, _ilst1, _varskn1, _time1, _vars2, _negatedCr2, _ilst2, _varskn2, _time2, _eqnAttributes, _seqns, _index, _mT ,&_index ,&_mT);
          tmpMeta18 = mmc_mk_box7(0, _vars, _shared, _eqns, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(1 /* true */));
          tmpMeta1 = tmpMeta18;
          goto tmp3_done;
        }
        case 1: {
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT136, _inE1, _OMC_LIT3, _inE2, _OMC_LIT137);
          }

          _e1 = omc_Expression_crefExp(threadData, _cr1);

          _ty = omc_Expression_typeof(threadData, _e1);

          _e2 = _inE2;
          tmpMeta1 = omc_RemoveSimpleEquations_generateEquation(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 2) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_addSimpleEquationAcausal(threadData_t *threadData, modelica_metatype _cr1, modelica_metatype _inE1, modelica_metatype _negatedCr1, modelica_metatype _cr2, modelica_metatype _inE2, modelica_metatype _negatedCr2, modelica_metatype _eqnAttributes, modelica_metatype _genEqn, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_negatedCr1);
  tmp2 = mmc_unbox_integer(_negatedCr2);
  tmp3 = mmc_unbox_integer(_genEqn);
  _outTpl = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _inE1, tmp1, _cr2, _inE2, tmp2, _eqnAttributes, tmp3, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, 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;
    tmp4_1 = _exp;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _tp = 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.
      // _tp has no default value.
      tmp4 = 0;
      for (; tmp4 < 17; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,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 */
          tmpMeta12 = mmc_mk_box2(8, &DAE_Operator_UMINUS__desc, _ty);
          tmpMeta13 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta12, _e1);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, tmpMeta13, 0 /* false */, _cr2, _e2, 1 /* true */, _eqnAttributes, _selfCalled, _inTpl);
          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,7,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,6,2) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,7,1) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,6,2) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 2));
          
          _e1 = tmpMeta14;
          _cr1 = tmpMeta15;
          _ty = tmpMeta17;
          _e2 = tmpMeta18;
          _cr2 = tmpMeta19;
          /* Pattern matching succeeded */
          tmpMeta20 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta21 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta20, _e1);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, tmpMeta21, 0 /* false */, _cr2, _e2, 1 /* true */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,6,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,1,1) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,6,2) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          
          _e1 = tmpMeta22;
          _cr1 = tmpMeta23;
          _e2 = tmpMeta25;
          _cr2 = tmpMeta26;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,6,2) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,8,1) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta30,6,2) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta30), 2));
          
          _e1 = tmpMeta27;
          _cr1 = tmpMeta28;
          _e2 = tmpMeta30;
          _cr2 = tmpMeta31;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,8,2) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta33,5,1) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,6,2) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta34), 2));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta36,0,1) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,6,2) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta37), 2));
          
          _e1 = tmpMeta34;
          _cr1 = tmpMeta35;
          _e2 = tmpMeta37;
          _cr2 = tmpMeta38;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 5: {
          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,7,3) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,8,2) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta40,6,1) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta41,6,2) == 0) goto tmp3_end;
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta41), 2));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta43,7,1) == 0) goto tmp3_end;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta44,6,2) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta44), 2));
          
          _e1 = tmpMeta41;
          _cr1 = tmpMeta42;
          _e2 = tmpMeta44;
          _cr2 = tmpMeta45;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          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;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 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,6,2) == 0) goto tmp3_end;
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta48), 2));
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta50,1,1) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta50), 2));
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta52,6,2) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta52), 2));
          
          _e1 = tmpMeta46;
          _cr1 = tmpMeta49;
          _ty = tmpMeta51;
          _e2 = tmpMeta52;
          _cr2 = tmpMeta53;
          /* Pattern matching succeeded */
          tmpMeta54 = mmc_mk_box2(8, &DAE_Operator_UMINUS__desc, _ty);
          tmpMeta55 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta54, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 1 /* true */, _cr2, tmpMeta55, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta56,8,2) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta57,6,1) == 0) goto tmp3_end;
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta58,6,2) == 0) goto tmp3_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta58), 2));
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta60,8,1) == 0) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 2));
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta62,6,2) == 0) goto tmp3_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta62), 2));
          
          _e1 = tmpMeta56;
          _cr1 = tmpMeta59;
          _ty = tmpMeta61;
          _e2 = tmpMeta62;
          _cr2 = tmpMeta63;
          /* Pattern matching succeeded */
          tmpMeta64 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta65 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta64, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 1 /* true */, _cr2, tmpMeta65, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta66,6,2) == 0) goto tmp3_end;
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta67,7,1) == 0) goto tmp3_end;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta67), 2));
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta69,16,3) == 0) goto tmp3_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 2));
          
          _e1 = tmpMeta66;
          _tp = tmpMeta68;
          _e2 = tmpMeta69;
          _ty = tmpMeta70;
          /* Pattern matching succeeded */
          tmpMeta71 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _tp);
          tmpMeta72 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta71, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, tmpMeta72, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta73,6,2) == 0) goto tmp3_end;
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta74,7,1) == 0) goto tmp3_end;
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta74), 2));
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta76,17,3) == 0) goto tmp3_end;
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta76), 2));
          
          _e1 = tmpMeta73;
          _tp = tmpMeta75;
          _e2 = tmpMeta76;
          _ty = tmpMeta77;
          /* Pattern matching succeeded */
          tmpMeta78 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _tp);
          tmpMeta79 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta78, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, tmpMeta79, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta80,6,2) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta81,8,1) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta82,16,3) == 0) goto tmp3_end;
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta82), 2));
          
          _e1 = tmpMeta80;
          _e2 = tmpMeta82;
          _ty = tmpMeta83;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta84,6,2) == 0) goto tmp3_end;
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta85,8,1) == 0) goto tmp3_end;
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta86,17,3) == 0) goto tmp3_end;
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 2));
          
          _e1 = tmpMeta84;
          _e2 = tmpMeta86;
          _ty = tmpMeta87;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta88 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta88,8,2) == 0) goto tmp3_end;
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta88), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta89,6,1) == 0) goto tmp3_end;
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta88), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta90,6,2) == 0) goto tmp3_end;
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta91,7,1) == 0) goto tmp3_end;
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta92,16,3) == 0) goto tmp3_end;
          tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 2));
          
          _e1 = tmpMeta90;
          _e2 = tmpMeta92;
          _ty = tmpMeta93;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta94,8,2) == 0) goto tmp3_end;
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta94), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta95,6,1) == 0) goto tmp3_end;
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta94), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta96,6,2) == 0) goto tmp3_end;
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta97,7,1) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta98,17,3) == 0) goto tmp3_end;
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta98), 2));
          
          _e1 = tmpMeta96;
          _e2 = tmpMeta98;
          _ty = tmpMeta99;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 14: {
          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,7,3) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta100,8,2) == 0) goto tmp3_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta100), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta101,6,1) == 0) goto tmp3_end;
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta100), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta102,6,2) == 0) goto tmp3_end;
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta103,8,1) == 0) goto tmp3_end;
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta104,16,3) == 0) goto tmp3_end;
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 2));
          
          _e1 = tmpMeta100;
          _e2 = tmpMeta104;
          _ty = tmpMeta105;
          /* Pattern matching succeeded */
          tmpMeta106 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta107 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta106, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, tmpMeta107, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          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(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta111,8,1) == 0) goto tmp3_end;
          tmpMeta112 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta112,17,3) == 0) goto tmp3_end;
          tmpMeta113 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 2));
          
          _e1 = tmpMeta108;
          _e2 = tmpMeta112;
          _ty = tmpMeta113;
          /* Pattern matching succeeded */
          tmpMeta114 = mmc_mk_box2(9, &DAE_Operator_UMINUS__ARR__desc, _ty);
          tmpMeta115 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, tmpMeta114, _e2);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, tmpMeta115, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 16: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_timeIndependentExpressionAcausal(threadData, _exp, _eqnAttributes, _selfCalled, _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
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleExpressionAcausal(threadData_t *threadData, modelica_metatype _exp, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData, _exp, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_generateEquation(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _ty, modelica_metatype _eqnAttributes, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _eqnAttributes;
    tmp4_2 = _inTpl;
    {
      modelica_integer _size;
      modelica_metatype _dims = NULL;
      modelica_metatype _tp = NULL;
      modelica_metatype _ds = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _s = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _seqns = NULL;
      modelica_integer _index;
      modelica_metatype _recordSize = NULL;
      modelica_metatype _mT = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      modelica_boolean _b2;
      modelica_metatype _source = NULL;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _size has no default value.
      // _dims has no default value.
      // _tp has no default value.
      // _ds has no default value.
      // _v has no default value.
      // _s has no default value.
      // _eqns has no default value.
      // _seqns has no default value.
      // _index has no default value.
      // _recordSize has no default value.
      // _mT has no default value.
      // _b has no default value.
      // _b1 has no default value.
      // _b2 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 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          _source = tmpMeta6;
          _eqAttr = tmpMeta7;
          _v = tmpMeta8;
          _s = tmpMeta9;
          _eqns = tmpMeta10;
          _seqns = tmpMeta11;
          _index = tmp13  /* pattern as ty=Integer */;
          _mT = tmpMeta14;
          _b = tmp16  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_DAEUtil_expTypeComplex(threadData, _ty)) goto tmp3_end;
          _size = omc_Expression_sizeOf(threadData, _ty);
          tmpMeta18 = mmc_mk_box6(9, &BackendDAE_Equation_COMPLEX__EQUATION__desc, mmc_mk_integer(_size), _lhs, _rhs, _source, _eqAttr);
          tmpMeta17 = mmc_mk_cons(tmpMeta18, _eqns);
          tmpMeta19 = mmc_mk_box7(0, _v, _s, tmpMeta17, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(_b));
          tmpMeta1 = tmpMeta19;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp27 = mmc_unbox_integer(tmpMeta26);
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          _source = tmpMeta20;
          _eqAttr = tmpMeta21;
          _v = tmpMeta22;
          _s = tmpMeta23;
          _eqns = tmpMeta24;
          _seqns = tmpMeta25;
          _index = tmp27  /* pattern as ty=Integer */;
          _mT = tmpMeta28;
          _b = tmp30  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_DAEUtil_expTypeArray(threadData, _ty)) goto tmp3_end;
          _dims = omc_Expression_arrayDimension(threadData, _ty);

          _ds = omc_Expression_dimensionsSizes(threadData, _dims);

          _tp = omc_DAEUtil_expTypeElementType(threadData, _ty);

          if(omc_DAEUtil_expTypeComplex(threadData, _tp))
          {
            _recordSize = mmc_mk_some(mmc_mk_integer(omc_Expression_sizeOf(threadData, _tp)));
          }
          else
          {
            _recordSize = mmc_mk_none();
          }
          tmpMeta32 = mmc_mk_box7(4, &BackendDAE_Equation_ARRAY__EQUATION__desc, _ds, _lhs, _rhs, _source, _eqAttr, _recordSize);
          tmpMeta31 = mmc_mk_cons(tmpMeta32, _eqns);
          tmpMeta33 = mmc_mk_box7(0, _v, _s, tmpMeta31, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(_b));
          tmpMeta1 = tmpMeta33;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_integer tmp41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_integer tmp44;
          modelica_boolean tmp45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 1));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp41 = mmc_unbox_integer(tmpMeta40);
          tmpMeta42 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmpMeta43 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp44 = mmc_unbox_integer(tmpMeta43);
          _source = tmpMeta34;
          _eqAttr = tmpMeta35;
          _v = tmpMeta36;
          _s = tmpMeta37;
          _eqns = tmpMeta38;
          _seqns = tmpMeta39;
          _index = tmp41  /* pattern as ty=Integer */;
          _mT = tmpMeta42;
          _b = tmp44  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          _b1 = omc_DAEUtil_expTypeComplex(threadData, _ty);

          _b2 = omc_DAEUtil_expTypeArray(threadData, _ty);

          /* Pattern-matching assignment */
          tmp45 = (_b1 || _b2);
          if (0 /* false */ != tmp45) goto goto_2;
          tmpMeta47 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, _lhs, _rhs, _source, _eqAttr);
          tmpMeta46 = mmc_mk_cons(tmpMeta47, _eqns);
          tmpMeta48 = mmc_mk_box7(0, _v, _s, tmpMeta46, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(_b));
          tmpMeta1 = tmpMeta48;
          goto tmp3_done;
        }
        case 3: {
          modelica_boolean tmp49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp49 = omc_Flags_isSet(threadData, _OMC_LIT140);
          if (1 /* true */ != tmp49) goto goto_2;

          tmpMeta50 = stringAppend(_OMC_LIT141,omc_ExpressionBasics_printExpStr(threadData, _lhs));
          tmpMeta51 = stringAppend(tmpMeta50,_OMC_LIT3);
          tmpMeta52 = stringAppend(tmpMeta51,omc_ExpressionBasics_printExpStr(threadData, _rhs));
          tmpMeta53 = stringAppend(tmpMeta52,_OMC_LIT21);
          omc_Debug_traceln(threadData, tmpMeta53);
          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 < 4) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausal1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile 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;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 6; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          
          /* Pattern matching succeeded */
          _elst1 = omc_Expression_splitRecord(threadData, _lhs, omc_Expression_typeof(threadData, _lhs));

          _elst2 = omc_Expression_splitRecord(threadData, _rhs, omc_Expression_typeof(threadData, _rhs));
          tmpMeta1 = omc_List_threadFold2(threadData, _elst1, _elst2, boxvar_RemoveSimpleEquations_simpleEquationAcausal, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
          goto tmp3_done;
        }
        case 1: {
          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_fold2(threadData, _elst1, boxvar_RemoveSimpleEquations_simpleExpressionAcausal, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
          goto tmp3_done;
        }
        case 2: {
          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_fold2(threadData, _elst2, boxvar_RemoveSimpleEquations_simpleExpressionAcausal, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _rhs)) goto tmp3_end;
          tmpMeta1 = omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData, _lhs, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_Expression_isZero(threadData, _lhs)) goto tmp3_end;
          tmpMeta1 = omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData, _rhs, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 5: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_timeIndependentEquationAcausal(threadData, _lhs, _rhs, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 6) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausal1(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_simpleEquationAcausal1(threadData, _lhs, _rhs, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausalLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  _outTpl = omc_List_threadFold2(threadData, _elst1, _elst2, boxvar_RemoveSimpleEquations_simpleEquationAcausal, _eqnAttributes, mmc_mk_boolean(_selfCalled), _inTpl);
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausalLst(threadData_t *threadData, modelica_metatype _elst1, modelica_metatype _elst2, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_simpleEquationAcausalLst(threadData, _elst1, _elst2, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

static modelica_metatype closure5_Expression_applyExpSubscriptsFoldCheckSimplify(threadData_t *thData, modelica_metatype closure, modelica_metatype inSubs, modelica_metatype $in_checkSimplify, modelica_metatype tmp17)
{
  modelica_metatype $in_exp = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_applyExpSubscriptsFoldCheckSimplify(thData, $in_exp, inSubs, $in_checkSimplify, tmp17);
}static modelica_metatype closure6_Expression_applyExpSubscriptsFoldCheckSimplify(threadData_t *thData, modelica_metatype closure, modelica_metatype inSubs, modelica_metatype $in_checkSimplify, modelica_metatype tmp22)
{
  modelica_metatype $in_exp = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_Expression_applyExpSubscriptsFoldCheckSimplify(thData, $in_exp, inSubs, $in_checkSimplify, tmp22);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _ty, modelica_metatype _eqnAttributes, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _dims = NULL;
  modelica_metatype _ds = NULL;
  modelica_metatype _subslst = NULL;
  modelica_metatype _elst1 = NULL;
  modelica_metatype _elst2 = NULL;
  modelica_boolean _hasInlineAfterIndexReduction;
  modelica_boolean _expandLhs;
  modelica_boolean _expandRhs;
  modelica_metatype _source = NULL;
  modelica_metatype _attr = NULL;
  modelica_metatype _eq = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_integer tmp12;
  modelica_metatype tmpMeta13;
  modelica_integer tmp14;
  modelica_metatype tmpMeta15;
  modelica_integer tmp16;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_integer tmp21;
  modelica_metatype tmpMeta23;
  modelica_metatype tmpMeta24;
  modelica_boolean tmp25;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _dims has no default value.
  // _ds has no default value.
  // _subslst has no default value.
  // _elst1 has no default value.
  // _elst2 has no default value.
  // _hasInlineAfterIndexReduction has no default value.
  // _expandLhs has no default value.
  // _expandRhs has no default value.
  // _source has no default value.
  // _attr has no default value.
  // _eq has no default value.
  _dims = omc_Expression_arrayDimension(threadData, _ty);

  _ds = omc_Expression_dimensionsSizes(threadData, _dims);

  _subslst = omc_List_map(threadData, _ds, boxvar_Expression_dimensionSizeSubscripts);

  _subslst = omc_Expression_rangesToSubscripts(threadData, _subslst);

  if(listEmpty(_subslst))
  {
    /* Pattern-matching assignment */
    tmpMeta1 = _eqnAttributes;
    tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
    tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
    _source = tmpMeta2;
    _attr = tmpMeta3;

    _outTpl = _inTpl;

    goto _return;

    tmpMeta10 = mmc_mk_cons(_lhs, mmc_mk_cons(_rhs, MMC_REFSTRUCTLIT(mmc_nil)));
    {
      modelica_metatype _e;
      for (tmpMeta4 = tmpMeta10; !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
      {
        _e = MMC_CAR(tmpMeta4);
        if(omc_Expression_isEvaluatedConst(threadData, _e))
        {
          continue;
        }

        tmpMeta6 = mmc_mk_box5(5, &BackendDAE_WhenOperator_ASSERT__desc, _OMC_LIT142, _OMC_LIT144, _OMC_LIT149, _source);
        tmpMeta5 = mmc_mk_cons(tmpMeta6, MMC_REFSTRUCTLIT(mmc_nil));
        tmpMeta7 = mmc_mk_box4(3, &BackendDAE_WhenEquation_WHEN__STMTS__desc, _OMC_LIT142, tmpMeta5, mmc_mk_none());
        tmpMeta8 = mmc_mk_box5(8, &BackendDAE_Equation_WHEN__EQUATION__desc, mmc_mk_integer(((modelica_integer) 0)), tmpMeta7, _source, _attr);
        _eq = tmpMeta8;

        _outTpl = omc_RemoveSimpleEquations_simpleEquationsFinder(threadData, _eq, _outTpl);
      }
    }

    goto _return;
  }

  /* Pattern-matching tuple assignment, wild first pattern */
  omc_Expression_traverseExpTopDown(threadData, _lhs, boxvar_Expression_findCallIsInlineAfterIndexReduction, mmc_mk_boolean(0 /* false */), &tmpMeta11);
  tmp12 = mmc_unbox_integer(tmpMeta11);
  _hasInlineAfterIndexReduction = tmp12  /* pattern as ty=Boolean */;

  /* Pattern-matching tuple assignment, wild first pattern */
  omc_Expression_traverseExpTopDown(threadData, _rhs, boxvar_Expression_findCallIsInlineAfterIndexReduction, mmc_mk_boolean(_hasInlineAfterIndexReduction), &tmpMeta13);
  tmp14 = mmc_unbox_integer(tmpMeta13);
  _hasInlineAfterIndexReduction = tmp14  /* pattern as ty=Boolean */;

  /* Pattern-matching tuple assignment */
  tmpMeta18 = mmc_mk_box1(0, _lhs);
  tmpMeta19 = omc_List_mapFold(threadData, _subslst, (modelica_fnptr) mmc_mk_box2(0,closure5_Expression_applyExpSubscriptsFoldCheckSimplify,tmpMeta18), mmc_mk_boolean(0 /* false */), &tmpMeta15);
  _elst1 = tmpMeta19;
  tmp16 = mmc_unbox_integer(tmpMeta15);
  _expandLhs = tmp16  /* pattern as ty=Boolean */;

  /* Pattern-matching tuple assignment */
  tmpMeta23 = mmc_mk_box1(0, _rhs);
  tmpMeta24 = omc_List_mapFold(threadData, _subslst, (modelica_fnptr) mmc_mk_box2(0,closure6_Expression_applyExpSubscriptsFoldCheckSimplify,tmpMeta23), mmc_mk_boolean(0 /* false */), &tmpMeta20);
  _elst2 = tmpMeta24;
  tmp21 = mmc_unbox_integer(tmpMeta20);
  _expandRhs = tmp21  /* pattern as ty=Boolean */;

  if((!_hasInlineAfterIndexReduction))
  {
    /* Pattern-matching assignment */
    tmp25 = (_expandLhs && _expandRhs);
    if (1 /* true */ != tmp25) MMC_THROW_INTERNAL();
  }

  _outTpl = omc_List_threadFold2(threadData, _elst1, _elst2, boxvar_RemoveSimpleEquations_simpleEquationAcausal, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_boolean _selfCalled, 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 = _lhs;
    tmp4_2 = _rhs;
    {
      modelica_metatype _cr1 = NULL;
      modelica_metatype _cr2 = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _ty = NULL;
      modelica_metatype _elst1 = NULL;
      modelica_metatype _elst2 = NULL;
      modelica_metatype _elstlst1 = NULL;
      modelica_metatype _elstlst2 = NULL;
      modelica_metatype _op = 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.
      // _elst1 has no default value.
      // _elst2 has no default value.
      // _elstlst1 has no default value.
      // _elstlst2 has no default value.
      // _op has no default value.
      tmp4 = 0;
      for (; tmp4 < 41; 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(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 */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _lhs, 0 /* false */, _cr2, _rhs, 0 /* false */, _eqnAttributes, _selfCalled, _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));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,5,1) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,6,2) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _cr1 = tmpMeta8;
          _op = tmpMeta9;
          _cr2 = tmpMeta11;
          /* Pattern matching succeeded */
          tmpMeta12 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _lhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, tmpMeta12, 0 /* false */, _cr2, _rhs, 1 /* true */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,6,1) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,6,2) == 0) goto tmp3_end;
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          
          _cr1 = tmpMeta13;
          _op = tmpMeta14;
          _cr2 = tmpMeta16;
          /* Pattern matching succeeded */
          tmpMeta17 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _lhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, tmpMeta17, 0 /* false */, _cr2, _rhs, 1 /* true */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta19,5,1) == 0) goto tmp3_end;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,6,2) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta20), 2));
          
          _cr2 = tmpMeta18;
          _op = tmpMeta19;
          _cr1 = tmpMeta21;
          /* Pattern matching succeeded */
          tmpMeta22 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _rhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _lhs, 1 /* true */, _cr2, tmpMeta22, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta24,6,1) == 0) goto tmp3_end;
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,6,2) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          
          _cr2 = tmpMeta23;
          _op = tmpMeta24;
          _cr1 = tmpMeta26;
          /* Pattern matching succeeded */
          tmpMeta27 = mmc_mk_box3(11, &DAE_Exp_UNARY__desc, _op, _rhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _lhs, 1 /* true */, _cr2, tmpMeta27, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta28,5,1) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta29,6,2) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta29), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta31,5,1) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta32,6,2) == 0) goto tmp3_end;
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta32), 2));
          
          _e1 = tmpMeta29;
          _cr1 = tmpMeta30;
          _e2 = tmpMeta32;
          _cr2 = tmpMeta33;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta34,6,1) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,6,2) == 0) goto tmp3_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta37,6,1) == 0) goto tmp3_end;
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta38,6,2) == 0) goto tmp3_end;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          
          _e1 = tmpMeta35;
          _cr1 = tmpMeta36;
          _e2 = tmpMeta38;
          _cr2 = tmpMeta39;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta41,24,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));
          
          _cr1 = tmpMeta40;
          _op = tmpMeta41;
          _cr2 = tmpMeta43;
          /* Pattern matching succeeded */
          tmpMeta44 = mmc_mk_box3(13, &DAE_Exp_LUNARY__desc, _op, _lhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, tmpMeta44, 0 /* false */, _cr2, _rhs, 1 /* true */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta46,24,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));
          
          _cr2 = tmpMeta45;
          _op = tmpMeta46;
          _cr1 = tmpMeta48;
          /* Pattern matching succeeded */
          tmpMeta49 = mmc_mk_box3(13, &DAE_Exp_LUNARY__desc, _op, _lhs);
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _lhs, 1 /* true */, _cr2, tmpMeta49, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta50,24,1) == 0) goto tmp3_end;
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta51,6,2) == 0) goto tmp3_end;
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta51), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta53,24,1) == 0) goto tmp3_end;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta54,6,2) == 0) goto tmp3_end;
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta54), 2));
          
          _e1 = tmpMeta51;
          _cr1 = tmpMeta52;
          _e2 = tmpMeta54;
          _cr2 = tmpMeta55;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_addSimpleEquationAcausal(threadData, _cr1, _e1, 0 /* false */, _cr2, _e2, 0 /* false */, _eqnAttributes, _selfCalled, _inTpl);
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _elst1 = tmpMeta56;
          _elst2 = tmpMeta57;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_threadFold2(threadData, _elst1, _elst2, boxvar_RemoveSimpleEquations_simpleEquationAcausal, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,3) == 0) goto tmp3_end;
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,17,3) == 0) goto tmp3_end;
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _elstlst1 = tmpMeta58;
          _elstlst2 = tmpMeta59;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_List_threadFold2(threadData, _elstlst1, _elstlst2, boxvar_RemoveSimpleEquations_simpleEquationAcausalLst, _eqnAttributes, mmc_mk_boolean(1 /* true */), _inTpl);
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta60;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta60 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _ty = tmpMeta60;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta61;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,17,3) == 0) goto tmp3_end;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _ty = tmpMeta61;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta63,6,1) == 0) goto tmp3_end;
          tmpMeta64 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta64,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta62;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,17,3) == 0) goto tmp3_end;
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta66,6,1) == 0) goto tmp3_end;
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta67,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta65;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta68,6,1) == 0) goto tmp3_end;
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta69,16,3) == 0) goto tmp3_end;
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta69), 2));
          
          _ty = tmpMeta70;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta71,6,1) == 0) goto tmp3_end;
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta72,17,3) == 0) goto tmp3_end;
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta72), 2));
          
          _ty = tmpMeta73;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta74,6,1) == 0) goto tmp3_end;
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta75,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta76 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta76,6,1) == 0) goto tmp3_end;
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta77,16,3) == 0) goto tmp3_end;
          tmpMeta78 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta77), 2));
          
          _e1 = tmpMeta75;
          _e2 = tmpMeta77;
          _ty = tmpMeta78;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 19: {
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta79,6,1) == 0) goto tmp3_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta80,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta81,6,1) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta82,17,3) == 0) goto tmp3_end;
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta82), 2));
          
          _e1 = tmpMeta80;
          _e2 = tmpMeta82;
          _ty = tmpMeta83;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 20: {
          modelica_metatype tmpMeta84;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta84;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 21: {
          modelica_metatype tmpMeta85;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,3) == 0) goto tmp3_end;
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta85;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 22: {
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta86,6,1) == 0) goto tmp3_end;
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta87,16,3) == 0) goto tmp3_end;
          tmpMeta88 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta87), 2));
          
          _ty = tmpMeta88;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 23: {
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta89,6,1) == 0) goto tmp3_end;
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta90,17,3) == 0) goto tmp3_end;
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta90), 2));
          
          _ty = tmpMeta91;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 24: {
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta93,6,1) == 0) goto tmp3_end;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta94,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta92;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 25: {
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,3) == 0) goto tmp3_end;
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta96,6,1) == 0) goto tmp3_end;
          tmpMeta97 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta97,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta95;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 26: {
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta98,6,1) == 0) goto tmp3_end;
          tmpMeta99 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta99,16,3) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta99), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta101 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta101,6,1) == 0) goto tmp3_end;
          tmpMeta102 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta102,6,2) == 0) goto tmp3_end;
          
          _e1 = tmpMeta99;
          _ty = tmpMeta100;
          _e2 = tmpMeta102;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 27: {
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta103,6,1) == 0) goto tmp3_end;
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta104,17,3) == 0) goto tmp3_end;
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta104), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,8,2) == 0) goto tmp3_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta106,6,1) == 0) goto tmp3_end;
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta107,6,2) == 0) goto tmp3_end;
          
          _e1 = tmpMeta104;
          _ty = tmpMeta105;
          _e2 = tmpMeta107;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 28: {
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,16,3) == 0) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta109 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta109,24,1) == 0) goto tmp3_end;
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta110,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta108;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 29: {
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,17,3) == 0) goto tmp3_end;
          tmpMeta111 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta112 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta112,24,1) == 0) goto tmp3_end;
          tmpMeta113 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta113,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta111;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 30: {
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta114 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta114,24,1) == 0) goto tmp3_end;
          tmpMeta115 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta115,16,3) == 0) goto tmp3_end;
          tmpMeta116 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta115), 2));
          
          _ty = tmpMeta116;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 31: {
          modelica_metatype tmpMeta117;
          modelica_metatype tmpMeta118;
          modelica_metatype tmpMeta119;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta117 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta117,24,1) == 0) goto tmp3_end;
          tmpMeta118 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta118,17,3) == 0) goto tmp3_end;
          tmpMeta119 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta118), 2));
          
          _ty = tmpMeta119;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 32: {
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta120 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta120,24,1) == 0) goto tmp3_end;
          tmpMeta121 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta121,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta122 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta122,24,1) == 0) goto tmp3_end;
          tmpMeta123 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta123,16,3) == 0) goto tmp3_end;
          tmpMeta124 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta123), 2));
          
          _e1 = tmpMeta121;
          _e2 = tmpMeta123;
          _ty = tmpMeta124;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 33: {
          modelica_metatype tmpMeta125;
          modelica_metatype tmpMeta126;
          modelica_metatype tmpMeta127;
          modelica_metatype tmpMeta128;
          modelica_metatype tmpMeta129;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta125 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta125,24,1) == 0) goto tmp3_end;
          tmpMeta126 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta126,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta127 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta127,24,1) == 0) goto tmp3_end;
          tmpMeta128 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta128,17,3) == 0) goto tmp3_end;
          tmpMeta129 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta128), 2));
          
          _e1 = tmpMeta126;
          _e2 = tmpMeta128;
          _ty = tmpMeta129;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 34: {
          modelica_metatype tmpMeta130;
          modelica_metatype tmpMeta131;
          modelica_metatype tmpMeta132;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,16,3) == 0) goto tmp3_end;
          tmpMeta130 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta131 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta131,24,1) == 0) goto tmp3_end;
          tmpMeta132 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta132,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta130;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 35: {
          modelica_metatype tmpMeta133;
          modelica_metatype tmpMeta134;
          modelica_metatype tmpMeta135;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,17,3) == 0) goto tmp3_end;
          tmpMeta133 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta134 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta134,24,1) == 0) goto tmp3_end;
          tmpMeta135 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta135,6,2) == 0) goto tmp3_end;
          
          _ty = tmpMeta133;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 36: {
          modelica_metatype tmpMeta136;
          modelica_metatype tmpMeta137;
          modelica_metatype tmpMeta138;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta136 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta136,24,1) == 0) goto tmp3_end;
          tmpMeta137 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta137,16,3) == 0) goto tmp3_end;
          tmpMeta138 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta137), 2));
          
          _ty = tmpMeta138;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 37: {
          modelica_metatype tmpMeta139;
          modelica_metatype tmpMeta140;
          modelica_metatype tmpMeta141;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,6,2) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta139 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta139,24,1) == 0) goto tmp3_end;
          tmpMeta140 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta140,17,3) == 0) goto tmp3_end;
          tmpMeta141 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta140), 2));
          
          _ty = tmpMeta141;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _lhs, _rhs, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 38: {
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          modelica_metatype tmpMeta144;
          modelica_metatype tmpMeta145;
          modelica_metatype tmpMeta146;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta142 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta142,24,1) == 0) goto tmp3_end;
          tmpMeta143 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta143,16,3) == 0) goto tmp3_end;
          tmpMeta144 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta143), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta145 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta145,24,1) == 0) goto tmp3_end;
          tmpMeta146 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta146,6,2) == 0) goto tmp3_end;
          
          _e1 = tmpMeta143;
          _ty = tmpMeta144;
          _e2 = tmpMeta146;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 39: {
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          modelica_metatype tmpMeta149;
          modelica_metatype tmpMeta150;
          modelica_metatype tmpMeta151;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,10,2) == 0) goto tmp3_end;
          tmpMeta147 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta147,24,1) == 0) goto tmp3_end;
          tmpMeta148 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta148,17,3) == 0) goto tmp3_end;
          tmpMeta149 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta148), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,10,2) == 0) goto tmp3_end;
          tmpMeta150 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta150,24,1) == 0) goto tmp3_end;
          tmpMeta151 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta151,6,2) == 0) goto tmp3_end;
          
          _e1 = tmpMeta148;
          _ty = tmpMeta149;
          _e2 = tmpMeta151;
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, _ty, _eqnAttributes, _inTpl);
          goto tmp3_done;
        }
        case 40: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = omc_RemoveSimpleEquations_simpleEquationAcausal1(threadData, _lhs, _rhs, _eqnAttributes, _selfCalled, _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
  return _outTpl;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_simpleEquationAcausal(threadData_t *threadData, modelica_metatype _lhs, modelica_metatype _rhs, modelica_metatype _eqnAttributes, modelica_metatype _selfCalled, modelica_metatype _inTpl)
{
  modelica_integer tmp1;
  modelica_metatype _outTpl = NULL;
  tmp1 = mmc_unbox_integer(_selfCalled);
  _outTpl = omc_RemoveSimpleEquations_simpleEquationAcausal(threadData, _lhs, _rhs, _eqnAttributes, tmp1, _inTpl);
  /* skip box _outTpl; tuple<BackendDAE.Variables, BackendDAE.Shared, list<BackendDAE.Equation>, list<RemoveSimpleEquations.SimpleContainer>, #Integer, array<list<#Integer>>, #Boolean> */
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_simpleEquationsFinder(threadData_t *threadData, modelica_metatype _eqn, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _eqn;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _e1 = NULL;
      modelica_metatype _e2 = NULL;
      modelica_metatype _source = NULL;
      modelica_metatype _v = NULL;
      modelica_metatype _s = NULL;
      modelica_metatype _eqns = NULL;
      modelica_metatype _seqns = NULL;
      modelica_integer _index;
      modelica_metatype _mT = NULL;
      modelica_boolean _b;
      modelica_metatype _eqAttr = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _e1 has no default value.
      // _e2 has no default value.
      // _source has no default value.
      // _v has no default value.
      // _s has no default value.
      // _eqns has no default value.
      // _seqns has no default value.
      // _index has no default value.
      // _mT has no default value.
      // _b 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 < 6; 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 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT150, _e1, _OMC_LIT3, _e2, _OMC_LIT151);
          }
          tmpMeta10 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleEquationAcausal(threadData, _e1, _e2, tmpMeta10, 0 /* false */, _inTpl);
          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,1,6) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _e1 = tmpMeta11;
          _e2 = tmpMeta12;
          _source = tmpMeta13;
          _eqAttr = tmpMeta14;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT152, _e1, _OMC_LIT3, _e2, _OMC_LIT151);
          }
          tmpMeta15 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleArrayEquationAcausal(threadData, _e1, _e2, omc_Expression_typeof(threadData, _e1), tmpMeta15, _inTpl);
          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,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));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          
          _cr = tmpMeta16;
          _e2 = tmpMeta17;
          _source = tmpMeta18;
          _eqAttr = tmpMeta19;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          _e1 = omc_Expression_crefExp(threadData, _cr);

          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT153, _e1, _OMC_LIT3, _e2, _OMC_LIT151);
          }
          tmpMeta20 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleEquationAcausal(threadData, _e1, _e2, tmpMeta20, 0 /* false */, _inTpl);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,3,3) == 0) goto tmp3_end;
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          
          _e1 = tmpMeta21;
          _source = tmpMeta22;
          _eqAttr = tmpMeta23;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStr(threadData, _OMC_LIT154, _e1, _OMC_LIT151);
          }
          tmpMeta24 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleExpressionAcausal(threadData, _e1, tmpMeta24, 0 /* false */, _inTpl);
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,5) == 0) goto tmp3_end;
          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));
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          
          _e1 = tmpMeta25;
          _e2 = tmpMeta26;
          _source = tmpMeta27;
          _eqAttr = tmpMeta28;
          /* Pattern matching succeeded */
          if(omc_Flags_isSet(threadData, _OMC_LIT24))
          {
            omc_BackendDump_debugStrExpStrExpStr(threadData, _OMC_LIT155, _e1, _OMC_LIT3, _e2, _OMC_LIT151);
          }
          tmpMeta29 = mmc_mk_box2(0, _source, _eqAttr);
          tmpMeta1 = omc_RemoveSimpleEquations_simpleEquationAcausal(threadData, _e1, _e2, tmpMeta29, 0 /* false */, _inTpl);
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_integer tmp38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp38 = mmc_unbox_integer(tmpMeta37);
          _v = tmpMeta30;
          _s = tmpMeta31;
          _eqns = tmpMeta32;
          _seqns = tmpMeta33;
          _index = tmp35  /* pattern as ty=Integer */;
          _mT = tmpMeta36;
          _b = tmp38  /* pattern as ty=Boolean */;
          /* Pattern matching succeeded */
          tmpMeta39 = mmc_mk_cons(_eqn, _eqns);
          tmpMeta40 = mmc_mk_box7(0, _v, _s, tmpMeta39, _seqns, mmc_mk_integer(_index), _mT, mmc_mk_boolean(_b));
          tmpMeta1 = tmpMeta40;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      tmp3_done:
      (void)tmp4;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp3_done2;
      goto_2:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp4 < 6) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder2(threadData_t *threadData, modelica_boolean _b, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _globalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outRepl = NULL;
  modelica_metatype _outUnReplaceable = NULL;
  modelica_metatype _outEqnslst = NULL;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_boolean tmp1_c5 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c6 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[7] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _outShared has no default value.
  // _outRepl has no default value.
  // _outUnReplaceable has no default value.
  // _outEqnslst has no default value.
  // _outGlobalFoundSimple has no default value.
  _warnAliasConflicts = __omcQ_24in_5FwarnAliasConflicts;
  
  
  
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _b;
    tmp4_2 = _iEqnslst;
    {
      modelica_boolean _b1;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _simpleeqnslst = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _shared = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _b1 has no default value.
      // _eqnslst has no default value.
      // _simpleeqnslst has no default value.
      // _vars has no default value.
      // _shared has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = _iGlobalEqnslst;
          tmp1_c5 = _globalFoundSimple;
          tmp1_c6 = _warnAliasConflicts;
          goto tmp3_done;
        }
        case 1: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = listAppend(_iEqnslst, _iGlobalEqnslst);
          tmp1_c5 = _globalFoundSimple;
          tmp1_c6 = _warnAliasConflicts;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta8 = mmc_mk_box7(0, _iVars, _ishared, tmpMeta6, tmpMeta7, mmc_mk_integer(((modelica_integer) 1)), _iMT, mmc_mk_boolean(0 /* false */));
          tmpMeta9 = omc_List_fold(threadData, _iEqnslst, boxvar_RemoveSimpleEquations_simpleEquationsFinder, tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 7));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          _vars = tmpMeta10;
          _shared = tmpMeta11;
          _eqnslst = tmpMeta12;
          _simpleeqnslst = tmpMeta13;
          _b1 = tmp15  /* pattern as ty=Boolean */;
          tmpMeta[0+0] = omc_RemoveSimpleEquations_allCausalFinder1(threadData, _b1, 0 /* false */, _simpleeqnslst, _eqnslst, _vars, _shared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, _globalFoundSimple, _warnAliasConflicts, &tmpMeta[0+1], &tmpMeta[0+2], &tmpMeta[0+3], &tmpMeta[0+4], &tmp1_c5, &tmp1_c6);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVars = tmpMeta[0+0];
  _outShared = tmpMeta[0+1];
  _outRepl = tmpMeta[0+2];
  _outUnReplaceable = tmpMeta[0+3];
  _outEqnslst = tmpMeta[0+4];
  _outGlobalFoundSimple = tmp1_c5;
  _warnAliasConflicts = tmp1_c6;
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outRepl) { *out_outRepl = _outRepl; }
  if (out_outUnReplaceable) { *out_outUnReplaceable = _outUnReplaceable; }
  if (out_outEqnslst) { *out_outEqnslst = _outEqnslst; }
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = _outGlobalFoundSimple; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_allCausalFinder2(threadData_t *threadData, modelica_metatype _b, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _globalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_b);
  tmp2 = mmc_unbox_integer(_globalFoundSimple);
  tmp3 = mmc_unbox_integer(__omcQ_24in_5FwarnAliasConflicts);
  _outVars = omc_RemoveSimpleEquations_allCausalFinder2(threadData, tmp1, _iEqnslst, _iVars, _ishared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, tmp2, tmp3, out_outShared, out_outRepl, out_outUnReplaceable, out_outEqnslst, &_outGlobalFoundSimple, &_warnAliasConflicts);
  /* skip box _outVars; BackendDAE.Variables */
  /* skip box _outShared; BackendDAE.Shared */
  /* skip box _outRepl; BackendVarTransform.VariableReplacements */
  /* skip box _outUnReplaceable; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<DAE.ComponentRef>>>, #Integer, #Integer, tuple<.HashSet.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashSet.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashSet.FuncCrefStr<function>(DAE.ComponentRef cr) => String>> */
  /* skip box _outEqnslst; list<BackendDAE.Equation> */
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = mmc_mk_icon(_outGlobalFoundSimple); }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder1(threadData_t *threadData, modelica_boolean _foundSimple, modelica_boolean _didReplacement, modelica_metatype _iSimpleeqnslst, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _globalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outRepl = NULL;
  modelica_metatype _outUnReplaceable = NULL;
  modelica_metatype _outEqnslst = NULL;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_boolean tmp1_c5 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c6 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[7] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  // _outShared has no default value.
  // _outRepl has no default value.
  // _outUnReplaceable has no default value.
  // _outEqnslst has no default value.
  // _outGlobalFoundSimple has no default value.
  _warnAliasConflicts = __omcQ_24in_5FwarnAliasConflicts;
  
  
  
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _foundSimple;
    tmp4_2 = _iEqnslst;
    {
      modelica_metatype _vars = NULL;
      modelica_metatype _repl = NULL;
      modelica_boolean _b;
      modelica_boolean _b1;
      modelica_metatype _simpleeqns = NULL;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _shared = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _vars has no default value.
      // _repl has no default value.
      // _b has no default value.
      // _b1 has no default value.
      // _simpleeqns has no default value.
      // _eqnslst has no default value.
      // _shared has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          if (!listEmpty(tmp4_2)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = _iGlobalEqnslst;
          tmp1_c5 = (_didReplacement || _globalFoundSimple);
          tmp1_c6 = _warnAliasConflicts;
          goto tmp3_done;
        }
        case 1: {
          if (0 /* false */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = listAppend(_iEqnslst, _iGlobalEqnslst);
          tmp1_c5 = (_didReplacement || _globalFoundSimple);
          tmp1_c6 = _warnAliasConflicts;
          goto tmp3_done;
        }
        case 2: {
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _simpleeqns = omc_List_listArrayReverse(threadData, _iSimpleeqnslst);

          _vars = omc_RemoveSimpleEquations_handleSets(threadData, arrayLength(_simpleeqns), ((modelica_integer) 1), _simpleeqns, _iMT, _iUnreplaceable, _iVars, _iEqnslst, _ishared, _iRepl ,&_eqnslst ,&_shared ,&_repl ,&_b);

          _warnAliasConflicts = (_warnAliasConflicts || _b);

          _eqnslst = omc_BackendVarTransform_replaceEquations(threadData, _eqnslst, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);
          tmpMeta[0+0] = omc_RemoveSimpleEquations_allCausalFinder2(threadData, _b1, _eqnslst, _vars, _shared, _repl, _iUnreplaceable, _iMT, _iGlobalEqnslst, 1 /* true */, _warnAliasConflicts, &tmpMeta[0+1], &tmpMeta[0+2], &tmpMeta[0+3], &tmpMeta[0+4], &tmp1_c5, &tmp1_c6);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVars = tmpMeta[0+0];
  _outShared = tmpMeta[0+1];
  _outRepl = tmpMeta[0+2];
  _outUnReplaceable = tmpMeta[0+3];
  _outEqnslst = tmpMeta[0+4];
  _outGlobalFoundSimple = tmp1_c5;
  _warnAliasConflicts = tmp1_c6;
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outRepl) { *out_outRepl = _outRepl; }
  if (out_outUnReplaceable) { *out_outUnReplaceable = _outUnReplaceable; }
  if (out_outEqnslst) { *out_outEqnslst = _outEqnslst; }
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = _outGlobalFoundSimple; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_allCausalFinder1(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _didReplacement, modelica_metatype _iSimpleeqnslst, modelica_metatype _iEqnslst, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _globalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_foundSimple);
  tmp2 = mmc_unbox_integer(_didReplacement);
  tmp3 = mmc_unbox_integer(_globalFoundSimple);
  tmp4 = mmc_unbox_integer(__omcQ_24in_5FwarnAliasConflicts);
  _outVars = omc_RemoveSimpleEquations_allCausalFinder1(threadData, tmp1, tmp2, _iSimpleeqnslst, _iEqnslst, _iVars, _ishared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, tmp3, tmp4, out_outShared, out_outRepl, out_outUnReplaceable, out_outEqnslst, &_outGlobalFoundSimple, &_warnAliasConflicts);
  /* skip box _outVars; BackendDAE.Variables */
  /* skip box _outShared; BackendDAE.Shared */
  /* skip box _outRepl; BackendVarTransform.VariableReplacements */
  /* skip box _outUnReplaceable; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<DAE.ComponentRef>>>, #Integer, #Integer, tuple<.HashSet.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashSet.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashSet.FuncCrefStr<function>(DAE.ComponentRef cr) => String>> */
  /* skip box _outEqnslst; list<BackendDAE.Equation> */
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = mmc_mk_icon(_outGlobalFoundSimple); }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allCausalFinder(threadData_t *threadData, modelica_metatype _eqns, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _shared = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype _unReplaceable = NULL;
  modelica_metatype _mt = NULL;
  modelica_boolean _b;
  modelica_boolean _b1;
  modelica_boolean _b2;
  modelica_boolean _b3;
  modelica_boolean _globalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _globaleqnslst = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype _simpleeqnslst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_integer tmp11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_integer tmp19;
  modelica_metatype tmpMeta20;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _vars has no default value.
  // _shared has no default value.
  // _repl has no default value.
  // _unReplaceable has no default value.
  // _mt has no default value.
  // _b has no default value.
  // _b1 has no default value.
  // _b2 has no default value.
  // _b3 has no default value.
  // _globalFoundSimple has no default value.
  // _warnAliasConflicts has no default value.
  // _globaleqnslst has no default value.
  // _eqnslst has no default value.
  // _simpleeqnslst 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));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 5));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 6));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 8));
  tmp11 = mmc_unbox_integer(tmpMeta10);
  _vars = tmpMeta2;
  _shared = tmpMeta3;
  _repl = tmpMeta4;
  _unReplaceable = tmpMeta5;
  _mt = tmpMeta6;
  _globaleqnslst = tmpMeta7;
  _b = tmp9  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp11  /* pattern as ty=Boolean */;

  _eqnslst = omc_BackendVarTransform_replaceEquations(threadData, _eqns, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b2);

  /* Pattern-matching assignment */
  tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta14 = mmc_mk_box7(0, _vars, _shared, tmpMeta12, tmpMeta13, mmc_mk_integer(((modelica_integer) 1)), _mt, mmc_mk_boolean(0 /* false */));
  tmpMeta15 = omc_List_fold(threadData, _eqnslst, boxvar_RemoveSimpleEquations_simpleEquationsFinder, tmpMeta14);
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 3));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 4));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 7));
  tmp19 = mmc_unbox_integer(tmpMeta18);
  _eqnslst = tmpMeta16;
  _simpleeqnslst = tmpMeta17;
  _b1 = tmp19  /* pattern as ty=Boolean */;

  _vars = omc_RemoveSimpleEquations_allCausalFinder1(threadData, _b1, _b2, _simpleeqnslst, _eqnslst, _vars, _shared, _repl, _unReplaceable, _mt, _globaleqnslst, _b, _warnAliasConflicts ,&_shared ,&_repl ,&_unReplaceable ,&_eqnslst ,&_globalFoundSimple ,&_b3);

  _warnAliasConflicts = (_warnAliasConflicts || _b3);

  tmpMeta20 = mmc_mk_box8(0, _vars, _shared, _repl, _unReplaceable, _mt, _eqnslst, mmc_mk_boolean(_globalFoundSimple), mmc_mk_boolean(_warnAliasConflicts));
  _outTpl = tmpMeta20;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_traverseComponents(threadData_t *threadData, modelica_metatype _inComps, modelica_metatype _iEqns, modelica_fnptr _inFunc, modelica_metatype _inTypeA)
{
  modelica_metatype _outTypeA = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTypeA has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inComps;
    {
      modelica_integer _e;
      modelica_metatype _elst = NULL;
      modelica_metatype _rest = NULL;
      modelica_metatype _eqn = NULL;
      modelica_metatype _eqnlst = NULL;
      modelica_metatype _eqnlst1 = NULL;
      modelica_metatype _innerEquations = NULL;
      modelica_metatype _arg = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _e has no default value.
      // _elst has no default value.
      // _rest has no default value.
      // _eqn has no default value.
      // _eqnlst has no default value.
      // _eqnlst1 has no default value.
      // _innerEquations has no default value.
      // _arg has no default value.
      tmp4 = 0;
      for (; tmp4 < 9; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmpMeta1 = _inTypeA;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,0,2) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          
          _e = tmp9  /* pattern as ty=Integer */;
          _rest = tmpMeta7;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta10 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta11 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta11, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta10, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmp4_1);
          tmpMeta13 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,1,5) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          
          _elst = tmpMeta14;
          _rest = tmpMeta13;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendEquation_getList(threadData, _elst, _iEqns);

          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), _eqnlst, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, _eqnlst, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_integer tmp18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta15 = MMC_CAR(tmp4_1);
          tmpMeta16 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta15,2,2) == 0) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta15), 2));
          tmp18 = mmc_unbox_integer(tmpMeta17);
          
          _e = tmp18  /* pattern as ty=Integer */;
          _rest = tmpMeta16;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta19 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta20 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta20, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta19, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta21 = MMC_CAR(tmp4_1);
          tmpMeta22 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta21,6,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          
          _e = tmp24  /* pattern as ty=Integer */;
          _rest = tmpMeta22;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta25 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta26 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta26, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta25, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_integer tmp30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta27 = MMC_CAR(tmp4_1);
          tmpMeta28 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta27,3,2) == 0) goto tmp3_end;
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 2));
          tmp30 = mmc_unbox_integer(tmpMeta29);
          
          _e = tmp30  /* pattern as ty=Integer */;
          _rest = tmpMeta28;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta31 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta32 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta32, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta31, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_integer tmp36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta33 = MMC_CAR(tmp4_1);
          tmpMeta34 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta33,4,2) == 0) goto tmp3_end;
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta33), 2));
          tmp36 = mmc_unbox_integer(tmpMeta35);
          
          _e = tmp36  /* pattern as ty=Integer */;
          _rest = tmpMeta34;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta37 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta38 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta38, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta37, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_integer tmp42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta39 = MMC_CAR(tmp4_1);
          tmpMeta40 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta39,5,2) == 0) goto tmp3_end;
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta39), 2));
          tmp42 = mmc_unbox_integer(tmpMeta41);
          
          _e = tmp42  /* pattern as ty=Integer */;
          _rest = tmpMeta40;
          /* Pattern matching succeeded */
          _eqn = omc_BackendEquation_get(threadData, _iEqns, _e);

          tmpMeta43 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta44 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), tmpMeta44, _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, tmpMeta43, _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta45 = MMC_CAR(tmp4_1);
          tmpMeta46 = MMC_CDR(tmp4_1);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta45,7,4) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta45), 2));
          tmpMeta48 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta47), 3));
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta47), 4));
          
          _elst = tmpMeta48;
          _innerEquations = tmpMeta49;
          _rest = tmpMeta46;
          /* Pattern matching succeeded */
          _eqnlst = omc_BackendEquation_getList(threadData, _elst, _iEqns);

          _elst = omc_List_map__3(threadData, _innerEquations, boxvar_BackendDAEUtil_getEqnAndVarsFromInnerEquation, NULL, NULL);

          _eqnlst1 = omc_BackendEquation_getList(threadData, _elst, _iEqns);

          _arg = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 2))) ? ((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(_inFunc), 2))), listAppend(_eqnlst, _eqnlst1), _inTypeA) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inFunc), 1)))) (threadData, listAppend(_eqnlst, _eqnlst1), _inTypeA);
          /* Tail recursive call */
          _inComps = _rest;
          _inTypeA = _arg;
          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:;
    }
  }
  _outTypeA = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTypeA;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl)
{
  modelica_metatype _outSystem = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _eqns = NULL;
  modelica_metatype _comps = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype _unReplaceable = NULL;
  modelica_boolean _b;
  modelica_boolean _b1;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _mT = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  modelica_metatype tmpMeta11;
  modelica_integer tmp12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_metatype tmpMeta21;
  modelica_metatype tmpMeta22;
  modelica_integer tmp23;
  modelica_metatype tmpMeta24;
  modelica_integer tmp25;
  modelica_metatype tmpMeta26;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSystem has no default value.
  // _outShared has no default value.
  // _outTpl has no default value.
  // _vars has no default value.
  // _eqns has no default value.
  // _comps has no default value.
  // _repl has no default value.
  // _unReplaceable has no default value.
  // _b has no default value.
  // _b1 has no default value.
  // _warnAliasConflicts has no default value.
  // _mT has no default value.
  // _eqnslst has no default value.
  if(omc_BackendDAEUtil_isClockedSyst(threadData, _inSystem))
  {
    _outSystem = _inSystem;

    _outShared = _inShared;

    _outTpl = _inTpl;

    goto _return;
  }

  /* Pattern-matching assignment */
  tmpMeta1 = _inSystem;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 7));
  if (mmc__uniontype__metarecord__typedef__equal(tmpMeta4,1,3) == 0) MMC_THROW_INTERNAL();
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 4));
  _vars = tmpMeta2;
  _eqns = tmpMeta3;
  _comps = tmpMeta5;

  /* Pattern-matching assignment */
  tmpMeta6 = _inTpl;
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
  tmp12 = mmc_unbox_integer(tmpMeta11);
  _repl = tmpMeta7;
  _unReplaceable = tmpMeta8;
  _b1 = tmp10  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp12  /* pattern as ty=Boolean */;

  tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
  _mT = arrayCreate(omc_BackendVariable_varsSize(threadData, _vars), tmpMeta13);

  /* Pattern-matching assignment */
  tmpMeta14 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta15 = mmc_mk_box8(0, _vars, _inShared, _repl, _unReplaceable, _mT, tmpMeta14, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(_warnAliasConflicts));
  tmpMeta16 = omc_RemoveSimpleEquations_traverseComponents(threadData, _comps, _eqns, boxvar_RemoveSimpleEquations_allCausalFinder, tmpMeta15);
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 1));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 2));
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 3));
  tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 4));
  tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 6));
  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 7));
  tmp23 = mmc_unbox_integer(tmpMeta22);
  tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta16), 8));
  tmp25 = mmc_unbox_integer(tmpMeta24);
  _vars = tmpMeta17;
  _outShared = tmpMeta18;
  _repl = tmpMeta19;
  _unReplaceable = tmpMeta20;
  _eqnslst = tmpMeta21;
  _b = tmp23  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp25  /* pattern as ty=Boolean */;

  _outSystem = omc_RemoveSimpleEquations_updateSystem(threadData, _b, _eqnslst, _vars, _repl, _inSystem);

  tmpMeta26 = mmc_mk_box4(0, _repl, _unReplaceable, mmc_mk_boolean((_b || _b1)), mmc_mk_boolean(_warnAliasConflicts));
  _outTpl = tmpMeta26;
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outSystem;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_causal(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _repl = NULL;
  modelica_boolean _b;
  modelica_boolean _warnAliasConflicts;
  modelica_integer _size;
  modelica_metatype _unReplaceable = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _repl has no default value.
  // _b has no default value.
  // _warnAliasConflicts has no default value.
  // _size has no default value.
  // _unReplaceable has no default value.
  _size = omc_BackendDAEUtil_daeSize(threadData, _inDAE);

  _size = modelica_integer_max((modelica_integer)(((modelica_integer) 2053)),(modelica_integer)(((modelica_integer)floor((0.7) * (((modelica_real)_size))))));

  _repl = omc_BackendVarTransform_emptyReplacementsSized(threadData, _size);

  _unReplaceable = omc_HashSet_emptyHashSet(threadData);

  _unReplaceable = omc_BackendDAEUtil_foldEqSystem(threadData, _inDAE, boxvar_RemoveSimpleEquations_addUnreplaceable, _unReplaceable);

  /* Pattern-matching assignment */
  tmpMeta1 = mmc_mk_box2(0, boxvar_RemoveSimpleEquations_traverserExpUnreplaceable, _unReplaceable);
  tmpMeta2 = omc_BackendDAEUtil_traverseBackendDAEExps(threadData, _inDAE, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta1);
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  _unReplaceable = tmpMeta3;

  _unReplaceable = omc_RemoveSimpleEquations_addUnreplaceableFromWhens(threadData, _inDAE, _unReplaceable);

  _unReplaceable = omc_RemoveSimpleEquations_addUnreplaceableFromStateSets(threadData, _inDAE, _unReplaceable);

  if(omc_Flags_isSet(threadData, _OMC_LIT51))
  {
    omc_BackendDump_dumpHashSet(threadData, _unReplaceable, _OMC_LIT156);
  }

  /* Pattern-matching tuple assignment */
  tmpMeta10 = mmc_mk_box4(0, _repl, _unReplaceable, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
  tmpMeta11 = omc_BackendDAEUtil_mapEqSystemAndFold(threadData, _inDAE, boxvar_RemoveSimpleEquations_causal1, tmpMeta10, &tmpMeta4);
  _outDAE = tmpMeta11;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 3));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 4));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  _repl = tmpMeta5;
  _b = tmp7  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp9  /* pattern as ty=Boolean */;

  if((_warnAliasConflicts && omc_BackendDAEUtil_isSimulationDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3))))))
  {
    tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
    omc_Error_addMessage(threadData, _OMC_LIT158, tmpMeta12);
  }

  _outDAE = omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData, _b, _outDAE, _repl);
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_allAcausal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl)
{
  modelica_metatype _outSystem = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _eqns = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype _unReplaceable = NULL;
  modelica_boolean _b;
  modelica_boolean _b1;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _mT = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_integer tmp8;
  modelica_metatype tmpMeta9;
  modelica_integer tmp10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta18;
  modelica_metatype tmpMeta19;
  modelica_metatype tmpMeta20;
  modelica_integer tmp21;
  modelica_metatype tmpMeta22;
  modelica_integer tmp23;
  modelica_metatype tmpMeta24;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outSystem has no default value.
  // _outShared has no default value.
  // _outTpl has no default value.
  // _vars has no default value.
  // _eqns has no default value.
  // _repl has no default value.
  // _unReplaceable has no default value.
  // _b has no default value.
  // _b1 has no default value.
  // _warnAliasConflicts has no default value.
  // _mT has no default value.
  // _eqnslst has no default value.
  if(omc_BackendDAEUtil_isClockedSyst(threadData, _inSystem))
  {
    _outSystem = _inSystem;

    _outShared = _inShared;

    _outTpl = _inTpl;

    goto _return;
  }

  /* Pattern-matching assignment */
  tmpMeta1 = _inSystem;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  _vars = tmpMeta2;
  _eqns = tmpMeta3;

  /* Pattern-matching assignment */
  tmpMeta4 = _inTpl;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 3));
  tmp8 = mmc_unbox_integer(tmpMeta7);
  tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 4));
  tmp10 = mmc_unbox_integer(tmpMeta9);
  _repl = tmpMeta5;
  _unReplaceable = tmpMeta6;
  _b1 = tmp8  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp10  /* pattern as ty=Boolean */;

  _eqnslst = omc_BackendEquation_equationList(threadData, _eqns);

  tmpMeta11 = MMC_REFSTRUCTLIT(mmc_nil);
  _mT = arrayCreate(omc_BackendVariable_varsSize(threadData, _vars), tmpMeta11);

  /* Pattern-matching assignment */
  tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
  tmpMeta13 = mmc_mk_box8(0, _vars, _inShared, _repl, _unReplaceable, _mT, tmpMeta12, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(_warnAliasConflicts));
  tmpMeta14 = omc_RemoveSimpleEquations_allCausalFinder(threadData, _eqnslst, tmpMeta13);
  tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 1));
  tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
  tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
  tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 4));
  tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 6));
  tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 7));
  tmp21 = mmc_unbox_integer(tmpMeta20);
  tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 8));
  tmp23 = mmc_unbox_integer(tmpMeta22);
  _vars = tmpMeta15;
  _outShared = tmpMeta16;
  _repl = tmpMeta17;
  _unReplaceable = tmpMeta18;
  _eqnslst = tmpMeta19;
  _b = tmp21  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp23  /* pattern as ty=Boolean */;

  _outSystem = omc_RemoveSimpleEquations_updateSystem(threadData, _b, _eqnslst, _vars, _repl, _inSystem);

  tmpMeta24 = mmc_mk_box4(0, _repl, _unReplaceable, mmc_mk_boolean((_b || _b1)), mmc_mk_boolean(_warnAliasConflicts));
  _outTpl = tmpMeta24;
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outTpl) { *out_outTpl = _outTpl; }
  return _outSystem;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_allAcausal(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _repl = NULL;
  modelica_boolean _b;
  modelica_boolean _warnAliasConflicts;
  modelica_integer _size;
  modelica_metatype _unReplaceable = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _repl has no default value.
  // _b has no default value.
  // _warnAliasConflicts has no default value.
  // _size has no default value.
  // _unReplaceable has no default value.
  _size = omc_BackendDAEUtil_daeSize(threadData, _inDAE);

  _size = modelica_integer_max((modelica_integer)(((modelica_integer) 2053)),(modelica_integer)(((modelica_integer)floor((0.7) * (((modelica_real)_size))))));

  _repl = omc_BackendVarTransform_emptyReplacementsSized(threadData, _size);

  _unReplaceable = omc_HashSet_emptyHashSet(threadData);

  _unReplaceable = omc_BackendDAEUtil_foldEqSystem(threadData, _inDAE, boxvar_RemoveSimpleEquations_addUnreplaceable, _unReplaceable);

  /* Pattern-matching assignment */
  tmpMeta1 = mmc_mk_box2(0, boxvar_RemoveSimpleEquations_traverserExpUnreplaceable, _unReplaceable);
  tmpMeta2 = omc_BackendDAEUtil_traverseBackendDAEExps(threadData, _inDAE, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta1);
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  _unReplaceable = tmpMeta3;

  _unReplaceable = omc_RemoveSimpleEquations_addUnreplaceableFromWhens(threadData, _inDAE, _unReplaceable);

  if(omc_Flags_isSet(threadData, _OMC_LIT51))
  {
    omc_BackendDump_dumpHashSet(threadData, _unReplaceable, _OMC_LIT156);
  }

  /* Pattern-matching tuple assignment */
  tmpMeta10 = mmc_mk_box4(0, _repl, _unReplaceable, mmc_mk_boolean(0 /* false */), mmc_mk_boolean(0 /* false */));
  tmpMeta11 = omc_BackendDAEUtil_mapEqSystemAndFold(threadData, _inDAE, boxvar_RemoveSimpleEquations_allAcausal1, tmpMeta10, &tmpMeta4);
  _outDAE = tmpMeta11;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 3));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 4));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  _repl = tmpMeta5;
  _b = tmp7  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp9  /* pattern as ty=Boolean */;

  if((_warnAliasConflicts && omc_BackendDAEUtil_isSimulationDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3))))))
  {
    tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
    omc_Error_addMessage(threadData, _OMC_LIT158, tmpMeta12);
  }

  _outDAE = omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData, _b, _outDAE, _repl);
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causalFinder1(threadData_t *threadData, modelica_boolean _finished, modelica_boolean _b, modelica_metatype _iEqnslst, modelica_integer _index, modelica_integer _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _inGlobalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outRepl = NULL;
  modelica_metatype _outUnReplaceable = NULL;
  modelica_metatype _outEqnslst = NULL;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype tmpMeta[5] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVars = _iVars;
  _outShared = _ishared;
  _outRepl = _iRepl;
  _outUnReplaceable = _iUnreplaceable;
  _outEqnslst = listAppend(_iEqnslst, _iGlobalEqnslst);
  _warnAliasConflicts = __omcQ_24in_5FwarnAliasConflicts;
  
  
  
  
  
  { /* match expression */
    modelica_boolean tmp4_1;modelica_boolean tmp4_2;modelica_metatype tmp4_3;
    tmp4_1 = _finished;
    tmp4_2 = _b;
    tmp4_3 = _iEqnslst;
    {
      modelica_boolean _b1;
      modelica_metatype _eqnslst = NULL;
      modelica_metatype _simpleeqnslst = NULL;
      modelica_metatype _vars = NULL;
      modelica_metatype _shared = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _b1 has no default value.
      // _eqnslst has no default value.
      // _simpleeqnslst has no default value.
      // _vars has no default value.
      // _shared has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (1 /* true */ != tmp4_1) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = listAppend(_iEqnslst, _iGlobalEqnslst);
          goto tmp3_done;
        }
        case 1: {
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          if (!listEmpty(tmp4_3)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = _iGlobalEqnslst;
          goto tmp3_done;
        }
        case 2: {
          if (0 /* false */ != tmp4_2) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _iVars;
          tmpMeta[0+1] = _ishared;
          tmpMeta[0+2] = _iRepl;
          tmpMeta[0+3] = _iUnreplaceable;
          tmpMeta[0+4] = listAppend(_iEqnslst, _iGlobalEqnslst);
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          if (1 /* true */ != tmp4_2) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta8 = mmc_mk_box7(0, _iVars, _ishared, tmpMeta6, tmpMeta7, mmc_mk_integer(((modelica_integer) 1)), _iMT, mmc_mk_boolean(0 /* false */));
          tmpMeta9 = omc_List_fold(threadData, _iEqnslst, boxvar_RemoveSimpleEquations_simpleEquationsFinder, tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 7));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          _vars = tmpMeta10;
          _shared = tmpMeta11;
          _eqnslst = tmpMeta12;
          _simpleeqnslst = tmpMeta13;
          _b1 = tmp15  /* pattern as ty=Boolean */;

          _outVars = omc_RemoveSimpleEquations_causalFinder(threadData, _b1, _simpleeqnslst, _eqnslst, _index, _maxTraversals, _vars, _shared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, _inGlobalFoundSimple, _warnAliasConflicts ,&_outShared ,&_outRepl ,&_outUnReplaceable ,&_outEqnslst ,NULL ,&_warnAliasConflicts);
          tmpMeta[0+0] = _outVars;
          tmpMeta[0+1] = _outShared;
          tmpMeta[0+2] = _outRepl;
          tmpMeta[0+3] = _outUnReplaceable;
          tmpMeta[0+4] = _outEqnslst;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outVars = tmpMeta[0+0];
  _outShared = tmpMeta[0+1];
  _outRepl = tmpMeta[0+2];
  _outUnReplaceable = tmpMeta[0+3];
  _outEqnslst = tmpMeta[0+4];
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outRepl) { *out_outRepl = _outRepl; }
  if (out_outUnReplaceable) { *out_outUnReplaceable = _outUnReplaceable; }
  if (out_outEqnslst) { *out_outEqnslst = _outEqnslst; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_causalFinder1(threadData_t *threadData, modelica_metatype _finished, modelica_metatype _b, modelica_metatype _iEqnslst, modelica_metatype _index, modelica_metatype _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _inGlobalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_integer tmp6;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_finished);
  tmp2 = mmc_unbox_integer(_b);
  tmp3 = mmc_unbox_integer(_index);
  tmp4 = mmc_unbox_integer(_maxTraversals);
  tmp5 = mmc_unbox_integer(_inGlobalFoundSimple);
  tmp6 = mmc_unbox_integer(__omcQ_24in_5FwarnAliasConflicts);
  _outVars = omc_RemoveSimpleEquations_causalFinder1(threadData, tmp1, tmp2, _iEqnslst, tmp3, tmp4, _iVars, _ishared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, tmp5, tmp6, out_outShared, out_outRepl, out_outUnReplaceable, out_outEqnslst, &_warnAliasConflicts);
  /* skip box _outVars; BackendDAE.Variables */
  /* skip box _outShared; BackendDAE.Shared */
  /* skip box _outRepl; BackendVarTransform.VariableReplacements */
  /* skip box _outUnReplaceable; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<DAE.ComponentRef>>>, #Integer, #Integer, tuple<.HashSet.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashSet.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashSet.FuncCrefStr<function>(DAE.ComponentRef cr) => String>> */
  /* skip box _outEqnslst; list<BackendDAE.Equation> */
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_causalFinder(threadData_t *threadData, modelica_boolean _foundSimple, modelica_metatype _simpleContainerIn, modelica_metatype _iEqnslst, modelica_integer _traversalIdx, modelica_integer _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_boolean _inGlobalFoundSimple, modelica_boolean __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_boolean *out_outGlobalFoundSimple, modelica_boolean *out_warnAliasConflicts)
{
  modelica_metatype _outVars = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outRepl = NULL;
  modelica_metatype _outUnReplaceable = NULL;
  modelica_metatype _outEqnslst = NULL;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _vars = NULL;
  modelica_metatype _repl = NULL;
  modelica_boolean _b;
  modelica_boolean _b1;
  modelica_metatype _simpleContainer = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype _shared = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outVars = _iVars;
  _outShared = _ishared;
  _outRepl = _iRepl;
  _outUnReplaceable = _iUnreplaceable;
  // _outEqnslst has no default value.
  _outGlobalFoundSimple = _inGlobalFoundSimple;
  _warnAliasConflicts = __omcQ_24in_5FwarnAliasConflicts;
  // _vars has no default value.
  // _repl has no default value.
  // _b has no default value.
  // _b1 has no default value.
  // _simpleContainer has no default value.
  // _eqnslst has no default value.
  // _shared has no default value.
  if(_foundSimple)
  {
    _simpleContainer = omc_List_listArrayReverse(threadData, _simpleContainerIn);

    _vars = omc_RemoveSimpleEquations_handleSets(threadData, arrayLength(_simpleContainer), ((modelica_integer) 1), _simpleContainer, _iMT, _iUnreplaceable, _iVars, _iEqnslst, _ishared, _iRepl ,&_eqnslst ,&_shared ,&_repl ,&_b);

    _warnAliasConflicts = (_warnAliasConflicts || _b);

    _eqnslst = omc_BackendVarTransform_replaceEquations(threadData, _eqnslst, _repl, mmc_mk_some(boxvar_BackendVarTransform_skipPreChangeEdgeOperator) ,&_b1);

    _outVars = omc_RemoveSimpleEquations_causalFinder1(threadData, (_traversalIdx > _maxTraversals), _b1, _eqnslst, ((modelica_integer) 1) + _traversalIdx, _maxTraversals, _vars, _shared, _repl, _iUnreplaceable, _iMT, _iGlobalEqnslst, _inGlobalFoundSimple, _warnAliasConflicts ,&_outShared ,&_outRepl ,&_outUnReplaceable ,&_outEqnslst ,&_warnAliasConflicts);

    _outGlobalFoundSimple = 1 /* true */;
  }
  else
  {
    _outEqnslst = listAppend(_iEqnslst, _iGlobalEqnslst);
  }
  _return: OMC_LABEL_UNUSED
  if (out_outShared) { *out_outShared = _outShared; }
  if (out_outRepl) { *out_outRepl = _outRepl; }
  if (out_outUnReplaceable) { *out_outUnReplaceable = _outUnReplaceable; }
  if (out_outEqnslst) { *out_outEqnslst = _outEqnslst; }
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = _outGlobalFoundSimple; }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = _warnAliasConflicts; }
  return _outVars;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_RemoveSimpleEquations_causalFinder(threadData_t *threadData, modelica_metatype _foundSimple, modelica_metatype _simpleContainerIn, modelica_metatype _iEqnslst, modelica_metatype _traversalIdx, modelica_metatype _maxTraversals, modelica_metatype _iVars, modelica_metatype _ishared, modelica_metatype _iRepl, modelica_metatype _iUnreplaceable, modelica_metatype _iMT, modelica_metatype _iGlobalEqnslst, modelica_metatype _inGlobalFoundSimple, modelica_metatype __omcQ_24in_5FwarnAliasConflicts, modelica_metatype *out_outShared, modelica_metatype *out_outRepl, modelica_metatype *out_outUnReplaceable, modelica_metatype *out_outEqnslst, modelica_metatype *out_outGlobalFoundSimple, modelica_metatype *out_warnAliasConflicts)
{
  modelica_integer tmp1;
  modelica_integer tmp2;
  modelica_integer tmp3;
  modelica_integer tmp4;
  modelica_integer tmp5;
  modelica_boolean _outGlobalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_metatype _outVars = NULL;
  tmp1 = mmc_unbox_integer(_foundSimple);
  tmp2 = mmc_unbox_integer(_traversalIdx);
  tmp3 = mmc_unbox_integer(_maxTraversals);
  tmp4 = mmc_unbox_integer(_inGlobalFoundSimple);
  tmp5 = mmc_unbox_integer(__omcQ_24in_5FwarnAliasConflicts);
  _outVars = omc_RemoveSimpleEquations_causalFinder(threadData, tmp1, _simpleContainerIn, _iEqnslst, tmp2, tmp3, _iVars, _ishared, _iRepl, _iUnreplaceable, _iMT, _iGlobalEqnslst, tmp4, tmp5, out_outShared, out_outRepl, out_outUnReplaceable, out_outEqnslst, &_outGlobalFoundSimple, &_warnAliasConflicts);
  /* skip box _outVars; BackendDAE.Variables */
  /* skip box _outShared; BackendDAE.Shared */
  /* skip box _outRepl; BackendVarTransform.VariableReplacements */
  /* skip box _outUnReplaceable; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<DAE.ComponentRef>>>, #Integer, #Integer, tuple<.HashSet.FuncHashCref<function>(DAE.ComponentRef cr) => #Integer, .HashSet.FuncCrefEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .HashSet.FuncCrefStr<function>(DAE.ComponentRef cr) => String>> */
  /* skip box _outEqnslst; list<BackendDAE.Equation> */
  if (out_outGlobalFoundSimple) { *out_outGlobalFoundSimple = mmc_mk_icon(_outGlobalFoundSimple); }
  if (out_warnAliasConflicts) { *out_warnAliasConflicts = mmc_mk_icon(_warnAliasConflicts); }
  return _outVars;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fastAcausal1(threadData_t *threadData, modelica_metatype _inSystem, modelica_metatype _inShared, modelica_metatype _inTpl, modelica_metatype *out_outShared, modelica_metatype *out_outTpl)
{
  jmp_buf *old_mmc_jumper = threadData->mmc_jumper;
  modelica_metatype _outSystem = NULL;
  modelica_metatype _outShared = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _repl = NULL;
  modelica_metatype _unReplaceable = NULL;
  modelica_metatype _eqnslst = NULL;
  modelica_metatype _simpleeqnslst = NULL;
  modelica_metatype _vars = NULL;
  modelica_metatype _eqns = NULL;
  modelica_metatype _mT = NULL;
  modelica_boolean _foundSimple;
  modelica_boolean _globalFoundSimple;
  modelica_boolean _warnAliasConflicts;
  modelica_integer _maxTraversals;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outSystem = omc_BackendDAEUtil_copyEqSystem(threadData, _inSystem);
  // _outShared has no default value.
  // _outTpl has no default value.
  // _repl has no default value.
  // _unReplaceable has no default value.
  // _eqnslst has no default value.
  // _simpleeqnslst has no default value.
  // _vars has no default value.
  // _eqns has no default value.
  // _mT has no default value.
  // _foundSimple has no default value.
  // _globalFoundSimple has no default value.
  // _warnAliasConflicts has no default value.
  // _maxTraversals has no default value.
  if(omc_BackendDAEUtil_isClockedSyst(threadData, _inSystem))
  {
    _outSystem = _inSystem;

    _outShared = _inShared;

    _outTpl = _inTpl;

    goto _return;
  }

  { /* 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_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_integer tmp14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmpMeta5 = _outSystem;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta5), 3));
          _vars = tmpMeta6;
          _eqns = tmpMeta7;

          /* Pattern-matching assignment */
          tmpMeta8 = _inTpl;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 4));
          tmp14 = mmc_unbox_integer(tmpMeta13);
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 5));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          _repl = tmpMeta9;
          _globalFoundSimple = tmp11  /* pattern as ty=Boolean */;
          _unReplaceable = tmpMeta12;
          _maxTraversals = tmp14  /* pattern as ty=Integer */;
          _warnAliasConflicts = tmp16  /* pattern as ty=Boolean */;

          _eqnslst = omc_BackendEquation_equationList(threadData, _eqns);

          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          _mT = arrayCreate(omc_BackendVariable_varsSize(threadData, _vars), tmpMeta17);

          /* Pattern-matching assignment */
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta19 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta20 = mmc_mk_box7(0, _vars, _inShared, tmpMeta18, tmpMeta19, mmc_mk_integer(((modelica_integer) 1)), _mT, mmc_mk_boolean(0 /* false */));
          tmpMeta21 = omc_List_fold(threadData, _eqnslst, boxvar_RemoveSimpleEquations_simpleEquationsFinder, tmpMeta20);
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 3));
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 4));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 7));
          tmp25 = mmc_unbox_integer(tmpMeta24);
          _eqnslst = tmpMeta22;
          _simpleeqnslst = tmpMeta23;
          _foundSimple = tmp25  /* pattern as ty=Boolean */;

          tmpMeta26 = MMC_REFSTRUCTLIT(mmc_nil);
          _vars = omc_RemoveSimpleEquations_causalFinder(threadData, _foundSimple, _simpleeqnslst, _eqnslst, ((modelica_integer) 1), _maxTraversals, _vars, _inShared, _repl, _unReplaceable, _mT, tmpMeta26, _globalFoundSimple, _warnAliasConflicts ,&_outShared ,&_repl ,&_unReplaceable ,&_eqnslst ,&_globalFoundSimple ,&_warnAliasConflicts);

          _outSystem = omc_RemoveSimpleEquations_updateSystem(threadData, _globalFoundSimple, _eqnslst, _vars, _repl, _outSystem);

          tmpMeta27 = mmc_mk_box5(0, _repl, mmc_mk_boolean(_globalFoundSimple), _unReplaceable, mmc_mk_integer(_maxTraversals), mmc_mk_boolean(_warnAliasConflicts));
          _outTpl = tmpMeta27;

          omc_GCExt_free(threadData, _mT);
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          _outSystem = _inSystem;

          _outShared = _inShared;

          _outTpl = _inTpl;
          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_outShared) { *out_outShared = _outShared; }
  if (out_outTpl) { *out_outTpl = _outTpl; }
  threadData->mmc_jumper = old_mmc_jumper;
  return _outSystem;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_addUnreplaceable(threadData_t *threadData, modelica_metatype _syst, modelica_metatype _shared, modelica_metatype _inUnreplaceable)
{
  modelica_metatype _outUnreplaceable = NULL;
  modelica_metatype _orderedVars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outUnreplaceable = _inUnreplaceable;
  // _orderedVars has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _syst;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _orderedVars = tmpMeta2;

  {
    modelica_metatype _var;
    for (tmpMeta3 = omc_BackendVariable_varList(threadData, _orderedVars); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _var = MMC_CAR(tmpMeta3);
      if(omc_BackendVariable_varUnreplaceable(threadData, _var))
      {
        _outUnreplaceable = omc_BaseHashSet_add(threadData, omc_BackendVariable_varCref(threadData, _var), _outUnreplaceable);
      }
    }
  }
  _return: OMC_LABEL_UNUSED
  return _outUnreplaceable;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_fastAcausal(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _repl = NULL;
  modelica_boolean _b;
  modelica_boolean _warnAliasConflicts;
  modelica_integer _size;
  modelica_metatype _unReplaceable = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_integer tmp7;
  modelica_metatype tmpMeta8;
  modelica_integer tmp9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _repl has no default value.
  // _b has no default value.
  // _warnAliasConflicts has no default value.
  // _size has no default value.
  // _unReplaceable has no default value.
  _size = omc_BackendDAEUtil_daeSize(threadData, _inDAE);

  _size = modelica_integer_max((modelica_integer)(((modelica_integer) 2053)),(modelica_integer)(((modelica_integer)floor((0.7) * (((modelica_real)_size))))));

  _repl = omc_BackendVarTransform_emptyReplacementsSized(threadData, _size);

  _unReplaceable = omc_HashSet_emptyHashSet(threadData);

  _unReplaceable = omc_BackendDAEUtil_foldEqSystem(threadData, _inDAE, boxvar_RemoveSimpleEquations_addUnreplaceable, _unReplaceable);

  /* Pattern-matching assignment */
  tmpMeta1 = mmc_mk_box2(0, boxvar_RemoveSimpleEquations_traverserExpUnreplaceable, _unReplaceable);
  tmpMeta2 = omc_BackendDAEUtil_traverseBackendDAEExps(threadData, _inDAE, boxvar_Expression_traverseSubexpressionsHelper, tmpMeta1);
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  _unReplaceable = tmpMeta3;

  _unReplaceable = omc_RemoveSimpleEquations_addUnreplaceableFromWhens(threadData, _inDAE, _unReplaceable);

  if(omc_Flags_isSet(threadData, _OMC_LIT51))
  {
    omc_BackendDump_dumpHashSet(threadData, _unReplaceable, _OMC_LIT156);
  }

  /* Pattern-matching tuple assignment */
  tmpMeta10 = mmc_mk_box5(0, _repl, mmc_mk_boolean(0 /* false */), _unReplaceable, mmc_mk_integer(omc_Flags_getConfigInt(threadData, _OMC_LIT162)), mmc_mk_boolean(0 /* false */));
  tmpMeta11 = omc_BackendDAEUtil_mapEqSystemAndFold(threadData, _inDAE, boxvar_RemoveSimpleEquations_fastAcausal1, tmpMeta10, &tmpMeta4);
  _outDAE = tmpMeta11;
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
  tmp7 = mmc_unbox_integer(tmpMeta6);
  tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 5));
  tmp9 = mmc_unbox_integer(tmpMeta8);
  _repl = tmpMeta5;
  _b = tmp7  /* pattern as ty=Boolean */;
  _warnAliasConflicts = tmp9  /* pattern as ty=Boolean */;

  if((_warnAliasConflicts && omc_BackendDAEUtil_isSimulationDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3))))))
  {
    tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
    omc_Error_addMessage(threadData, _OMC_LIT158, tmpMeta12);
  }

  _outDAE = omc_RemoveSimpleEquations_removeSimpleEquationsShared(threadData, _b, _outDAE, _repl);
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixKnownVarsCausal2(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype _rightCrefs = NULL;
  modelica_metatype _eqs1 = NULL;
  modelica_metatype tmpMeta1;
  modelica_boolean _done;
  modelica_metatype _var = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _orderedVars = NULL;
  modelica_metatype _orderedEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _binding has no default value.
  // _rightCrefs has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs1 = tmpMeta1;
  _done = 0 /* false */;
  // _var has no default value.
  // _eqn has no default value.
  // _orderedVars has no default value.
  // _orderedEqs has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_boolean tmp12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          /* Pattern matching succeeded */
          _binding = omc_BackendVariable_varBindExp(threadData, _inVar);

          _rightCrefs = omc_Expression_getAllCrefs(threadData, _binding);

          _var = omc_BackendVariable_setBindExp(threadData, _inVar, mmc_mk_none());

          tmpMeta6 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_BackendVariable_varExp(threadData, _var), _binding, _OMC_LIT15, _OMC_LIT18);
          _eqn = tmpMeta6;

          {
            modelica_metatype _eq;
            for (tmpMeta7 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 2))); !listEmpty(tmpMeta7); tmpMeta7=MMC_CDR(tmpMeta7))
            {
              _eq = MMC_CAR(tmpMeta7);
              /* Pattern-matching assignment */
              tmpMeta8 = _eq;
              tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 2));
              tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
              _orderedVars = tmpMeta9;
              _orderedEqs = tmpMeta10;

              if(omc_BackendVariable_existsAnyVar(threadData, _rightCrefs, _orderedVars, 0 /* false */))
              {
                _orderedVars = omc_BackendVariable_addVar(threadData, _var, _orderedVars);

                _orderedEqs = omc_BackendEquation_add(threadData, _eqn, _orderedEqs);

                tmpMeta11 = mmc_mk_cons(omc_BackendDAEUtil_setEqSystEqs(threadData, omc_BackendDAEUtil_setEqSystVars(threadData, _eq, _orderedVars), _orderedEqs), _eqs1);
                _eqs1 = tmpMeta11;

                /* Pattern-matching assignment */
                tmp12 = _done;
                if (0 /* false */ != tmp12) goto goto_2;

                _done = 1 /* true */;
              }
              else
              {
                tmpMeta13 = mmc_mk_cons(_eq, _eqs1);
                _eqs1 = tmpMeta13;
              }
            }
          }

          if((!_done))
          {
            tmpMeta16 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta17 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta15 = mmc_mk_cons(omc_BackendDAEUtil_createEqSystem(threadData, omc_BackendVariable_listVar(threadData, tmpMeta16), omc_BackendEquation_listEquation(threadData, tmpMeta17), tmpMeta18, _OMC_LIT163, omc_BackendEquation_emptyEqns(threadData)), _eqs1);
            _eqs1 = tmpMeta15;
          }

          tmpMeta19 = mmc_mk_box3(3, &BackendDAE_BackendDAE_DAE__desc, listReverse(_eqs1), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3))));
          _outDAE = tmpMeta19;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta20;
          /* Pattern matching succeeded */
          tmpMeta20 = mmc_mk_cons(_inVar, MMC_REFSTRUCTLIT(mmc_nil));
          omc_BackendDump_dumpVarList(threadData, tmpMeta20, _OMC_LIT164);

          omc_Error_addCompilerError(threadData, _OMC_LIT165);

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

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasVarsCausal2(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype _rightCrefs = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _eqs1 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _shared = NULL;
  modelica_boolean _done;
  modelica_metatype _var = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _orderedVars = NULL;
  modelica_metatype _orderedEqs = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _binding has no default value.
  // _rightCrefs has no default value.
  // _eqs has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqs1 = tmpMeta1;
  // _shared has no default value.
  _done = 0 /* false */;
  // _var has no default value.
  // _eqn has no default value.
  // _orderedVars has no default value.
  // _orderedEqs has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_boolean tmp15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          /* Pattern matching succeeded */
          _binding = omc_BackendVariable_varBindExp(threadData, _inVar);

          _rightCrefs = omc_Expression_getAllCrefs(threadData, _binding);

          /* Pattern-matching assignment */
          tmpMeta6 = _inDAE;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          _eqs = tmpMeta7;
          _shared = tmpMeta8;

          _var = omc_BackendVariable_setBindExp(threadData, _inVar, mmc_mk_none());

          _var = omc_BackendVariable_setVarFixed(threadData, _var, 0 /* false */);

          tmpMeta9 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_BackendVariable_varExp(threadData, _var), _binding, _OMC_LIT15, _OMC_LIT18);
          _eqn = tmpMeta9;

          {
            modelica_metatype _eq;
            for (tmpMeta10 = _eqs; !listEmpty(tmpMeta10); tmpMeta10=MMC_CDR(tmpMeta10))
            {
              _eq = MMC_CAR(tmpMeta10);
              /* Pattern-matching assignment */
              tmpMeta11 = _eq;
              tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
              tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 3));
              _orderedVars = tmpMeta12;
              _orderedEqs = tmpMeta13;

              if(omc_BackendVariable_existsAnyVar(threadData, _rightCrefs, _orderedVars, 0 /* false */))
              {
                _orderedVars = omc_BackendVariable_addVar(threadData, _var, _orderedVars);

                _orderedEqs = omc_BackendEquation_add(threadData, _eqn, _orderedEqs);

                tmpMeta14 = mmc_mk_cons(omc_BackendDAEUtil_setEqSystEqs(threadData, omc_BackendDAEUtil_setEqSystVars(threadData, _eq, _orderedVars), _orderedEqs), _eqs1);
                _eqs1 = tmpMeta14;

                /* Pattern-matching assignment */
                tmp15 = _done;
                if (0 /* false */ != tmp15) goto goto_2;

                _done = 1 /* true */;
              }
              else
              {
                tmpMeta16 = mmc_mk_cons(_eq, _eqs1);
                _eqs1 = tmpMeta16;
              }
            }
          }

          if((!_done))
          {
            tmpMeta19 = mmc_mk_cons(_var, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta20 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
            tmpMeta21 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta18 = mmc_mk_cons(omc_BackendDAEUtil_createEqSystem(threadData, omc_BackendVariable_listVar(threadData, tmpMeta19), omc_BackendEquation_listEquation(threadData, tmpMeta20), tmpMeta21, _OMC_LIT163, omc_BackendEquation_emptyEqns(threadData)), _eqs1);
            _eqs1 = tmpMeta18;
          }

          tmpMeta22 = mmc_mk_box3(3, &BackendDAE_BackendDAE_DAE__desc, listReverse(_eqs1), _shared);
          _outDAE = tmpMeta22;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta23;
          /* Pattern matching succeeded */
          tmpMeta23 = mmc_mk_cons(_inVar, MMC_REFSTRUCTLIT(mmc_nil));
          omc_BackendDump_dumpVarList(threadData, tmpMeta23, _OMC_LIT166);

          omc_Error_addCompilerError(threadData, _OMC_LIT167);

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

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasAndKnownVarsCausal(threadData_t *threadData, modelica_metatype _inDAE1, modelica_metatype _inDAE2)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _aliasVars1 = NULL;
  modelica_metatype _knownVars1 = NULL;
  modelica_metatype _aliasVars2 = NULL;
  modelica_metatype _knownVars2 = NULL;
  modelica_metatype _aliasVarList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _knownVarList = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _cref = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outDAE = _inDAE2;
  // _aliasVars1 has no default value.
  // _knownVars1 has no default value.
  // _aliasVars2 has no default value.
  // _knownVars2 has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _aliasVarList = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _knownVarList = tmpMeta2;
  // _cref has no default value.
  _aliasVars1 = omc_BackendDAEUtil_getAliasVars(threadData, _inDAE1);

  _aliasVars2 = omc_BackendDAEUtil_getAliasVars(threadData, _inDAE2);

  _knownVars1 = omc_BackendDAEUtil_getGlobalKnownVarsFromDAE(threadData, _inDAE1);

  _knownVars2 = omc_BackendDAEUtil_getGlobalKnownVarsFromDAE(threadData, _inDAE2);

  {
    modelica_metatype _var;
    for (tmpMeta3 = omc_BackendVariable_varList(threadData, _aliasVars2); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _var = MMC_CAR(tmpMeta3);
      _cref = omc_BackendVariable_varCref(threadData, _var);

      if((!omc_BackendVariable_existsVar(threadData, _cref, _aliasVars1, 0 /* false */)))
      {
        _outDAE = omc_RemoveSimpleEquations_fixAliasVarsCausal2(threadData, _var, _outDAE);
      }
      else
      {
        tmpMeta4 = mmc_mk_cons(_var, _aliasVarList);
        _aliasVarList = tmpMeta4;
      }
    }
  }

  _outDAE = omc_BackendDAEUtil_setAliasVars(threadData, _outDAE, omc_BackendVariable_listVar(threadData, _aliasVarList));

  {
    modelica_metatype _var;
    for (tmpMeta6 = omc_BackendVariable_varList(threadData, _knownVars2); !listEmpty(tmpMeta6); tmpMeta6=MMC_CDR(tmpMeta6))
    {
      _var = MMC_CAR(tmpMeta6);
      _cref = omc_BackendVariable_varCref(threadData, _var);

      if(((!omc_BackendVariable_existsVar(threadData, _cref, _knownVars1, 0 /* false */)) && (!(omc_BackendVariable_isInput(threadData, _var) || omc_BackendVariable_isAlgebraicOldState(threadData, _var)))))
      {
        _outDAE = omc_RemoveSimpleEquations_fixKnownVarsCausal2(threadData, _var, _outDAE);
      }
      else
      {
        tmpMeta7 = mmc_mk_cons(_var, _knownVarList);
        _knownVarList = tmpMeta7;
      }
    }
  }

  _outDAE = omc_BackendDAEUtil_setDAEGlobalKnownVars(threadData, _outDAE, omc_BackendVariable_listVar(threadData, _knownVarList));
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixKnownVars(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fdae)
{
  modelica_metatype _dae = NULL;
  modelica_metatype _eqs = NULL;
  modelica_metatype _globalKnownVars = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype _eqnList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _varList = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _knownVarList = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype _crlst = NULL;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _dae = __omcQ_24in_5Fdae;
  // _eqs has no default value.
  // _globalKnownVars has no default value.
  // _binding has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _eqnList = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _varList = tmpMeta2;
  tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
  _knownVarList = tmpMeta3;
  // _crlst has no default value.
  _globalKnownVars = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dae), 3)))), 2)));

  {
    modelica_metatype _var;
    for (tmpMeta4 = omc_BackendVariable_varList(threadData, _globalKnownVars); !listEmpty(tmpMeta4); tmpMeta4=MMC_CDR(tmpMeta4))
    {
      _var = MMC_CAR(tmpMeta4);
      if(omc_BackendVariable_varHasBindExp(threadData, _var))
      {
        _binding = omc_BackendVariable_varBindExp(threadData, _var);

        tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
        omc_Expression_traverseExpTopDown(threadData, _binding, boxvar_Expression_traversingComponentRefFinderNoPreDer, tmpMeta5 ,&_crlst);

        if(omc_BackendDAEUtil_containAnyVar(threadData, _crlst, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dae), 3)))), 3)))))
        {
          tmpMeta6 = mmc_mk_cons(omc_BackendVariable_setBindExp(threadData, _var, mmc_mk_none()), _varList);
          _varList = tmpMeta6;

          tmpMeta8 = mmc_mk_box5(3, &BackendDAE_Equation_EQUATION__desc, omc_BackendVariable_varExp(threadData, _var), _binding, _OMC_LIT15, _OMC_LIT18);
          tmpMeta7 = mmc_mk_cons(tmpMeta8, _eqnList);
          _eqnList = tmpMeta7;
        }
        else
        {
          tmpMeta9 = mmc_mk_cons(_var, _knownVarList);
          _knownVarList = tmpMeta9;
        }
      }
      else
      {
        tmpMeta10 = mmc_mk_cons(_var, _knownVarList);
        _knownVarList = tmpMeta10;
      }
    }
  }

  if((!listEmpty(_varList)))
  {
    tmpMeta12 = MMC_REFSTRUCTLIT(mmc_nil);
    _eqs = omc_BackendDAEUtil_createEqSystem(threadData, omc_BackendVariable_listVar(threadData, _varList), omc_BackendEquation_listEquation(threadData, _eqnList), tmpMeta12, _OMC_LIT163, omc_BackendEquation_emptyEqns(threadData));

    tmpMeta14 = mmc_mk_cons(_eqs, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_dae), 2))));
    tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(4));
    memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_dae), 4*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[2] = tmpMeta14;
    _dae = tmpMeta13;
  }

  _dae = omc_BackendDAEUtil_setDAEGlobalKnownVars(threadData, _dae, omc_BackendVariable_listVar(threadData, _knownVarList));
  _return: OMC_LABEL_UNUSED
  return _dae;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_fixAliasVars(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype _aliasVarList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _knownVarList = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _aliasVars has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _aliasVarList = tmpMeta1;
  // _knownVarList has no default value.
  // _binding has no default value.
  _aliasVars = omc_BackendDAEUtil_getAliasVars(threadData, _inDAE);

  _knownVarList = omc_BackendVariable_varList(threadData, omc_BackendDAEUtil_getGlobalKnownVarsFromDAE(threadData, _inDAE));

  {
    modelica_metatype _var;
    for (tmpMeta2 = omc_BackendVariable_varList(threadData, _aliasVars); !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _var = MMC_CAR(tmpMeta2);
      _binding = omc_BackendVariable_varBindExp(threadData, _var);

      if(omc_Expression_isConst(threadData, _binding))
      {
        tmpMeta3 = mmc_mk_cons(_var, _knownVarList);
        _knownVarList = tmpMeta3;
      }
      else
      {
        tmpMeta4 = mmc_mk_cons(_var, _aliasVarList);
        _aliasVarList = tmpMeta4;
      }
    }
  }

  _outDAE = omc_BackendDAEUtil_setAliasVars(threadData, _inDAE, omc_BackendVariable_listVar(threadData, _aliasVarList));

  _outDAE = omc_BackendDAEUtil_setDAEGlobalKnownVars(threadData, _outDAE, omc_BackendVariable_listVar(threadData, _knownVarList));
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_RemoveSimpleEquations_getVarsHelper(threadData_t *threadData, modelica_metatype _cr, modelica_metatype _vars)
{
  modelica_metatype _outVars = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outVars has no default value.
  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp3;
      int tmp4;
      tmp3 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp2_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp3 < 2; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          /* Pattern matching succeeded */
          _outVars = omc_BackendVariable_getVar(threadData, _cr, _vars, NULL);
          goto tmp2_done;
        }
        case 1: {
          modelica_metatype tmpMeta5;
          /* Pattern matching succeeded */
          tmpMeta5 = MMC_REFSTRUCTLIT(mmc_nil);
          _outVars = tmpMeta5;
          goto tmp2_done;
        }
        }
        goto tmp2_end;
        tmp2_end: ;
      }
      goto goto_1;
      tmp2_done:
      (void)tmp3;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp2_done2;
      goto_1:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp3 < 2) {
        goto tmp2_top;
      }
      MMC_THROW_INTERNAL();
      tmp2_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  return _outVars;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_fixAliasVarsVariablity(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype _aliasVars = NULL;
  modelica_metatype _systvars = NULL;
  modelica_metatype _globalKnownVars = NULL;
  modelica_metatype _binding = NULL;
  modelica_metatype _crefs = NULL;
  modelica_boolean _paramOrConst;
  modelica_boolean _const;
  modelica_metatype _shared = NULL;
  modelica_metatype _referencevar = NULL;
  modelica_metatype _tempreferencevar = NULL;
  modelica_metatype _knownVarList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _aliasVarList = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _tempvar = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  // _aliasVars has no default value.
  // _systvars has no default value.
  // _globalKnownVars has no default value.
  // _binding has no default value.
  // _crefs has no default value.
  // _paramOrConst has no default value.
  // _const has no default value.
  // _shared has no default value.
  // _referencevar has no default value.
  // _tempreferencevar has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _knownVarList = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _aliasVarList = tmpMeta2;
  // _tempvar has no default value.
  if((!omc_Flags_getConfigBool(threadData, _OMC_LIT171)))
  {
    _outDAE = _inDAE;

    goto _return;
  }

  _aliasVars = omc_BackendDAEUtil_getAliasVars(threadData, _inDAE);

  _systvars = omc_BackendVariable_listVar(threadData, omc_BackendVariable_equationSystemsVarsLst(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 2)))));

  {
    modelica_metatype _var;
    for (tmpMeta3 = omc_BackendVariable_varList(threadData, _aliasVars); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _var = MMC_CAR(tmpMeta3);
      _binding = omc_BackendVariable_varBindExp(threadData, _var);

      _crefs = omc_Expression_getAllCrefs(threadData, _binding);

      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      _referencevar = tmpMeta4;

      {
        modelica_metatype _cr;
        for (tmpMeta5 = _crefs; !listEmpty(tmpMeta5); tmpMeta5=MMC_CDR(tmpMeta5))
        {
          _cr = MMC_CAR(tmpMeta5);
          _tempreferencevar = omc_RemoveSimpleEquations_getVarsHelper(threadData, _cr, _systvars);

          if(listEmpty(_tempreferencevar))
          {
            _tempreferencevar = omc_RemoveSimpleEquations_getVarsHelper(threadData, _cr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3)))), 2))));
          }

          _referencevar = listAppend(_tempreferencevar, _referencevar);
        }
      }

      if(listEmpty(_referencevar))
      {
        _paramOrConst = 0 /* false */;

        _const = 0 /* false */;
      }
      else
      {
        _paramOrConst = omc_List_all(threadData, _referencevar, boxvar_BackendVariable_isParamOrConstant);

        _const = omc_List_all(threadData, _referencevar, boxvar_BackendVariable_isConst);
      }

      if(_const)
      {
        _tempvar = omc_BackendVariable_setVarKind(threadData, _var, _OMC_LIT173);

        tmpMeta7 = mmc_mk_cons(omc_BackendVariable_setVarFixed(threadData, _tempvar, 1 /* true */), _knownVarList);
        _knownVarList = tmpMeta7;
      }
      else
      {
        if(_paramOrConst)
        {
          _tempvar = omc_BackendVariable_setVarKind(threadData, _var, _OMC_LIT172);

          tmpMeta8 = mmc_mk_cons(omc_BackendVariable_setVarFixed(threadData, _tempvar, 1 /* true */), _knownVarList);
          _knownVarList = tmpMeta8;
        }
        else
        {
          tmpMeta9 = mmc_mk_cons(_var, _aliasVarList);
          _aliasVarList = tmpMeta9;
        }
      }
    }
  }

  _globalKnownVars = omc_BackendVariable_mergeVariables(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_inDAE), 3)))), 2))), omc_BackendVariable_listVar(threadData, _knownVarList), 1 /* true */);

  _outDAE = omc_BackendDAEUtil_setAliasVars(threadData, _inDAE, omc_BackendVariable_listVar(threadData, _aliasVarList));

  _outDAE = omc_BackendDAEUtil_setDAEGlobalKnownVars(threadData, _outDAE, _globalKnownVars);
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_removeVerySimpleEquations(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  if(omc_BackendDAEUtil_hasDAEMatching(threadData, _inDAE))
  {
    omc_Error_addInternalError(threadData, _OMC_LIT174, _OMC_LIT176);

    _outDAE = _inDAE;
  }
  else
  {
    _outDAE = omc_RemoveSimpleEquations_performAliasEliminationBB(threadData, _inDAE, 1 /* true */);
  }
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

DLLDirection
modelica_metatype omc_RemoveSimpleEquations_removeSimpleEquations(threadData_t *threadData, modelica_metatype _inDAE)
{
  modelica_metatype _outDAE = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outDAE has no default value.
  if(omc_BackendDAEUtil_hasDAEMatching(threadData, _inDAE))
  {
    { /* match expression */
      modelica_string tmp4_1;
      tmp4_1 = omc_Flags_getConfigString(threadData, _OMC_LIT206);
      {
        volatile mmc_switch_type tmp4;
        int tmp5;
        tmp4 = 0;
        for (; tmp4 < 4; tmp4++) {
          switch (MMC_SWITCH_CAST(tmp4)) {
          case 0: {
            if (7 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT178), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
            /* Pattern matching succeeded */
            tmpMeta1 = omc_RemoveSimpleEquations_causal(threadData, _inDAE);
            goto tmp3_done;
          }
          case 1: {
            if (6 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT185), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
            /* Pattern matching succeeded */
            tmpMeta1 = omc_RemoveSimpleEquations_causal(threadData, _inDAE);
            goto tmp3_done;
          }
          case 2: {
            if (3 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT194), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
            /* Pattern matching succeeded */
            tmpMeta1 = omc_RemoveSimpleEquations_performAliasEliminationBB(threadData, _inDAE, 1 /* true */);
            goto tmp3_done;
          }
          case 3: {
            
            /* Pattern matching succeeded */
            tmpMeta1 = _inDAE;
            goto tmp3_done;
          }
          }
          goto tmp3_end;
          tmp3_end: ;
        }
        goto goto_2;
        goto_2:;
        MMC_THROW_INTERNAL();
        goto tmp3_done;
        tmp3_done:;
      }
    }
    _outDAE = tmpMeta1;

    _outDAE = omc_RemoveSimpleEquations_fixAliasVars(threadData, _outDAE);

    _outDAE = omc_RemoveSimpleEquations_fixAliasAndKnownVarsCausal(threadData, _inDAE, _outDAE);

    _outDAE = omc_RemoveSimpleEquations_fixAliasVarsVariablity(threadData, _outDAE);
  }
  else
  {
    { /* match expression */
      modelica_string tmp9_1;
      tmp9_1 = omc_Flags_getConfigString(threadData, _OMC_LIT206);
      {
        volatile mmc_switch_type tmp9;
        int tmp10;
        tmp9 = 0;
        for (; tmp9 < 5; tmp9++) {
          switch (MMC_SWITCH_CAST(tmp9)) {
          case 0: {
            if (7 != MMC_STRLEN(tmp9_1) || strcmp(MMC_STRINGDATA(_OMC_LIT178), MMC_STRINGDATA(tmp9_1)) != 0) goto tmp8_end;
            /* Pattern matching succeeded */
            tmpMeta6 = omc_RemoveSimpleEquations_fastAcausal(threadData, _inDAE);
            goto tmp8_done;
          }
          case 1: {
            if (11 != MMC_STRLEN(tmp9_1) || strcmp(MMC_STRINGDATA(_OMC_LIT188), MMC_STRINGDATA(tmp9_1)) != 0) goto tmp8_end;
            /* Pattern matching succeeded */
            tmpMeta6 = omc_RemoveSimpleEquations_fastAcausal(threadData, _inDAE);
            goto tmp8_done;
          }
          case 2: {
            if (10 != MMC_STRLEN(tmp9_1) || strcmp(MMC_STRINGDATA(_OMC_LIT191), MMC_STRINGDATA(tmp9_1)) != 0) goto tmp8_end;
            /* Pattern matching succeeded */
            tmpMeta6 = omc_RemoveSimpleEquations_allAcausal(threadData, _inDAE);
            goto tmp8_done;
          }
          case 3: {
            if (3 != MMC_STRLEN(tmp9_1) || strcmp(MMC_STRINGDATA(_OMC_LIT194), MMC_STRINGDATA(tmp9_1)) != 0) goto tmp8_end;
            /* Pattern matching succeeded */
            tmpMeta6 = omc_RemoveSimpleEquations_performAliasEliminationBB(threadData, _inDAE, 1 /* true */);
            goto tmp8_done;
          }
          case 4: {
            
            /* Pattern matching succeeded */
            tmpMeta6 = _inDAE;
            goto tmp8_done;
          }
          }
          goto tmp8_end;
          tmp8_end: ;
        }
        goto goto_7;
        goto_7:;
        MMC_THROW_INTERNAL();
        goto tmp8_done;
        tmp8_done:;
      }
    }
    _outDAE = tmpMeta6;

    _outDAE = omc_RemoveSimpleEquations_fixAliasVars(threadData, _outDAE);

    _outDAE = omc_RemoveSimpleEquations_fixKnownVars(threadData, _outDAE);

    _outDAE = omc_RemoveSimpleEquations_fixAliasVarsVariablity(threadData, _outDAE);
  }
  _return: OMC_LABEL_UNUSED
  return _outDAE;
}

