#include "omc_simulation_settings.h"
#include "FUnitCheck.h"
#define _OMC_LIT0_data ""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT0,0,_OMC_LIT0_data);
#define _OMC_LIT0 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT0)
#define _OMC_LIT1_data "None"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT1,4,_OMC_LIT1_data);
#define _OMC_LIT1 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT1)
#define _OMC_LIT2_data "unit"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT2,4,_OMC_LIT2_data);
#define _OMC_LIT2 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT2)
#define _OMC_LIT3_data "-"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT3,1,_OMC_LIT3_data);
#define _OMC_LIT3 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT3)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT4,2,4) {&FUnit_Unit_MASTER__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT4 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT4)
#define _OMC_LIT5_data "NONE"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT5,4,_OMC_LIT5_data);
#define _OMC_LIT5 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT5)
#define _OMC_LIT6_data "- sub-expression \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT6,18,_OMC_LIT6_data);
#define _OMC_LIT6 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT6)
#define _OMC_LIT7_data "\" has unit \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT7,12,_OMC_LIT7_data);
#define _OMC_LIT7 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT7)
#define _OMC_LIT8_data "\""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT8,1,_OMC_LIT8_data);
#define _OMC_LIT8 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT8)
#define _OMC_LIT9_data "\"\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT9,2,_OMC_LIT9_data);
#define _OMC_LIT9 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT9)
#define _OMC_LIT10_data "The following equation is INCONSISTENT due to specified unit information:"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT10,73,_OMC_LIT10_data);
#define _OMC_LIT10 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT10)
#define _OMC_LIT11_data "\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT11,1,_OMC_LIT11_data);
#define _OMC_LIT11 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT11)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT12,1,5) {&ErrorTypes_MessageType_TRANSLATION__desc,}};
#define _OMC_LIT12 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT12)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT13,1,5) {&ErrorTypes_Severity_WARNING__desc,}};
#define _OMC_LIT13 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT13)
#define _OMC_LIT14_data "%s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT14,2,_OMC_LIT14_data);
#define _OMC_LIT14 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT14)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT15,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(6000)),_OMC_LIT12,_OMC_LIT13,_OMC_LIT14}};
#define _OMC_LIT15 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT15)
#define _OMC_LIT16_data "The units of following sub-expressions need to be equal:\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT16,57,_OMC_LIT16_data);
#define _OMC_LIT16 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT16)
#define _OMC_LIT17_data "jhagemann"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT17,9,_OMC_LIT17_data);
#define _OMC_LIT17 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT17)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT18,2,4) {&DAE_Type_T__REAL__desc,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT18 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT18)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT19,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT17,_OMC_LIT18,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT19 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT19)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT20,2,0) {_OMC_LIT19,_OMC_LIT4}};
#define _OMC_LIT20 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT20)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT21,1.0);
#define _OMC_LIT21 MMC_REFREALLIT(_OMC_LIT_STRUCT21)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT22,9,3) {&FUnit_Unit_UNIT__desc,_OMC_LIT21,MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT22 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT22)
#define _OMC_LIT23_data "."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT23,1,_OMC_LIT23_data);
#define _OMC_LIT23 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT23)
#define _OMC_LIT24_data "time"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT24,4,_OMC_LIT24_data);
#define _OMC_LIT24 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT24)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT25,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT24,_OMC_LIT18,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT25 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT25)
#define _OMC_LIT26_data "pre"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT26,3,_OMC_LIT26_data);
#define _OMC_LIT26 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT26)
#define _OMC_LIT27_data "der"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT27,3,_OMC_LIT27_data);
#define _OMC_LIT27 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT27)
#define _OMC_LIT28_data "sqrt"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT28,4,_OMC_LIT28_data);
#define _OMC_LIT28 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT28)
#define _OMC_LIT29_data "()"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT29,2,_OMC_LIT29_data);
#define _OMC_LIT29 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT29)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT30,2,4) {&DAE_Operator_SUB__desc,_OMC_LIT18}};
#define _OMC_LIT30 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT30)
#define _OMC_LIT31_data "dumpEqUCStruct"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT31,14,_OMC_LIT31_data);
#define _OMC_LIT31 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT31)
#define _OMC_LIT32_data "Dumps all the equations handled by the unit checker as tree-structure."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT32,70,_OMC_LIT32_data);
#define _OMC_LIT32 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT32)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT33,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(110)),_OMC_LIT31,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT32}};
#define _OMC_LIT33 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT33)
#define _OMC_LIT34_data "FUnitCheck.foldEquation2 failed on: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT34,36,_OMC_LIT34_data);
#define _OMC_LIT34 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT34)
#define _OMC_LIT35_data "/projects/OpenModelica-session2/OMCompiler/Compiler/FrontEnd/FUnitCheck.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT35,74,_OMC_LIT35_data);
#define _OMC_LIT35 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT35)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT36_6,1.782113391e9);
#define _OMC_LIT36_6 MMC_REFREALLIT(_OMC_LIT_STRUCT36_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT36,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT35,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(570)),MMC_IMMEDIATE(MMC_TAGFIXNUM(9)),MMC_IMMEDIATE(MMC_TAGFIXNUM(571)),MMC_IMMEDIATE(MMC_TAGFIXNUM(53)),_OMC_LIT36_6}};
#define _OMC_LIT36 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT36)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT37,1,11) {&DAE_Type_T__UNKNOWN__desc,}};
#define _OMC_LIT37 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT37)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT38,4,4) {&DAE_ComponentRef_CREF__IDENT__desc,_OMC_LIT0,_OMC_LIT37,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT38 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT38)
#define _OMC_LIT39_data "\" has the Unit \""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT39,16,_OMC_LIT39_data);
#define _OMC_LIT39 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT39)
#define _OMC_LIT40_data "dumpUnits"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT40,9,_OMC_LIT40_data);
#define _OMC_LIT40 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT40)
#define _OMC_LIT41_data "Dumps all the calculated units."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT41,31,_OMC_LIT41_data);
#define _OMC_LIT41 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT41)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT42,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(108)),_OMC_LIT40,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT41}};
#define _OMC_LIT42 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT42)
#define _OMC_LIT43_data "unitChecking"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT43,12,_OMC_LIT43_data);
#define _OMC_LIT43 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT43)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT44,1,4) {&Flags_FlagVisibility_EXTERNAL__desc,}};
#define _OMC_LIT44 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT44)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT45,2,4) {&Flags_FlagData_BOOL__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT45 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT45)
#define _OMC_LIT46_data "Enable unit checking."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT46,21,_OMC_LIT46_data);
#define _OMC_LIT46 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT46)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT47,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(31)),_OMC_LIT43,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT44,_OMC_LIT45,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT46}};
#define _OMC_LIT47 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT47)
#define _OMC_LIT48_data "checkModel"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT48,10,_OMC_LIT48_data);
#define _OMC_LIT48 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT48)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT49,1,3) {&Flags_FlagVisibility_INTERNAL__desc,}};
#define _OMC_LIT49 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT49)
#define _OMC_LIT50_data "Set when checkModel is used to turn on specific features for checking."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT50,70,_OMC_LIT50_data);
#define _OMC_LIT50 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT50)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT51,8,3) {&Flags_ConfigFlag_CONFIG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(29)),_OMC_LIT48,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT49,_OMC_LIT45,MMC_REFSTRUCTLIT(mmc_none),_OMC_LIT50}};
#define _OMC_LIT51 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT51)
#define _OMC_LIT52_data "newInst"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT52,7,_OMC_LIT52_data);
#define _OMC_LIT52 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT52)
#define _OMC_LIT53_data "Enables new instantiation phase."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT53,32,_OMC_LIT53_data);
#define _OMC_LIT53 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT53)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT54,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(66)),_OMC_LIT52,MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */)),_OMC_LIT53}};
#define _OMC_LIT54 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT54)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT55,6,3) {&FUnitCheck_Functionargs_FUNCTIONUNITS__desc,_OMC_LIT0,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT55 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT55)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT56,2,1) {_OMC_LIT55,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT56 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT56)
#define _OMC_LIT57_data "######## UnitCheck COMPLETED ########\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT57,38,_OMC_LIT57_data);
#define _OMC_LIT57 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT57)
#define _OMC_LIT58_data "FUnitCheck.checkUnits: unit check module failed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT58,47,_OMC_LIT58_data);
#define _OMC_LIT58 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT58)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT59_6,1.782113391e9);
#define _OMC_LIT59_6 MMC_REFREALLIT(_OMC_LIT_STRUCT59_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT59,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT35,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(126)),MMC_IMMEDIATE(MMC_TAGFIXNUM(5)),MMC_IMMEDIATE(MMC_TAGFIXNUM(126)),MMC_IMMEDIATE(MMC_TAGFIXNUM(91)),_OMC_LIT59_6}};
#define _OMC_LIT59 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT59)
#define _OMC_LIT60_data "FUnitCheck.checkUnits"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT60,21,_OMC_LIT60_data);
#define _OMC_LIT60 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT60)
#include "util/modelica.h"

#include "FUnitCheck_includes.h"


/* default, do not make protected functions static */
#if !defined(PROTECTED_FUNCTION_STATIC)
#define PROTECTED_FUNCTION_STATIC
#endif
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_parse(threadData_t *threadData, modelica_string _inUnitString, modelica_metatype _inCref, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_parse,2,0) {(void*) boxptr_FUnitCheck_parse,0}};
#define boxvar_FUnitCheck_parse MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_parse)
PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_parseVarList(threadData_t *threadData, modelica_metatype _invarlist);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_parseVarList,2,0) {(void*) boxptr_FUnitCheck_parseVarList,0}};
#define boxvar_FUnitCheck_parseVarList MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_parseVarList)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_convertUnitString2unit(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_convertUnitString2unit,2,0) {(void*) boxptr_FUnitCheck_convertUnitString2unit,0}};
#define boxvar_FUnitCheck_convertUnitString2unit MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_convertUnitString2unit)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_convertUnitString2unit__old(threadData_t *threadData, modelica_metatype _var, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_convertUnitString2unit__old,2,0) {(void*) boxptr_FUnitCheck_convertUnitString2unit__old,0}};
#define boxvar_FUnitCheck_convertUnitString2unit__old MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_convertUnitString2unit__old)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_addUnit2HtU2S(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_addUnit2HtU2S,2,0) {(void*) boxptr_FUnitCheck_addUnit2HtU2S,0}};
#define boxvar_FUnitCheck_addUnit2HtU2S MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_addUnit2HtU2S)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_addUnit2HtS2U(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _inHtS2U);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_addUnit2HtS2U,2,0) {(void*) boxptr_FUnitCheck_addUnit2HtS2U,0}};
#define boxvar_FUnitCheck_addUnit2HtS2U MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_addUnit2HtS2U)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldCallArg1(threadData_t *threadData, modelica_metatype _inExpList, modelica_metatype _inHtCr2U, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype _inunit, modelica_metatype _unitlist, modelica_metatype _invars, modelica_string _fname, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S, modelica_metatype *out_outExpListList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_foldCallArg1,2,0) {(void*) boxptr_FUnitCheck_foldCallArg1,0}};
#define boxvar_FUnitCheck_foldCallArg1 MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_foldCallArg1)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldCallArg(threadData_t *threadData, modelica_metatype _inExpList, modelica_metatype _inHtCr2U, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S, modelica_metatype *out_outExpListList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_foldCallArg,2,0) {(void*) boxptr_FUnitCheck_foldCallArg,0}};
#define boxvar_FUnitCheck_foldCallArg MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_foldCallArg)
PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_Errorfunction2(threadData_t *threadData, modelica_metatype _inexpList, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_Errorfunction2,2,0) {(void*) boxptr_FUnitCheck_Errorfunction2,0}};
#define boxvar_FUnitCheck_Errorfunction2 MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_Errorfunction2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_getSourceInfo(threadData_t *threadData, modelica_metatype _inequation);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_getSourceInfo,2,0) {(void*) boxptr_FUnitCheck_getSourceInfo,0}};
#define boxvar_FUnitCheck_getSourceInfo MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_getSourceInfo)
PROTECTED_FUNCTION_STATIC void omc_FUnitCheck_Errorfunction(threadData_t *threadData, modelica_metatype _inexpList, modelica_metatype _inEq, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_Errorfunction,2,0) {(void*) boxptr_FUnitCheck_Errorfunction,0}};
#define boxvar_FUnitCheck_Errorfunction MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_Errorfunction)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_updateHtCr2U(threadData_t *threadData, modelica_metatype _inCr, modelica_metatype _inUt, modelica_metatype _inHtCr2U);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_updateHtCr2U,2,0) {(void*) boxptr_FUnitCheck_updateHtCr2U,0}};
#define boxvar_FUnitCheck_updateHtCr2U MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_updateHtCr2U)
PROTECTED_FUNCTION_STATIC modelica_boolean omc_FUnitCheck_UnitTypesEqual(threadData_t *threadData, modelica_metatype _inut, modelica_metatype _inut2, modelica_metatype _inHtCr2U, modelica_metatype *out_outUt, modelica_metatype *out_outHtCr2U);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_FUnitCheck_UnitTypesEqual(threadData_t *threadData, modelica_metatype _inut, modelica_metatype _inut2, modelica_metatype _inHtCr2U, modelica_metatype *out_outUt, modelica_metatype *out_outHtCr2U);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_UnitTypesEqual,2,0) {(void*) boxptr_FUnitCheck_UnitTypesEqual,0}};
#define boxvar_FUnitCheck_UnitTypesEqual MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_UnitTypesEqual)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_getNamedUnitlist(threadData_t *threadData, modelica_string _instring, modelica_metatype _inargs, modelica_metatype *out_outargs2, modelica_metatype *out_outargs3, modelica_metatype *out_outargs4);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_getNamedUnitlist,2,0) {(void*) boxptr_FUnitCheck_getNamedUnitlist,0}};
#define boxvar_FUnitCheck_getNamedUnitlist MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_getNamedUnitlist)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_insertUnitInEquation(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTpl, modelica_metatype _inUt, modelica_metatype _inargs, modelica_metatype *out_outTpl, modelica_metatype *out_outexpList);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_insertUnitInEquation,2,0) {(void*) boxptr_FUnitCheck_insertUnitInEquation,0}};
#define boxvar_FUnitCheck_insertUnitInEquation MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_insertUnitInEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_makenewcref(threadData_t *threadData, modelica_metatype _inexp, modelica_string _instring, modelica_string _instring1);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_makenewcref,2,0) {(void*) boxptr_FUnitCheck_makenewcref,0}};
#define boxvar_FUnitCheck_makenewcref MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_makenewcref)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldEquation2(threadData_t *threadData, modelica_metatype _eq, modelica_metatype __omcQ_24in_5FhtCr2U, modelica_metatype __omcQ_24in_5FhtS2U, modelica_metatype __omcQ_24in_5FhtU2S, modelica_metatype _args, modelica_metatype *out_htS2U, modelica_metatype *out_htU2S, modelica_metatype *out_inconsistentUnits);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_foldEquation2,2,0) {(void*) boxptr_FUnitCheck_foldEquation2,0}};
#define boxvar_FUnitCheck_foldEquation2 MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_foldEquation2)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldEquation(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inargs, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_foldEquation,2,0) {(void*) boxptr_FUnitCheck_foldEquation,0}};
#define boxvar_FUnitCheck_foldEquation MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_foldEquation)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldBindingExp(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inTpl);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_foldBindingExp,2,0) {(void*) boxptr_FUnitCheck_foldBindingExp,0}};
#define boxvar_FUnitCheck_foldBindingExp MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_foldBindingExp)
PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_notification2(threadData_t *threadData, modelica_metatype _inLt1, modelica_metatype _inHtCr2U2, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_notification2,2,0) {(void*) boxptr_FUnitCheck_notification2,0}};
#define boxvar_FUnitCheck_notification2 MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_notification2)
PROTECTED_FUNCTION_STATIC void omc_FUnitCheck_notification(threadData_t *threadData, modelica_metatype _inHtCr2U1, modelica_metatype _inHtCr2U2, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_notification,2,0) {(void*) boxptr_FUnitCheck_notification,0}};
#define boxvar_FUnitCheck_notification MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_notification)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_returnVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inHtCr2U, modelica_metatype _inHtU2S);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_returnVar,2,0) {(void*) boxptr_FUnitCheck_returnVar,0}};
#define boxvar_FUnitCheck_returnVar MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_returnVar)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_updateDAElist(threadData_t *threadData, modelica_metatype _indaelist, modelica_metatype _indaevarlist);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_updateDAElist,2,0) {(void*) boxptr_FUnitCheck_updateDAElist,0}};
#define boxvar_FUnitCheck_updateDAElist MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_updateDAElist)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_parseFunctionList(threadData_t *threadData, modelica_metatype _infunction);
static const MMC_DEFSTRUCTLIT(boxvar_lit_FUnitCheck_parseFunctionList,2,0) {(void*) boxptr_FUnitCheck_parseFunctionList,0}};
#define boxvar_FUnitCheck_parseFunctionList MMC_REFSTRUCTLIT(boxvar_lit_FUnitCheck_parseFunctionList)

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_parse(threadData_t *threadData, modelica_string _inUnitString, modelica_metatype _inCref, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S)
{
  jmp_buf *old_mmc_jumper = threadData->mmc_jumper;
  modelica_metatype _outUnit = NULL;
  modelica_metatype _outHtS2U = NULL;
  modelica_metatype _outHtU2S = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUnit has no default value.
  _outHtS2U = _inHtS2U;
  _outHtU2S = _inHtU2S;
  if((stringEqual(_inUnitString, _OMC_LIT0)))
  {
    tmpMeta1 = mmc_mk_cons(_inCref, MMC_REFSTRUCTLIT(mmc_nil));
    tmpMeta2 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta1);
    _outUnit = tmpMeta2;

    goto _return;
  }

  { /* matchcontinue expression */
    {
      volatile mmc_switch_type tmp5;
      int tmp6;
      tmp5 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp4_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp5 < 2; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          /* Pattern matching succeeded */
          _outUnit = omc_BaseHashTable_get(threadData, _inUnitString, _inHtS2U);
          goto tmp4_done;
        }
        case 1: {
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          /* Pattern matching succeeded */
          { /* matchcontinue expression */
            {
              volatile mmc_switch_type tmp9;
              int tmp10;
              tmp9 = 0;
              MMC_TRY_INTERNAL(mmc_jumper)
              tmp8_top:
              threadData->mmc_jumper = &new_mmc_jumper;
              for (; tmp9 < 2; tmp9++) {
                switch (MMC_SWITCH_CAST(tmp9)) {
                case 0: {
                  /* Pattern matching succeeded */
                  _outUnit = omc_FUnit_parseUnitString(threadData, _inUnitString, _inHtS2U);
                  goto tmp8_done;
                }
                case 1: {
                  modelica_metatype tmpMeta11;
                  /* Pattern matching succeeded */
                  tmpMeta11 = mmc_mk_box2(5, &FUnit_Unit_UNKNOWN__desc, _inUnitString);
                  _outUnit = tmpMeta11;
                  goto tmp8_done;
                }
                }
                goto tmp8_end;
                tmp8_end: ;
              }
              goto goto_7;
              tmp8_done:
              (void)tmp9;
              MMC_RESTORE_INTERNAL(mmc_jumper);
              goto tmp8_done2;
              goto_7:;
              MMC_CATCH_INTERNAL(mmc_jumper);
              if (++tmp9 < 2) {
                goto tmp8_top;
              }
              goto goto_3;
              tmp8_done2:;
            }
          }
          ;

          tmpMeta12 = mmc_mk_box2(0, _inUnitString, _outUnit);
          _outHtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta12, _outHtS2U);

          tmpMeta13 = mmc_mk_box2(0, _inUnitString, _outUnit);
          _outHtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta13, _outHtU2S);
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      tmp4_done:
      (void)tmp5;
      MMC_RESTORE_INTERNAL(mmc_jumper);
      goto tmp4_done2;
      goto_3:;
      MMC_CATCH_INTERNAL(mmc_jumper);
      if (++tmp5 < 2) {
        goto tmp4_top;
      }
      MMC_THROW_INTERNAL();
      tmp4_done2:;
    }
  }
  ;
  _return: OMC_LABEL_UNUSED
  if (out_outHtS2U) { *out_outHtS2U = _outHtS2U; }
  if (out_outHtU2S) { *out_outHtU2S = _outHtU2S; }
  threadData->mmc_jumper = old_mmc_jumper;
  return _outUnit;
}

DLLDirection
modelica_string omc_FUnitCheck_getStringFromExp(threadData_t *threadData, modelica_metatype _binding)
{
  modelica_string _str = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _binding;
    {
      modelica_string _str1 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _str1 has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,0) == 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT0;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,2,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _str1 = tmpMeta7;
          /* Pattern matching succeeded */
          tmp1 = _str1;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT1;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _str = tmp1;
  _return: OMC_LABEL_UNUSED
  return _str;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_parseVarList(threadData_t *threadData, modelica_metatype _invarlist)
{
  modelica_string _outstring = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outstring has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _invarlist;
    {
      modelica_metatype _varlist = NULL;
      modelica_metatype _eqbind = NULL;
      modelica_string _name = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _varlist has no default value.
      // _eqbind has no default value.
      // _name 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);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          
          _name = tmpMeta8;
          _eqbind = tmpMeta9;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(stringEqual(_name, _OMC_LIT2))) goto tmp3_end;
          tmp1 = omc_FUnitCheck_getStringFromExp(threadData, _eqbind);
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_1);
          tmpMeta11 = MMC_CDR(tmp4_1);
          _varlist = tmpMeta11;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _invarlist = _varlist;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          if (!listEmpty(tmp4_1)) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT1;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outstring = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outstring;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_convertUnitString2unit(threadData_t *threadData, modelica_metatype _var, 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 = _var;
    tmp4_2 = _inTpl;
    {
      modelica_string _unitString = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _ut = NULL;
      modelica_metatype _varlst = NULL;
      modelica_metatype _HtS2U = NULL;
      modelica_metatype _HtU2S = NULL;
      modelica_metatype _HtCr2U = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _unitString has no default value.
      // _cr has no default value.
      // _ut has no default value.
      // _varlst has no default value.
      // _HtS2U has no default value.
      // _HtU2S has no default value.
      // _HtCr2U has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta6;
          _varlst = tmpMeta8;
          _HtCr2U = tmpMeta9;
          _HtS2U = tmpMeta10;
          _HtU2S = tmpMeta11;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!0 /* false */ == !listEmpty(_varlst))) goto tmp3_end;
          _unitString = omc_FUnitCheck_parseVarList(threadData, _varlst);

          _ut = omc_FUnitCheck_parse(threadData, _unitString, _cr, _HtS2U, _HtU2S ,&_HtS2U ,&_HtU2S);

          tmpMeta12 = mmc_mk_box2(0, _cr, _ut);
          _HtCr2U = omc_BaseHashTable_add(threadData, tmpMeta12, _HtCr2U);
          tmpMeta13 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta13;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta14;
          _HtCr2U = tmpMeta15;
          _HtS2U = tmpMeta16;
          _HtU2S = tmpMeta17;
          /* Pattern matching succeeded */
          tmpMeta18 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta19 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta18);
          tmpMeta20 = mmc_mk_box2(0, _cr, tmpMeta19);
          _HtCr2U = omc_BaseHashTable_add(threadData, tmpMeta20, _HtCr2U);

          tmpMeta21 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta22 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta21);
          tmpMeta23 = mmc_mk_box2(0, _OMC_LIT3, tmpMeta22);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta23, _HtS2U);

          tmpMeta24 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta25 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta24);
          tmpMeta26 = mmc_mk_box2(0, _OMC_LIT3, tmpMeta25);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta26, _HtU2S);
          tmpMeta27 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta27;
          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_FUnitCheck_convertUnitString2unit__old(threadData_t *threadData, modelica_metatype _var, 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 = _var;
    tmp4_2 = _inTpl;
    {
      modelica_string _unitString = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _ut = NULL;
      modelica_metatype _HtS2U = NULL;
      modelica_metatype _HtU2S = NULL;
      modelica_metatype _HtCr2U = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _unitString has no default value.
      // _cr has no default value.
      // _ut has no default value.
      // _HtS2U has no default value.
      // _HtU2S has no default value.
      // _HtCr2U has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 12));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta9,0,15) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
          if (optionNone(tmpMeta10)) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta11,2,1) == 0) goto tmp3_end;
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta11), 2));
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta6;
          _unitString = tmpMeta12;
          _HtCr2U = tmpMeta13;
          _HtS2U = tmpMeta14;
          _HtU2S = tmpMeta15;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!stringEqual(_unitString, _OMC_LIT0))) goto tmp3_end;
          _ut = omc_FUnitCheck_parse(threadData, _unitString, _cr, _HtS2U, _HtU2S ,&_HtS2U ,&_HtU2S);

          tmpMeta16 = mmc_mk_box2(0, _cr, _ut);
          _HtCr2U = omc_BaseHashTable_add(threadData, tmpMeta16, _HtCr2U);
          tmpMeta17 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta17;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _cr = tmpMeta18;
          _HtCr2U = tmpMeta19;
          _HtS2U = tmpMeta20;
          _HtU2S = tmpMeta21;
          /* Pattern matching succeeded */
          tmpMeta22 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta23 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta22);
          tmpMeta24 = mmc_mk_box2(0, _cr, tmpMeta23);
          _HtCr2U = omc_BaseHashTable_add(threadData, tmpMeta24, _HtCr2U);

          tmpMeta25 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta26 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta25);
          tmpMeta27 = mmc_mk_box2(0, _OMC_LIT3, tmpMeta26);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta27, _HtS2U);

          tmpMeta28 = mmc_mk_cons(_cr, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta29 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, tmpMeta28);
          tmpMeta30 = mmc_mk_box2(0, _OMC_LIT3, tmpMeta29);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta30, _HtU2S);
          tmpMeta31 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta31;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_addUnit2HtU2S(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _inHtU2S)
{
  modelica_metatype _outHtU2S = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHtU2S has no default value.
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;
    tmp4_1 = _inTpl;
    {
      modelica_string _s = NULL;
      modelica_metatype _ut = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _s has no default value.
      // _ut 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), 1));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _s = tmpMeta6;
          _ut = tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp8 = omc_BaseHashTable_hasKey(threadData, _ut, _inHtU2S);
          if (0 /* false */ != tmp8) goto goto_2;
          tmpMeta9 = mmc_mk_box2(0, _ut, _s);
          tmpMeta1 = omc_BaseHashTable_add(threadData, tmpMeta9, _inHtU2S);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inHtU2S;
          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:;
    }
  }
  _outHtU2S = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHtU2S;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_addUnit2HtS2U(threadData_t *threadData, modelica_metatype _inTpl, modelica_metatype _inHtS2U)
{
  modelica_metatype _outHtS2U = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHtS2U has no default value.
  _outHtS2U = omc_BaseHashTable_add(threadData, _inTpl, _inHtS2U);
  _return: OMC_LABEL_UNUSED
  return _outHtS2U;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldCallArg1(threadData_t *threadData, modelica_metatype _inExpList, modelica_metatype _inHtCr2U, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype _inunit, modelica_metatype _unitlist, modelica_metatype _invars, modelica_string _fname, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S, modelica_metatype *out_outExpListList)
{
  modelica_metatype _outHtCr2U = NULL;
  modelica_metatype _outHtS2U = NULL;
  modelica_metatype _outHtU2S = NULL;
  modelica_metatype _outExpListList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _expListList = NULL;
  modelica_metatype _ut = NULL;
  modelica_metatype _ut1 = NULL;
  modelica_string _s = NULL;
  modelica_string _formalarg = NULL;
  modelica_string _formalvar = NULL;
  modelica_metatype _exp = NULL;
  modelica_metatype _temp = NULL;
  modelica_boolean _b;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_integer tmp15;
  modelica_integer tmp16;
  modelica_integer tmp17;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outHtCr2U = _inHtCr2U;
  _outHtS2U = _inHtS2U;
  _outHtU2S = _inHtU2S;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outExpListList = tmpMeta1;
  // _expListList has no default value.
  // _ut has no default value.
  // _ut1 has no default value.
  // _s has no default value.
  // _formalarg has no default value.
  // _formalvar has no default value.
  // _exp has no default value.
  // _temp has no default value.
  // _b has no default value.
  tmp15 = ((modelica_integer) 1); tmp16 = 1; tmp17 = listLength(_inExpList);
  if(!(((tmp16 > 0) && (tmp15 > tmp17)) || ((tmp16 < 0) && (tmp15 < tmp17))))
  {
    modelica_integer _i;
    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp15, tmp17); _i += tmp16)
    {
      _exp = listGet(_inExpList, _i);

      _formalarg = listGet(_unitlist, _i);

      _formalvar = listGet(_invars, _i);

      /* Pattern-matching tuple assignment */
      tmpMeta7 = mmc_mk_box3(0, _outHtCr2U, _outHtS2U, _outHtU2S);
      tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
      tmpMeta9 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp, tmpMeta7, _inunit, tmpMeta8, &tmpMeta2, &tmpMeta6);
      _ut = tmpMeta9;
      tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
      _outHtCr2U = tmpMeta3;
      _outHtS2U = tmpMeta4;
      _outHtU2S = tmpMeta5;
      _expListList = tmpMeta6;

      if((stringEqual(_formalarg, _OMC_LIT5)))
      {
        _ut1 = _OMC_LIT4;
      }
      else
      {
        _ut1 = omc_FUnit_parseUnitString(threadData, _formalarg, omc_FUnit_getKnownUnits(threadData));
      }

      _s = omc_FUnit_unitString(threadData, _ut, _outHtU2S);

      _b = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut1, _outHtCr2U ,&_ut ,NULL);

      if((!_b == !1 /* true */))
      {
        tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
        _expListList = tmpMeta10;
      }
      else
      {
        _temp = omc_FUnitCheck_makenewcref(threadData, _exp, _formalvar, _fname);

        tmpMeta13 = mmc_mk_box2(0, _exp, _ut);
        tmpMeta14 = mmc_mk_box2(0, _temp, _ut1);
        tmpMeta12 = mmc_mk_cons(tmpMeta13, mmc_mk_cons(tmpMeta14, MMC_REFSTRUCTLIT(mmc_nil)));
        tmpMeta11 = mmc_mk_cons(tmpMeta12, MMC_REFSTRUCTLIT(mmc_nil));
        _expListList = tmpMeta11;
      }

      _outExpListList = omc_List_append__reverse(threadData, _expListList, _outExpListList);
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_outHtS2U) { *out_outHtS2U = _outHtS2U; }
  if (out_outHtU2S) { *out_outHtU2S = _outHtU2S; }
  if (out_outExpListList) { *out_outExpListList = _outExpListList; }
  return _outHtCr2U;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldCallArg(threadData_t *threadData, modelica_metatype _inExpList, modelica_metatype _inHtCr2U, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S, modelica_metatype *out_outHtS2U, modelica_metatype *out_outHtU2S, modelica_metatype *out_outExpListList)
{
  modelica_metatype _outHtCr2U = NULL;
  modelica_metatype _outHtS2U = NULL;
  modelica_metatype _outHtU2S = NULL;
  modelica_metatype _outExpListList = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _expListList = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outHtCr2U = _inHtCr2U;
  _outHtS2U = _inHtS2U;
  _outHtU2S = _inHtU2S;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _outExpListList = tmpMeta1;
  // _expListList has no default value.
  {
    modelica_metatype _exp;
    for (tmpMeta2 = _inExpList; !listEmpty(tmpMeta2); tmpMeta2=MMC_CDR(tmpMeta2))
    {
      _exp = MMC_CAR(tmpMeta2);
      /* Pattern-matching tuple assignment, wild first pattern */
      tmpMeta8 = mmc_mk_box3(0, _outHtCr2U, _outHtS2U, _outHtU2S);
      tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
      omc_FUnitCheck_insertUnitInEquation(threadData, _exp, tmpMeta8, _OMC_LIT4, tmpMeta9, &tmpMeta3, &tmpMeta7);
      tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 1));
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 2));
      tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta3), 3));
      _outHtCr2U = tmpMeta4;
      _outHtS2U = tmpMeta5;
      _outHtU2S = tmpMeta6;
      _expListList = tmpMeta7;

      _outExpListList = omc_List_append__reverse(threadData, _expListList, _outExpListList);
    }
  }

  _outExpListList = listReverse(_outExpListList);
  _return: OMC_LABEL_UNUSED
  if (out_outHtS2U) { *out_outHtS2U = _outHtS2U; }
  if (out_outHtU2S) { *out_outHtU2S = _outHtU2S; }
  if (out_outExpListList) { *out_outExpListList = _outExpListList; }
  return _outHtCr2U;
}

DLLDirection
modelica_metatype omc_FUnitCheck_GetElementList(threadData_t *threadData, modelica_metatype _eqlist)
{
  modelica_metatype _outstring = NULL;
  modelica_metatype _eq1 = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outstring has no default value.
  // _eq1 has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _eqlist;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _eq1 = tmpMeta6;
          /* Pattern matching succeeded */
          tmpMeta1 = _eq1;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outstring = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outstring;
}

DLLDirection
modelica_metatype omc_FUnitCheck_GetVarList(threadData_t *threadData, modelica_metatype _indaelist)
{
  modelica_metatype _outstring = NULL;
  modelica_metatype _varlist = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outstring has no default value.
  // _varlist has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _indaelist;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,18,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          _varlist = tmpMeta9;
          /* Pattern matching succeeded */
          tmpMeta1 = _varlist;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          
          /* Pattern matching succeeded */
          tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta1 = tmpMeta10;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outstring = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outstring;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_Errorfunction2(threadData_t *threadData, modelica_metatype _inexpList, modelica_metatype _inHtU2S)
{
  modelica_string _outS = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outS has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inexpList;
    {
      modelica_metatype _expList = NULL;
      modelica_metatype _exp = NULL;
      modelica_metatype _ut = NULL;
      modelica_string _s = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _expList has no default value.
      // _exp has no default value.
      // _ut has no default value.
      // _s has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_1);
          tmpMeta7 = MMC_CDR(tmp4_1);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          if (!listEmpty(tmpMeta7)) goto tmp3_end;
          _exp = tmpMeta8;
          _ut = tmpMeta9;
          /* Pattern matching succeeded */
          _s = omc_ExpressionBasics_printExpStr(threadData, _exp);

          _s1 = omc_FUnit_unitString(threadData, _ut, _inHtU2S);
          tmpMeta10 = stringAppend(_OMC_LIT6,_s);
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT7);
          tmpMeta12 = stringAppend(tmpMeta11,_s1);
          tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT8);
          tmp1 = tmpMeta13;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (listEmpty(tmp4_1)) goto tmp3_end;
          tmpMeta14 = MMC_CAR(tmp4_1);
          tmpMeta15 = MMC_CDR(tmp4_1);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 1));
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 2));
          _exp = tmpMeta16;
          _ut = tmpMeta17;
          _expList = tmpMeta15;
          /* Pattern matching succeeded */
          _s = omc_ExpressionBasics_printExpStr(threadData, _exp);

          _s1 = omc_FUnit_unitString(threadData, _ut, _inHtU2S);

          _s2 = omc_FUnitCheck_Errorfunction2(threadData, _expList, _inHtU2S);
          tmpMeta18 = stringAppend(_OMC_LIT6,_s);
          tmpMeta19 = stringAppend(tmpMeta18,_OMC_LIT7);
          tmpMeta20 = stringAppend(tmpMeta19,_s1);
          tmpMeta21 = stringAppend(tmpMeta20,_OMC_LIT9);
          tmpMeta22 = stringAppend(tmpMeta21,_s2);
          tmp1 = tmpMeta22;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outS = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outS;
}

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

PROTECTED_FUNCTION_STATIC void omc_FUnitCheck_Errorfunction(threadData_t *threadData, modelica_metatype _inexpList, modelica_metatype _inEq, modelica_metatype _inHtU2S)
{
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  { /* match expression */
    modelica_metatype tmp3_1;
    tmp3_1 = _inexpList;
    {
      modelica_string _s = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      modelica_metatype _expList = NULL;
      modelica_metatype _info = NULL;
      volatile mmc_switch_type tmp3;
      int tmp4;
      // _s has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      // _expList has no default value.
      // _info has no default value.
      tmp3 = 0;
      for (; tmp3 < 1; tmp3++) {
        switch (MMC_SWITCH_CAST(tmp3)) {
        case 0: {
          modelica_metatype tmpMeta5;
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          
          _expList = tmp3_1;
          /* Pattern matching succeeded */
          _info = omc_FUnitCheck_getSourceInfo(threadData, _inEq);

          _s = omc_DAEDump_dumpEquationStr(threadData, _inEq);

          _s1 = omc_FUnitCheck_Errorfunction2(threadData, _expList, _inHtU2S);

          tmpMeta5 = stringAppend(_OMC_LIT10,_s);
          tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT11);
          _s2 = tmpMeta6;

          tmpMeta7 = mmc_mk_cons(_s2, MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addSourceMessage(threadData, _OMC_LIT15, tmpMeta7, _info);

          tmpMeta8 = stringAppend(_OMC_LIT16,_s1);
          omc_Error_addCompilerWarning(threadData, tmpMeta8);
          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 modelica_metatype omc_FUnitCheck_updateHtCr2U(threadData_t *threadData, modelica_metatype _inCr, modelica_metatype _inUt, modelica_metatype _inHtCr2U)
{
  modelica_metatype _outHtCr2U = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outHtCr2U has no default value.
  { /* matchcontinue expression */
    {
      modelica_metatype _HtCr2U = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _HtCr2U has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_boolean tmp6;
          modelica_metatype tmpMeta7;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp6 = omc_BaseHashTable_hasKey(threadData, _OMC_LIT19, _inHtCr2U);
          if (1 /* true */ != tmp6) goto goto_2;

          tmpMeta7 = mmc_mk_box2(0, _inCr, _inUt);
          omc_BaseHashTable_update(threadData, tmpMeta7, _inHtCr2U);
          tmpMeta1 = _inHtCr2U;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta8;
          /* Pattern matching succeeded */
          _HtCr2U = omc_BaseHashTable_add(threadData, _OMC_LIT20, _inHtCr2U);

          tmpMeta8 = mmc_mk_box2(0, _inCr, _inUt);
          omc_BaseHashTable_update(threadData, tmpMeta8, _HtCr2U);
          tmpMeta1 = _HtCr2U;
          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:;
    }
  }
  _outHtCr2U = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outHtCr2U;
}

PROTECTED_FUNCTION_STATIC modelica_boolean omc_FUnitCheck_UnitTypesEqual(threadData_t *threadData, modelica_metatype _inut, modelica_metatype _inut2, modelica_metatype _inHtCr2U, modelica_metatype *out_outUt, modelica_metatype *out_outHtCr2U)
{
  modelica_boolean _b;
  modelica_metatype _outUt = NULL;
  modelica_metatype _outHtCr2U = NULL;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _outUt has no default value.
  // _outHtCr2U has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;
    tmp4_1 = _inut;
    tmp4_2 = _inut2;
    {
      modelica_string _s = NULL;
      modelica_string _s2 = NULL;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_integer _i3;
      modelica_integer _i4;
      modelica_integer _i5;
      modelica_integer _i6;
      modelica_integer _i7;
      modelica_integer _j1;
      modelica_integer _j2;
      modelica_integer _j3;
      modelica_integer _j4;
      modelica_integer _j5;
      modelica_integer _j6;
      modelica_integer _j7;
      modelica_metatype _lcr = NULL;
      modelica_metatype _lcr2 = NULL;
      modelica_metatype _HtCr2U = NULL;
      modelica_real _factor1;
      modelica_real _factor2;
      modelica_real _r;
      modelica_metatype _ut = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _s has no default value.
      // _s2 has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _i3 has no default value.
      // _i4 has no default value.
      // _i5 has no default value.
      // _i6 has no default value.
      // _i7 has no default value.
      // _j1 has no default value.
      // _j2 has no default value.
      // _j3 has no default value.
      // _j4 has no default value.
      // _j5 has no default value.
      // _j6 has no default value.
      // _j7 has no default value.
      // _lcr has no default value.
      // _lcr2 has no default value.
      // _HtCr2U has no default value.
      // _factor1 has no default value.
      // _factor2 has no default value.
      // _r has no default value.
      // _ut 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_real tmp7;
          modelica_metatype tmpMeta8;
          modelica_integer tmp9;
          modelica_metatype tmpMeta10;
          modelica_integer tmp11;
          modelica_metatype tmpMeta12;
          modelica_integer tmp13;
          modelica_metatype tmpMeta14;
          modelica_integer tmp15;
          modelica_metatype tmpMeta16;
          modelica_integer tmp17;
          modelica_metatype tmpMeta18;
          modelica_integer tmp19;
          modelica_metatype tmpMeta20;
          modelica_integer tmp21;
          modelica_metatype tmpMeta22;
          modelica_real tmp23;
          modelica_metatype tmpMeta24;
          modelica_integer tmp25;
          modelica_metatype tmpMeta26;
          modelica_integer tmp27;
          modelica_metatype tmpMeta28;
          modelica_integer tmp29;
          modelica_metatype tmpMeta30;
          modelica_integer tmp31;
          modelica_metatype tmpMeta32;
          modelica_integer tmp33;
          modelica_metatype tmpMeta34;
          modelica_integer tmp35;
          modelica_metatype tmpMeta36;
          modelica_integer tmp37;
          modelica_boolean tmp38;
          modelica_boolean tmp39;
          modelica_boolean tmp40;
          modelica_boolean tmp41;
          modelica_boolean tmp42;
          modelica_boolean tmp43;
          modelica_boolean tmp44;
          modelica_boolean tmp45;
          modelica_metatype tmpMeta46;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp7 = mmc_unbox_real(tmpMeta6);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp9 = mmc_unbox_integer(tmpMeta8);
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp11 = mmc_unbox_integer(tmpMeta10);
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp15 = mmc_unbox_integer(tmpMeta14);
          tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp17 = mmc_unbox_integer(tmpMeta16);
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmp19 = mmc_unbox_integer(tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmp21 = mmc_unbox_integer(tmpMeta20);
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,0,8) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp23 = mmc_unbox_real(tmpMeta22);
          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);
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmp31 = mmc_unbox_integer(tmpMeta30);
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp33 = mmc_unbox_integer(tmpMeta32);
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 8));
          tmp35 = mmc_unbox_integer(tmpMeta34);
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 9));
          tmp37 = mmc_unbox_integer(tmpMeta36);
          _factor1 = tmp7  /* pattern as ty=Real */;
          _i1 = tmp9  /* pattern as ty=Integer */;
          _i2 = tmp11  /* pattern as ty=Integer */;
          _i3 = tmp13  /* pattern as ty=Integer */;
          _i4 = tmp15  /* pattern as ty=Integer */;
          _i5 = tmp17  /* pattern as ty=Integer */;
          _i6 = tmp19  /* pattern as ty=Integer */;
          _i7 = tmp21  /* pattern as ty=Integer */;
          _factor2 = tmp23  /* pattern as ty=Real */;
          _j1 = tmp25  /* pattern as ty=Integer */;
          _j2 = tmp27  /* pattern as ty=Integer */;
          _j3 = tmp29  /* pattern as ty=Integer */;
          _j4 = tmp31  /* pattern as ty=Integer */;
          _j5 = tmp33  /* pattern as ty=Integer */;
          _j6 = tmp35  /* pattern as ty=Integer */;
          _j7 = tmp37  /* pattern as ty=Integer */;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp38 = (_factor1 == _factor2);
          if (1 /* true */ != tmp38) goto goto_2;

          /* Pattern-matching assignment */
          tmp39 = (_i1 == _j1);
          if (1 /* true */ != tmp39) goto goto_2;

          /* Pattern-matching assignment */
          tmp40 = (_i2 == _j2);
          if (1 /* true */ != tmp40) goto goto_2;

          /* Pattern-matching assignment */
          tmp41 = (_i3 == _j3);
          if (1 /* true */ != tmp41) goto goto_2;

          /* Pattern-matching assignment */
          tmp42 = (_i4 == _j4);
          if (1 /* true */ != tmp42) goto goto_2;

          /* Pattern-matching assignment */
          tmp43 = (_i5 == _j5);
          if (1 /* true */ != tmp43) goto goto_2;

          /* Pattern-matching assignment */
          tmp44 = (_i6 == _j6);
          if (1 /* true */ != tmp44) goto goto_2;

          /* Pattern-matching assignment */
          tmp45 = (_i7 == _j7);
          if (1 /* true */ != tmp45) goto goto_2;
          tmpMeta46 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta46;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta47;
          modelica_real tmp48;
          modelica_metatype tmpMeta49;
          modelica_integer tmp50;
          modelica_metatype tmpMeta51;
          modelica_integer tmp52;
          modelica_metatype tmpMeta53;
          modelica_integer tmp54;
          modelica_metatype tmpMeta55;
          modelica_integer tmp56;
          modelica_metatype tmpMeta57;
          modelica_integer tmp58;
          modelica_metatype tmpMeta59;
          modelica_integer tmp60;
          modelica_metatype tmpMeta61;
          modelica_integer tmp62;
          modelica_metatype tmpMeta63;
          modelica_real tmp64;
          modelica_metatype tmpMeta65;
          modelica_integer tmp66;
          modelica_metatype tmpMeta67;
          modelica_integer tmp68;
          modelica_metatype tmpMeta69;
          modelica_integer tmp70;
          modelica_metatype tmpMeta71;
          modelica_integer tmp72;
          modelica_metatype tmpMeta73;
          modelica_integer tmp74;
          modelica_metatype tmpMeta75;
          modelica_integer tmp76;
          modelica_metatype tmpMeta77;
          modelica_integer tmp78;
          modelica_real tmp79;
          modelica_boolean tmp80;
          modelica_boolean tmp81;
          modelica_boolean tmp82;
          modelica_boolean tmp83;
          modelica_boolean tmp84;
          modelica_boolean tmp85;
          modelica_boolean tmp86;
          modelica_boolean tmp87;
          modelica_metatype tmpMeta88;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          tmpMeta47 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmp48 = mmc_unbox_real(tmpMeta47);
          tmpMeta49 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmp50 = mmc_unbox_integer(tmpMeta49);
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmp52 = mmc_unbox_integer(tmpMeta51);
          tmpMeta53 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 5));
          tmp54 = mmc_unbox_integer(tmpMeta53);
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 6));
          tmp56 = mmc_unbox_integer(tmpMeta55);
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          tmp58 = mmc_unbox_integer(tmpMeta57);
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          tmp60 = mmc_unbox_integer(tmpMeta59);
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 9));
          tmp62 = mmc_unbox_integer(tmpMeta61);
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,0,8) == 0) goto tmp3_end;
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp64 = mmc_unbox_real(tmpMeta63);
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmp66 = mmc_unbox_integer(tmpMeta65);
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          tmp68 = mmc_unbox_integer(tmpMeta67);
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 5));
          tmp70 = mmc_unbox_integer(tmpMeta69);
          tmpMeta71 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 6));
          tmp72 = mmc_unbox_integer(tmpMeta71);
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 7));
          tmp74 = mmc_unbox_integer(tmpMeta73);
          tmpMeta75 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 8));
          tmp76 = mmc_unbox_integer(tmpMeta75);
          tmpMeta77 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 9));
          tmp78 = mmc_unbox_integer(tmpMeta77);
          _factor1 = tmp48  /* pattern as ty=Real */;
          _i1 = tmp50  /* pattern as ty=Integer */;
          _i2 = tmp52  /* pattern as ty=Integer */;
          _i3 = tmp54  /* pattern as ty=Integer */;
          _i4 = tmp56  /* pattern as ty=Integer */;
          _i5 = tmp58  /* pattern as ty=Integer */;
          _i6 = tmp60  /* pattern as ty=Integer */;
          _i7 = tmp62  /* pattern as ty=Integer */;
          _factor2 = tmp64  /* pattern as ty=Real */;
          _j1 = tmp66  /* pattern as ty=Integer */;
          _j2 = tmp68  /* pattern as ty=Integer */;
          _j3 = tmp70  /* pattern as ty=Integer */;
          _j4 = tmp72  /* pattern as ty=Integer */;
          _j5 = tmp74  /* pattern as ty=Integer */;
          _j6 = tmp76  /* pattern as ty=Integer */;
          _j7 = tmp78  /* pattern as ty=Integer */;
          tmp4 += 6; /* Pattern matching succeeded; we may skip some cases if we fail */
          _r = fmax(fabs(_factor1),fabs(_factor2));

          /* Pattern-matching assignment */
          tmp79 = _r;
          if (tmp79 == 0) {goto goto_2;}
          tmp80 = ((fabs(_factor1 - _factor2)) / tmp79 <= 0.001);
          if (1 /* true */ != tmp80) goto goto_2;

          /* Pattern-matching assignment */
          tmp81 = (_i1 == _j1);
          if (1 /* true */ != tmp81) goto goto_2;

          /* Pattern-matching assignment */
          tmp82 = (_i2 == _j2);
          if (1 /* true */ != tmp82) goto goto_2;

          /* Pattern-matching assignment */
          tmp83 = (_i3 == _j3);
          if (1 /* true */ != tmp83) goto goto_2;

          /* Pattern-matching assignment */
          tmp84 = (_i4 == _j4);
          if (1 /* true */ != tmp84) goto goto_2;

          /* Pattern-matching assignment */
          tmp85 = (_i5 == _j5);
          if (1 /* true */ != tmp85) goto goto_2;

          /* Pattern-matching assignment */
          tmp86 = (_i6 == _j6);
          if (1 /* true */ != tmp86) goto goto_2;

          /* Pattern-matching assignment */
          tmp87 = (_i7 == _j7);
          if (1 /* true */ != tmp87) goto goto_2;
          tmpMeta88 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta88;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta89;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,1) == 0) goto tmp3_end;
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _ut = tmp4_1;
          _lcr = tmpMeta89;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _inHtCr2U);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _ut;
          tmpMeta[0+2] = _HtCr2U;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta90;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          tmpMeta90 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,0,8) == 0) goto tmp3_end;
          
          _lcr = tmpMeta90;
          _ut = tmp4_2;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _inHtCr2U);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = _ut;
          tmpMeta[0+2] = _HtCr2U;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,1) == 0) goto tmp3_end;
          tmpMeta91 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,1,1) == 0) goto tmp3_end;
          tmpMeta92 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _lcr = tmpMeta91;
          _lcr2 = tmpMeta92;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _lcr2 = omc_List_append__reverse(threadData, _lcr, _lcr2);
          tmpMeta93 = mmc_mk_box2(4, &FUnit_Unit_MASTER__desc, _lcr2);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta93;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_boolean tmp96;
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,1) == 0) goto tmp3_end;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,2,1) == 0) goto tmp3_end;
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          _s = tmpMeta94;
          _s2 = tmpMeta95;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp96 = (stringEqual(_s, _s2));
          if (1 /* true */ != tmp96) goto goto_2;
          tmpMeta97 = mmc_mk_box2(5, &FUnit_Unit_UNKNOWN__desc, _s);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta97;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,1) == 0) goto tmp3_end;
          tmpMeta98 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _s = tmpMeta98;
          /* Pattern matching succeeded */
          tmpMeta99 = mmc_mk_box2(5, &FUnit_Unit_UNKNOWN__desc, _s);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta99;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta100;
          modelica_metatype tmpMeta101;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_2,2,1) == 0) goto tmp3_end;
          tmpMeta100 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          
          _s = tmpMeta100;
          /* Pattern matching succeeded */
          tmpMeta101 = mmc_mk_box2(5, &FUnit_Unit_UNKNOWN__desc, _s);
          tmp1_c0 = 1 /* true */;
          tmpMeta[0+1] = tmpMeta101;
          tmpMeta[0+2] = _inHtCr2U;
          goto tmp3_done;
        }
        case 8: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = 0 /* false */;
          tmpMeta[0+1] = _inut;
          tmpMeta[0+2] = _inHtCr2U;
          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:;
    }
  }
  _b = tmp1_c0;
  _outUt = tmpMeta[0+1];
  _outHtCr2U = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_outUt) { *out_outUt = _outUt; }
  if (out_outHtCr2U) { *out_outHtCr2U = _outHtCr2U; }
  return _b;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_FUnitCheck_UnitTypesEqual(threadData_t *threadData, modelica_metatype _inut, modelica_metatype _inut2, modelica_metatype _inHtCr2U, modelica_metatype *out_outUt, modelica_metatype *out_outHtCr2U)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_FUnitCheck_UnitTypesEqual(threadData, _inut, _inut2, _inHtCr2U, out_outUt, out_outHtCr2U);
  out_b = mmc_mk_icon(_b);
  /* skip box _outUt; FUnit.Unit */
  /* skip box _outHtCr2U; tuple<array<list<tuple<DAE.ComponentRef, #Integer>>>, tuple<#Integer, #Integer, array<Option<tuple<DAE.ComponentRef, FUnit.Unit>>>>, #Integer, tuple<.FHashTableCrToUnit.FuncHashKey<function>(DAE.ComponentRef cr) => #Integer, .FHashTableCrToUnit.FuncKeyEqual<function>(DAE.ComponentRef cr1, DAE.ComponentRef cr2) => #Boolean, .FHashTableCrToUnit.FuncKeyStr<function>(DAE.ComponentRef cr) => String, .FHashTableCrToUnit.FuncValueStr<function>(FUnit.Unit exp) => String>> */
  return out_b;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_getNamedUnitlist(threadData_t *threadData, modelica_string _instring, modelica_metatype _inargs, modelica_metatype *out_outargs2, modelica_metatype *out_outargs3, modelica_metatype *out_outargs4)
{
  modelica_metatype _outargs = NULL;
  modelica_metatype _outargs2 = NULL;
  modelica_metatype _outargs3 = NULL;
  modelica_metatype _outargs4 = NULL;
  modelica_metatype tmpMeta[4] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outargs has no default value.
  // _outargs2 has no default value.
  // _outargs3 has no default value.
  // _outargs4 has no default value.
  
  
  
  
  { /* match expression */
    modelica_string tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _instring;
    tmp4_2 = _inargs;
    {
      modelica_metatype _rest = NULL;
      modelica_string _fnname = NULL;
      modelica_string _fnname1 = NULL;
      modelica_metatype _invars = NULL;
      modelica_metatype _inunitlist = NULL;
      modelica_metatype _outunitlist = NULL;
      modelica_metatype _outvars = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _rest has no default value.
      // _fnname has no default value.
      // _fnname1 has no default value.
      // _invars has no default value.
      // _inunitlist has no default value.
      // _outunitlist has no default value.
      // _outvars has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_2);
          tmpMeta7 = MMC_CDR(tmp4_2);
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 3));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 5));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 6));
          
          _fnname1 = tmpMeta8;
          _invars = tmpMeta9;
          _outvars = tmpMeta10;
          _inunitlist = tmpMeta11;
          _outunitlist = tmpMeta12;
          _fnname = tmp4_1;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(stringEqual(_fnname, _fnname1))) goto tmp3_end;
          _inunitlist = _inunitlist;

          _outunitlist = _outunitlist;
          tmpMeta[0+0] = _invars;
          tmpMeta[0+1] = _outvars;
          tmpMeta[0+2] = _inunitlist;
          tmpMeta[0+3] = _outunitlist;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta13 = MMC_CAR(tmp4_2);
          tmpMeta14 = MMC_CDR(tmp4_2);
          
          _rest = tmpMeta14;
          _fnname = tmp4_1;
          /* Pattern matching succeeded */
          /* Tail recursive call */
          _instring = _fnname;
          _inargs = _rest;
          goto _tailrecursive;
          /* TODO: Make sure any eventual dead code below is never generated */
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          
          /* Pattern matching succeeded */
          tmpMeta15 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = tmpMeta15;
          tmpMeta[0+1] = tmpMeta16;
          tmpMeta[0+2] = tmpMeta17;
          tmpMeta[0+3] = tmpMeta18;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outargs = tmpMeta[0+0];
  _outargs2 = tmpMeta[0+1];
  _outargs3 = tmpMeta[0+2];
  _outargs4 = tmpMeta[0+3];
  _return: OMC_LABEL_UNUSED
  if (out_outargs2) { *out_outargs2 = _outargs2; }
  if (out_outargs3) { *out_outargs3 = _outargs3; }
  if (out_outargs4) { *out_outargs4 = _outargs4; }
  return _outargs;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_insertUnitInEquation(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inTpl, modelica_metatype _inUt, modelica_metatype _inargs, modelica_metatype *out_outTpl, modelica_metatype *out_outexpList)
{
  modelica_metatype _outUt = NULL;
  modelica_metatype _outTpl = NULL;
  modelica_metatype _outexpList = NULL;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outUt has no default value.
  // _outTpl has no default value.
  // _outexpList has no default value.
  
  
  
  { /* matchcontinue expression */
    volatile modelica_metatype tmp4_1;volatile modelica_metatype tmp4_2;volatile modelica_metatype tmp4_3;
    tmp4_1 = _inEq;
    tmp4_2 = _inTpl;
    tmp4_3 = _inUt;
    {
      modelica_metatype _cr = NULL;
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _exp3 = NULL;
      modelica_metatype _HtCr2U = NULL;
      modelica_metatype _HtS2U = NULL;
      modelica_metatype _HtU2S = NULL;
      modelica_integer _i;
      modelica_integer _i1;
      modelica_integer _i2;
      modelica_integer _i3;
      modelica_integer _i4;
      modelica_integer _i5;
      modelica_integer _i6;
      modelica_integer _i7;
      modelica_metatype _lcr = NULL;
      modelica_metatype _ExpList = NULL;
      modelica_metatype _expListList = NULL;
      modelica_metatype _expListList2 = NULL;
      modelica_metatype _expListList3 = NULL;
      modelica_real _factor1;
      modelica_real _r;
      modelica_string _s1 = NULL;
      modelica_metatype _path = NULL;
      modelica_metatype _ut = NULL;
      modelica_metatype _ut2 = NULL;
      modelica_metatype _invars = NULL;
      modelica_metatype _inunitlist = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _exp3 has no default value.
      // _HtCr2U has no default value.
      // _HtS2U has no default value.
      // _HtU2S has no default value.
      // _i has no default value.
      // _i1 has no default value.
      // _i2 has no default value.
      // _i3 has no default value.
      // _i4 has no default value.
      // _i5 has no default value.
      // _i6 has no default value.
      // _i7 has no default value.
      // _lcr has no default value.
      // _ExpList has no default value.
      // _expListList has no default value.
      // _expListList2 has no default value.
      // _expListList3 has no default value.
      // _factor1 has no default value.
      // _r has no default value.
      // _s1 has no default value.
      // _path has no default value.
      // _ut has no default value.
      // _ut2 has no default value.
      // _invars has no default value.
      // _inunitlist has no default value.
      tmp4 = 0;
      MMC_TRY_INTERNAL(mmc_jumper)
      tmp3_top:
      threadData->mmc_jumper = &new_mmc_jumper;
      for (; tmp4 < 40; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_boolean tmp28;
          modelica_metatype tmpMeta29;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta6;
          _exp2 = tmpMeta8;
          _HtCr2U = tmpMeta9;
          _HtS2U = tmpMeta10;
          _HtU2S = tmpMeta11;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta17 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta18 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta17, _inUt, _inargs, &tmpMeta12, &tmpMeta16);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta18,0,8) == 0) goto goto_2;
          _ut = tmpMeta18;
          tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 1));
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 2));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta12), 3));
          _HtCr2U = tmpMeta13;
          _HtS2U = tmpMeta14;
          _HtU2S = tmpMeta15;
          _expListList = tmpMeta16;

          /* Pattern-matching tuple assignment */
          tmpMeta24 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta25 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta24, _ut, _inargs, &tmpMeta19, &tmpMeta23);
          _ut2 = tmpMeta25;
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 1));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 3));
          _HtCr2U = tmpMeta20;
          _HtS2U = tmpMeta21;
          _HtU2S = tmpMeta22;
          _expListList2 = tmpMeta23;

          /* Pattern-matching tuple assignment */
          tmp28 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta26, &tmpMeta27);
          if (1 /* true */ != tmp28) goto goto_2;
          _ut = tmpMeta26;
          _HtCr2U = tmpMeta27;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta29 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta29;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_boolean tmp52;
          modelica_metatype tmpMeta53;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta31,1,1) == 0) goto tmp3_end;
          tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta33 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta30;
          _exp2 = tmpMeta32;
          _HtCr2U = tmpMeta33;
          _HtS2U = tmpMeta34;
          _HtU2S = tmpMeta35;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta41 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta42 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta41, _inUt, _inargs, &tmpMeta36, &tmpMeta40);
          _ut2 = tmpMeta42;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 1));
          tmpMeta38 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 2));
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 3));
          _HtCr2U = tmpMeta37;
          _HtS2U = tmpMeta38;
          _HtU2S = tmpMeta39;
          _expListList = tmpMeta40;

          /* Pattern-matching tuple assignment */
          tmpMeta48 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta49 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta48, _ut2, _inargs, &tmpMeta43, &tmpMeta47);
          _ut = tmpMeta49;
          tmpMeta44 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta43), 1));
          tmpMeta45 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta43), 2));
          tmpMeta46 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta43), 3));
          _HtCr2U = tmpMeta44;
          _HtS2U = tmpMeta45;
          _HtU2S = tmpMeta46;
          _expListList2 = tmpMeta47;

          /* Pattern-matching tuple assignment */
          tmp52 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta50, &tmpMeta51);
          if (1 /* true */ != tmp52) goto goto_2;
          _ut = tmpMeta50;
          _HtCr2U = tmpMeta51;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta53 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta53;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta54;
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          modelica_metatype tmpMeta62;
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_boolean tmp74;
          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;
          tmpMeta54 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta55 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta55,1,1) == 0) goto tmp3_end;
          tmpMeta56 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta54;
          _exp2 = tmpMeta56;
          _HtCr2U = tmpMeta57;
          _HtS2U = tmpMeta58;
          _HtU2S = tmpMeta59;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta65 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta66 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta65, _inUt, _inargs, &tmpMeta60, &tmpMeta64);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta66,0,8) == 0) goto goto_2;
          _ut = tmpMeta66;
          tmpMeta61 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 1));
          tmpMeta62 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 2));
          tmpMeta63 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta60), 3));
          _HtCr2U = tmpMeta61;
          _HtS2U = tmpMeta62;
          _HtU2S = tmpMeta63;
          _expListList = tmpMeta64;

          /* Pattern-matching tuple assignment */
          tmpMeta72 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta73 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta72, _ut, _inargs, &tmpMeta67, &tmpMeta71);
          _ut2 = tmpMeta73;
          tmpMeta68 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta67), 1));
          tmpMeta69 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta67), 2));
          tmpMeta70 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta67), 3));
          _HtCr2U = tmpMeta68;
          _HtS2U = tmpMeta69;
          _HtU2S = tmpMeta70;
          _expListList2 = tmpMeta71;

          /* Pattern-matching tuple assignment */
          tmp74 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp74) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta77 = mmc_mk_box2(0, _exp1, _ut);
          tmpMeta78 = mmc_mk_box2(0, _exp2, _ut2);
          tmpMeta76 = mmc_mk_cons(tmpMeta77, mmc_mk_cons(tmpMeta78, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta75 = mmc_mk_cons(tmpMeta76, _expListList);
          _expListList = tmpMeta75;
          tmpMeta79 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta79;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 3: {
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          modelica_boolean tmp100;
          modelica_metatype tmpMeta101;
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta81,1,1) == 0) goto tmp3_end;
          tmpMeta82 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta83 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta84 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta85 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta80;
          _exp2 = tmpMeta82;
          _HtCr2U = tmpMeta83;
          _HtS2U = tmpMeta84;
          _HtU2S = tmpMeta85;
          tmp4 += 35; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta91 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta92 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta91, _inUt, _inargs, &tmpMeta86, &tmpMeta90);
          _ut2 = tmpMeta92;
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 1));
          tmpMeta88 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 2));
          tmpMeta89 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta86), 3));
          _HtCr2U = tmpMeta87;
          _HtS2U = tmpMeta88;
          _HtU2S = tmpMeta89;
          _expListList = tmpMeta90;

          /* Pattern-matching tuple assignment */
          tmpMeta98 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta99 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta98, _ut2, _inargs, &tmpMeta93, &tmpMeta97);
          _ut = tmpMeta99;
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta93), 1));
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta93), 2));
          tmpMeta96 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta93), 3));
          _HtCr2U = tmpMeta94;
          _HtS2U = tmpMeta95;
          _HtU2S = tmpMeta96;
          _expListList2 = tmpMeta97;

          /* Pattern-matching tuple assignment */
          tmp100 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp100) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta103 = mmc_mk_box2(0, _exp1, _ut);
          tmpMeta104 = mmc_mk_box2(0, _exp2, _ut2);
          tmpMeta102 = mmc_mk_cons(tmpMeta103, mmc_mk_cons(tmpMeta104, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta101 = mmc_mk_cons(tmpMeta102, _expListList);
          _expListList = tmpMeta101;
          tmpMeta105 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta105;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          modelica_metatype tmpMeta114;
          modelica_metatype tmpMeta115;
          modelica_metatype tmpMeta116;
          modelica_metatype tmpMeta117;
          modelica_metatype tmpMeta118;
          modelica_metatype tmpMeta119;
          modelica_metatype tmpMeta120;
          modelica_metatype tmpMeta121;
          modelica_metatype tmpMeta122;
          modelica_metatype tmpMeta123;
          modelica_metatype tmpMeta124;
          modelica_metatype tmpMeta125;
          modelica_metatype tmpMeta126;
          modelica_metatype tmpMeta127;
          modelica_boolean tmp128;
          modelica_metatype tmpMeta129;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta106 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta107 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta107,0,1) == 0) goto tmp3_end;
          tmpMeta108 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta109 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta111 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta106;
          _exp2 = tmpMeta108;
          _HtCr2U = tmpMeta109;
          _HtS2U = tmpMeta110;
          _HtU2S = tmpMeta111;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta117 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta118 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta117, _inUt, _inargs, &tmpMeta112, &tmpMeta116);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta118,0,8) == 0) goto goto_2;
          _ut = tmpMeta118;
          tmpMeta113 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 1));
          tmpMeta114 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 2));
          tmpMeta115 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta112), 3));
          _HtCr2U = tmpMeta113;
          _HtS2U = tmpMeta114;
          _HtU2S = tmpMeta115;
          _expListList = tmpMeta116;

          /* Pattern-matching tuple assignment */
          tmpMeta124 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta125 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta124, _ut, _inargs, &tmpMeta119, &tmpMeta123);
          _ut2 = tmpMeta125;
          tmpMeta120 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta119), 1));
          tmpMeta121 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta119), 2));
          tmpMeta122 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta119), 3));
          _HtCr2U = tmpMeta120;
          _HtS2U = tmpMeta121;
          _HtU2S = tmpMeta122;
          _expListList2 = tmpMeta123;

          /* Pattern-matching tuple assignment */
          tmp128 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta126, &tmpMeta127);
          if (1 /* true */ != tmp128) goto goto_2;
          _ut = tmpMeta126;
          _HtCr2U = tmpMeta127;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta129 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta129;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta130;
          modelica_metatype tmpMeta131;
          modelica_metatype tmpMeta132;
          modelica_metatype tmpMeta133;
          modelica_metatype tmpMeta134;
          modelica_metatype tmpMeta135;
          modelica_metatype tmpMeta136;
          modelica_metatype tmpMeta137;
          modelica_metatype tmpMeta138;
          modelica_metatype tmpMeta139;
          modelica_metatype tmpMeta140;
          modelica_metatype tmpMeta141;
          modelica_metatype tmpMeta142;
          modelica_metatype tmpMeta143;
          modelica_metatype tmpMeta144;
          modelica_metatype tmpMeta145;
          modelica_metatype tmpMeta146;
          modelica_metatype tmpMeta147;
          modelica_metatype tmpMeta148;
          modelica_metatype tmpMeta149;
          modelica_metatype tmpMeta150;
          modelica_metatype tmpMeta151;
          modelica_boolean tmp152;
          modelica_metatype tmpMeta153;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta130 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta131 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta131,0,1) == 0) goto tmp3_end;
          tmpMeta132 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta133 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta134 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta135 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta130;
          _exp2 = tmpMeta132;
          _HtCr2U = tmpMeta133;
          _HtS2U = tmpMeta134;
          _HtU2S = tmpMeta135;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta141 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta142 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta141, _inUt, _inargs, &tmpMeta136, &tmpMeta140);
          _ut2 = tmpMeta142;
          tmpMeta137 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta136), 1));
          tmpMeta138 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta136), 2));
          tmpMeta139 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta136), 3));
          _HtCr2U = tmpMeta137;
          _HtS2U = tmpMeta138;
          _HtU2S = tmpMeta139;
          _expListList = tmpMeta140;

          /* Pattern-matching tuple assignment */
          tmpMeta148 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta149 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta148, _ut2, _inargs, &tmpMeta143, &tmpMeta147);
          _ut = tmpMeta149;
          tmpMeta144 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta143), 1));
          tmpMeta145 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta143), 2));
          tmpMeta146 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta143), 3));
          _HtCr2U = tmpMeta144;
          _HtS2U = tmpMeta145;
          _HtU2S = tmpMeta146;
          _expListList2 = tmpMeta147;

          /* Pattern-matching tuple assignment */
          tmp152 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta150, &tmpMeta151);
          if (1 /* true */ != tmp152) goto goto_2;
          _ut = tmpMeta150;
          _HtCr2U = tmpMeta151;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta153 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta153;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 6: {
          modelica_metatype tmpMeta154;
          modelica_metatype tmpMeta155;
          modelica_metatype tmpMeta156;
          modelica_metatype tmpMeta157;
          modelica_metatype tmpMeta158;
          modelica_metatype tmpMeta159;
          modelica_metatype tmpMeta160;
          modelica_metatype tmpMeta161;
          modelica_metatype tmpMeta162;
          modelica_metatype tmpMeta163;
          modelica_metatype tmpMeta164;
          modelica_metatype tmpMeta165;
          modelica_metatype tmpMeta166;
          modelica_metatype tmpMeta167;
          modelica_metatype tmpMeta168;
          modelica_metatype tmpMeta169;
          modelica_metatype tmpMeta170;
          modelica_metatype tmpMeta171;
          modelica_metatype tmpMeta172;
          modelica_metatype tmpMeta173;
          modelica_boolean tmp174;
          modelica_metatype tmpMeta175;
          modelica_metatype tmpMeta176;
          modelica_metatype tmpMeta177;
          modelica_metatype tmpMeta178;
          modelica_metatype tmpMeta179;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta154 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta155 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta155,0,1) == 0) goto tmp3_end;
          tmpMeta156 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta157 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta158 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta159 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta154;
          _exp2 = tmpMeta156;
          _HtCr2U = tmpMeta157;
          _HtS2U = tmpMeta158;
          _HtU2S = tmpMeta159;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta165 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta166 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta165, _inUt, _inargs, &tmpMeta160, &tmpMeta164);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta166,0,8) == 0) goto goto_2;
          _ut = tmpMeta166;
          tmpMeta161 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta160), 1));
          tmpMeta162 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta160), 2));
          tmpMeta163 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta160), 3));
          _HtCr2U = tmpMeta161;
          _HtS2U = tmpMeta162;
          _HtU2S = tmpMeta163;
          _expListList = tmpMeta164;

          /* Pattern-matching tuple assignment */
          tmpMeta172 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta173 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta172, _ut, _inargs, &tmpMeta167, &tmpMeta171);
          _ut2 = tmpMeta173;
          tmpMeta168 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta167), 1));
          tmpMeta169 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta167), 2));
          tmpMeta170 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta167), 3));
          _HtCr2U = tmpMeta168;
          _HtS2U = tmpMeta169;
          _HtU2S = tmpMeta170;
          _expListList2 = tmpMeta171;

          /* Pattern-matching tuple assignment */
          tmp174 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp174) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta177 = mmc_mk_box2(0, _exp1, _ut);
          tmpMeta178 = mmc_mk_box2(0, _exp2, _ut2);
          tmpMeta176 = mmc_mk_cons(tmpMeta177, mmc_mk_cons(tmpMeta178, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta175 = mmc_mk_cons(tmpMeta176, _expListList);
          _expListList = tmpMeta175;
          tmpMeta179 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta179;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta180;
          modelica_metatype tmpMeta181;
          modelica_metatype tmpMeta182;
          modelica_metatype tmpMeta183;
          modelica_metatype tmpMeta184;
          modelica_metatype tmpMeta185;
          modelica_metatype tmpMeta186;
          modelica_metatype tmpMeta187;
          modelica_metatype tmpMeta188;
          modelica_metatype tmpMeta189;
          modelica_metatype tmpMeta190;
          modelica_metatype tmpMeta191;
          modelica_metatype tmpMeta192;
          modelica_metatype tmpMeta193;
          modelica_metatype tmpMeta194;
          modelica_metatype tmpMeta195;
          modelica_metatype tmpMeta196;
          modelica_metatype tmpMeta197;
          modelica_metatype tmpMeta198;
          modelica_metatype tmpMeta199;
          modelica_boolean tmp200;
          modelica_metatype tmpMeta201;
          modelica_metatype tmpMeta202;
          modelica_metatype tmpMeta203;
          modelica_metatype tmpMeta204;
          modelica_metatype tmpMeta205;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta180 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta181 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta181,0,1) == 0) goto tmp3_end;
          tmpMeta182 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta183 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta184 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta185 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta180;
          _exp2 = tmpMeta182;
          _HtCr2U = tmpMeta183;
          _HtS2U = tmpMeta184;
          _HtU2S = tmpMeta185;
          tmp4 += 31; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta191 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta192 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta191, _inUt, _inargs, &tmpMeta186, &tmpMeta190);
          _ut2 = tmpMeta192;
          tmpMeta187 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta186), 1));
          tmpMeta188 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta186), 2));
          tmpMeta189 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta186), 3));
          _HtCr2U = tmpMeta187;
          _HtS2U = tmpMeta188;
          _HtU2S = tmpMeta189;
          _expListList = tmpMeta190;

          /* Pattern-matching tuple assignment */
          tmpMeta198 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta199 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta198, _ut2, _inargs, &tmpMeta193, &tmpMeta197);
          _ut = tmpMeta199;
          tmpMeta194 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta193), 1));
          tmpMeta195 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta193), 2));
          tmpMeta196 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta193), 3));
          _HtCr2U = tmpMeta194;
          _HtS2U = tmpMeta195;
          _HtU2S = tmpMeta196;
          _expListList2 = tmpMeta197;

          /* Pattern-matching tuple assignment */
          tmp200 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp200) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta203 = mmc_mk_box2(0, _exp1, _ut);
          tmpMeta204 = mmc_mk_box2(0, _exp2, _ut2);
          tmpMeta202 = mmc_mk_cons(tmpMeta203, mmc_mk_cons(tmpMeta204, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta201 = mmc_mk_cons(tmpMeta202, _expListList);
          _expListList = tmpMeta201;
          tmpMeta205 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta205;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 8: {
          modelica_metatype tmpMeta206;
          modelica_metatype tmpMeta207;
          modelica_metatype tmpMeta208;
          modelica_metatype tmpMeta209;
          modelica_metatype tmpMeta210;
          modelica_metatype tmpMeta211;
          modelica_metatype tmpMeta212;
          modelica_metatype tmpMeta213;
          modelica_metatype tmpMeta214;
          modelica_metatype tmpMeta215;
          modelica_metatype tmpMeta216;
          modelica_metatype tmpMeta217;
          modelica_metatype tmpMeta218;
          modelica_metatype tmpMeta219;
          modelica_metatype tmpMeta220;
          modelica_metatype tmpMeta221;
          modelica_metatype tmpMeta222;
          modelica_metatype tmpMeta223;
          modelica_metatype tmpMeta224;
          modelica_metatype tmpMeta225;
          modelica_metatype tmpMeta226;
          modelica_metatype tmpMeta227;
          modelica_metatype tmpMeta228;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta206 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta207 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta207,2,1) == 0) goto tmp3_end;
          tmpMeta208 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta209 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta210 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta211 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta206;
          _exp2 = tmpMeta208;
          _HtCr2U = tmpMeta209;
          _HtS2U = tmpMeta210;
          _HtU2S = tmpMeta211;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta217 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta218 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta217, _OMC_LIT4, _inargs, &tmpMeta212, &tmpMeta216);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta218,0,8) == 0) goto goto_2;
          _ut = tmpMeta218;
          tmpMeta213 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta212), 1));
          tmpMeta214 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta212), 2));
          tmpMeta215 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta212), 3));
          _HtCr2U = tmpMeta213;
          _HtS2U = tmpMeta214;
          _HtU2S = tmpMeta215;
          _expListList = tmpMeta216;

          /* Pattern-matching tuple assignment */
          tmpMeta224 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta225 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta224, _OMC_LIT4, _inargs, &tmpMeta219, &tmpMeta223);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta225,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta225;
          tmpMeta220 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta219), 1));
          tmpMeta221 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta219), 2));
          tmpMeta222 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta219), 3));
          _HtCr2U = tmpMeta220;
          _HtS2U = tmpMeta221;
          _HtU2S = tmpMeta222;
          _expListList2 = tmpMeta223;

          _ut = omc_FUnit_unitMul(threadData, _ut, _ut2);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta226 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta226, _HtS2U);

          tmpMeta227 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta227, _HtU2S);
          tmpMeta228 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta228;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 9: {
          modelica_metatype tmpMeta229;
          modelica_metatype tmpMeta230;
          modelica_metatype tmpMeta231;
          modelica_metatype tmpMeta232;
          modelica_metatype tmpMeta233;
          modelica_metatype tmpMeta234;
          modelica_metatype tmpMeta235;
          modelica_metatype tmpMeta236;
          modelica_metatype tmpMeta237;
          modelica_metatype tmpMeta238;
          modelica_metatype tmpMeta239;
          modelica_metatype tmpMeta240;
          modelica_metatype tmpMeta241;
          modelica_metatype tmpMeta242;
          modelica_metatype tmpMeta243;
          modelica_metatype tmpMeta244;
          modelica_metatype tmpMeta245;
          modelica_metatype tmpMeta246;
          modelica_metatype tmpMeta247;
          modelica_metatype tmpMeta248;
          modelica_metatype tmpMeta249;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,1) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta229 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta230 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta230,2,1) == 0) goto tmp3_end;
          tmpMeta231 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta232 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta233 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta234 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta229;
          _exp2 = tmpMeta231;
          _HtCr2U = tmpMeta232;
          _HtS2U = tmpMeta233;
          _HtU2S = tmpMeta234;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta240 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta241 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta240, _OMC_LIT4, _inargs, &tmpMeta235, &tmpMeta239);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta241,1,1) == 0) goto goto_2;
          tmpMeta236 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta235), 1));
          tmpMeta237 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta235), 2));
          tmpMeta238 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta235), 3));
          _HtCr2U = tmpMeta236;
          _HtS2U = tmpMeta237;
          _HtU2S = tmpMeta238;
          _expListList = tmpMeta239;

          /* Pattern-matching tuple assignment */
          tmpMeta247 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta248 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta247, _OMC_LIT4, _inargs, &tmpMeta242, &tmpMeta246);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta248,0,8) == 0) goto goto_2;
          tmpMeta243 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta242), 1));
          tmpMeta244 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta242), 2));
          tmpMeta245 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta242), 3));
          _HtCr2U = tmpMeta243;
          _HtS2U = tmpMeta244;
          _HtU2S = tmpMeta245;
          _expListList2 = tmpMeta246;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta249 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta249;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta250;
          modelica_metatype tmpMeta251;
          modelica_metatype tmpMeta252;
          modelica_metatype tmpMeta253;
          modelica_metatype tmpMeta254;
          modelica_metatype tmpMeta255;
          modelica_metatype tmpMeta256;
          modelica_metatype tmpMeta257;
          modelica_metatype tmpMeta258;
          modelica_metatype tmpMeta259;
          modelica_metatype tmpMeta260;
          modelica_metatype tmpMeta261;
          modelica_metatype tmpMeta262;
          modelica_metatype tmpMeta263;
          modelica_metatype tmpMeta264;
          modelica_metatype tmpMeta265;
          modelica_metatype tmpMeta266;
          modelica_metatype tmpMeta267;
          modelica_metatype tmpMeta268;
          modelica_metatype tmpMeta269;
          modelica_metatype tmpMeta270;
          modelica_metatype tmpMeta271;
          modelica_metatype tmpMeta272;
          modelica_metatype tmpMeta273;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta250 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta251 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta251,2,1) == 0) goto tmp3_end;
          tmpMeta252 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta253 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta254 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta255 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta250;
          _exp2 = tmpMeta252;
          _HtCr2U = tmpMeta253;
          _HtS2U = tmpMeta254;
          _HtU2S = tmpMeta255;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta261 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta262 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta261, _OMC_LIT4, _inargs, &tmpMeta256, &tmpMeta260);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta262,1,1) == 0) goto goto_2;
          tmpMeta263 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta262), 2));
          _lcr = tmpMeta263;
          tmpMeta257 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta256), 1));
          tmpMeta258 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta256), 2));
          tmpMeta259 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta256), 3));
          _HtCr2U = tmpMeta257;
          _HtS2U = tmpMeta258;
          _HtU2S = tmpMeta259;
          _expListList = tmpMeta260;

          /* Pattern-matching tuple assignment */
          tmpMeta269 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta270 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta269, _OMC_LIT4, _inargs, &tmpMeta264, &tmpMeta268);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta270,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta270;
          tmpMeta265 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta264), 1));
          tmpMeta266 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta264), 2));
          tmpMeta267 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta264), 3));
          _HtCr2U = tmpMeta265;
          _HtS2U = tmpMeta266;
          _HtU2S = tmpMeta267;
          _expListList2 = tmpMeta268;

          _ut = omc_FUnit_unitDiv(threadData, _inUt, _ut2);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta271 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta271, _HtS2U);

          tmpMeta272 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta272, _HtU2S);
          tmpMeta273 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta273;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 11: {
          modelica_metatype tmpMeta274;
          modelica_metatype tmpMeta275;
          modelica_metatype tmpMeta276;
          modelica_metatype tmpMeta277;
          modelica_metatype tmpMeta278;
          modelica_metatype tmpMeta279;
          modelica_metatype tmpMeta280;
          modelica_metatype tmpMeta281;
          modelica_metatype tmpMeta282;
          modelica_metatype tmpMeta283;
          modelica_metatype tmpMeta284;
          modelica_metatype tmpMeta285;
          modelica_metatype tmpMeta286;
          modelica_metatype tmpMeta287;
          modelica_metatype tmpMeta288;
          modelica_metatype tmpMeta289;
          modelica_metatype tmpMeta290;
          modelica_metatype tmpMeta291;
          modelica_metatype tmpMeta292;
          modelica_metatype tmpMeta293;
          modelica_metatype tmpMeta294;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,1) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta274 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta275 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta275,2,1) == 0) goto tmp3_end;
          tmpMeta276 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta277 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta278 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta279 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta274;
          _exp2 = tmpMeta276;
          _HtCr2U = tmpMeta277;
          _HtS2U = tmpMeta278;
          _HtU2S = tmpMeta279;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta285 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta286 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta285, _OMC_LIT4, _inargs, &tmpMeta280, &tmpMeta284);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta286,0,8) == 0) goto goto_2;
          tmpMeta281 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta280), 1));
          tmpMeta282 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta280), 2));
          tmpMeta283 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta280), 3));
          _HtCr2U = tmpMeta281;
          _HtS2U = tmpMeta282;
          _HtU2S = tmpMeta283;
          _expListList = tmpMeta284;

          /* Pattern-matching tuple assignment */
          tmpMeta292 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta293 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta292, _OMC_LIT4, _inargs, &tmpMeta287, &tmpMeta291);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta293,1,1) == 0) goto goto_2;
          tmpMeta288 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta287), 1));
          tmpMeta289 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta287), 2));
          tmpMeta290 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta287), 3));
          _HtCr2U = tmpMeta288;
          _HtS2U = tmpMeta289;
          _HtU2S = tmpMeta290;
          _expListList2 = tmpMeta291;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta294 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta294;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 12: {
          modelica_metatype tmpMeta295;
          modelica_metatype tmpMeta296;
          modelica_metatype tmpMeta297;
          modelica_metatype tmpMeta298;
          modelica_metatype tmpMeta299;
          modelica_metatype tmpMeta300;
          modelica_metatype tmpMeta301;
          modelica_metatype tmpMeta302;
          modelica_metatype tmpMeta303;
          modelica_metatype tmpMeta304;
          modelica_metatype tmpMeta305;
          modelica_metatype tmpMeta306;
          modelica_metatype tmpMeta307;
          modelica_metatype tmpMeta308;
          modelica_metatype tmpMeta309;
          modelica_metatype tmpMeta310;
          modelica_metatype tmpMeta311;
          modelica_metatype tmpMeta312;
          modelica_metatype tmpMeta313;
          modelica_metatype tmpMeta314;
          modelica_metatype tmpMeta315;
          modelica_metatype tmpMeta316;
          modelica_metatype tmpMeta317;
          modelica_metatype tmpMeta318;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta295 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta296 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta296,2,1) == 0) goto tmp3_end;
          tmpMeta297 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta298 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta299 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta300 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta295;
          _exp2 = tmpMeta297;
          _HtCr2U = tmpMeta298;
          _HtS2U = tmpMeta299;
          _HtU2S = tmpMeta300;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta306 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta307 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta306, _OMC_LIT4, _inargs, &tmpMeta301, &tmpMeta305);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta307,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta307;
          tmpMeta302 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta301), 1));
          tmpMeta303 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta301), 2));
          tmpMeta304 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta301), 3));
          _HtCr2U = tmpMeta302;
          _HtS2U = tmpMeta303;
          _HtU2S = tmpMeta304;
          _expListList = tmpMeta305;

          /* Pattern-matching tuple assignment */
          tmpMeta313 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta314 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta313, _OMC_LIT4, _inargs, &tmpMeta308, &tmpMeta312);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta314,1,1) == 0) goto goto_2;
          tmpMeta315 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta314), 2));
          _lcr = tmpMeta315;
          tmpMeta309 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta308), 1));
          tmpMeta310 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta308), 2));
          tmpMeta311 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta308), 3));
          _HtCr2U = tmpMeta309;
          _HtS2U = tmpMeta310;
          _HtU2S = tmpMeta311;
          _expListList2 = tmpMeta312;

          _ut = omc_FUnit_unitDiv(threadData, _inUt, _ut2);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta316 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta316, _HtS2U);

          tmpMeta317 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta317, _HtU2S);
          tmpMeta318 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta318;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 13: {
          modelica_metatype tmpMeta319;
          modelica_metatype tmpMeta320;
          modelica_metatype tmpMeta321;
          modelica_metatype tmpMeta322;
          modelica_metatype tmpMeta323;
          modelica_metatype tmpMeta324;
          modelica_metatype tmpMeta325;
          modelica_metatype tmpMeta326;
          modelica_metatype tmpMeta327;
          modelica_metatype tmpMeta328;
          modelica_metatype tmpMeta329;
          modelica_metatype tmpMeta330;
          modelica_metatype tmpMeta331;
          modelica_metatype tmpMeta332;
          modelica_metatype tmpMeta333;
          modelica_metatype tmpMeta334;
          modelica_metatype tmpMeta335;
          modelica_metatype tmpMeta336;
          modelica_metatype tmpMeta337;
          modelica_metatype tmpMeta338;
          modelica_metatype tmpMeta339;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta319 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta320 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta320,2,1) == 0) goto tmp3_end;
          tmpMeta321 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta322 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta323 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta324 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta319;
          _exp2 = tmpMeta321;
          _HtCr2U = tmpMeta322;
          _HtS2U = tmpMeta323;
          _HtU2S = tmpMeta324;
          tmp4 += 25; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta330 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta331 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta330, _OMC_LIT4, _inargs, &tmpMeta325, &tmpMeta329);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta331,1,1) == 0) goto goto_2;
          tmpMeta326 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta325), 1));
          tmpMeta327 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta325), 2));
          tmpMeta328 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta325), 3));
          _HtCr2U = tmpMeta326;
          _HtS2U = tmpMeta327;
          _HtU2S = tmpMeta328;
          _expListList = tmpMeta329;

          /* Pattern-matching tuple assignment */
          tmpMeta337 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta338 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta337, _OMC_LIT4, _inargs, &tmpMeta332, &tmpMeta336);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta338,1,1) == 0) goto goto_2;
          tmpMeta333 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta332), 1));
          tmpMeta334 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta332), 2));
          tmpMeta335 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta332), 3));
          _HtCr2U = tmpMeta333;
          _HtS2U = tmpMeta334;
          _HtU2S = tmpMeta335;
          _expListList2 = tmpMeta336;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta339 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta339;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 14: {
          modelica_metatype tmpMeta340;
          modelica_metatype tmpMeta341;
          modelica_metatype tmpMeta342;
          modelica_metatype tmpMeta343;
          modelica_metatype tmpMeta344;
          modelica_metatype tmpMeta345;
          modelica_metatype tmpMeta346;
          modelica_metatype tmpMeta347;
          modelica_metatype tmpMeta348;
          modelica_metatype tmpMeta349;
          modelica_metatype tmpMeta350;
          modelica_metatype tmpMeta351;
          modelica_metatype tmpMeta352;
          modelica_metatype tmpMeta353;
          modelica_metatype tmpMeta354;
          modelica_metatype tmpMeta355;
          modelica_metatype tmpMeta356;
          modelica_metatype tmpMeta357;
          modelica_metatype tmpMeta358;
          modelica_metatype tmpMeta359;
          modelica_metatype tmpMeta360;
          modelica_metatype tmpMeta361;
          modelica_metatype tmpMeta362;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta340 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta341 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta341,3,1) == 0) goto tmp3_end;
          tmpMeta342 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta343 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta344 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta345 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta340;
          _exp2 = tmpMeta342;
          _HtCr2U = tmpMeta343;
          _HtS2U = tmpMeta344;
          _HtU2S = tmpMeta345;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta351 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta352 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta351, _OMC_LIT4, _inargs, &tmpMeta346, &tmpMeta350);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta352,0,8) == 0) goto goto_2;
          _ut = tmpMeta352;
          tmpMeta347 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta346), 1));
          tmpMeta348 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta346), 2));
          tmpMeta349 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta346), 3));
          _HtCr2U = tmpMeta347;
          _HtS2U = tmpMeta348;
          _HtU2S = tmpMeta349;
          _expListList = tmpMeta350;

          /* Pattern-matching tuple assignment */
          tmpMeta358 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta359 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta358, _OMC_LIT4, _inargs, &tmpMeta353, &tmpMeta357);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta359,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta359;
          tmpMeta354 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta353), 1));
          tmpMeta355 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta353), 2));
          tmpMeta356 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta353), 3));
          _HtCr2U = tmpMeta354;
          _HtS2U = tmpMeta355;
          _HtU2S = tmpMeta356;
          _expListList2 = tmpMeta357;

          _ut = omc_FUnit_unitDiv(threadData, _ut, _ut2);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta360 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta360, _HtS2U);

          tmpMeta361 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta361, _HtU2S);
          tmpMeta362 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta362;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 15: {
          modelica_metatype tmpMeta363;
          modelica_metatype tmpMeta364;
          modelica_metatype tmpMeta365;
          modelica_metatype tmpMeta366;
          modelica_metatype tmpMeta367;
          modelica_metatype tmpMeta368;
          modelica_metatype tmpMeta369;
          modelica_metatype tmpMeta370;
          modelica_metatype tmpMeta371;
          modelica_metatype tmpMeta372;
          modelica_metatype tmpMeta373;
          modelica_metatype tmpMeta374;
          modelica_metatype tmpMeta375;
          modelica_metatype tmpMeta376;
          modelica_metatype tmpMeta377;
          modelica_metatype tmpMeta378;
          modelica_metatype tmpMeta379;
          modelica_metatype tmpMeta380;
          modelica_metatype tmpMeta381;
          modelica_metatype tmpMeta382;
          modelica_metatype tmpMeta383;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,1) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta363 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta364 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta364,3,1) == 0) goto tmp3_end;
          tmpMeta365 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta366 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta367 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta368 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta363;
          _exp2 = tmpMeta365;
          _HtCr2U = tmpMeta366;
          _HtS2U = tmpMeta367;
          _HtU2S = tmpMeta368;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta374 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta375 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta374, _OMC_LIT4, _inargs, &tmpMeta369, &tmpMeta373);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta375,1,1) == 0) goto goto_2;
          tmpMeta370 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta369), 1));
          tmpMeta371 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta369), 2));
          tmpMeta372 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta369), 3));
          _HtCr2U = tmpMeta370;
          _HtS2U = tmpMeta371;
          _HtU2S = tmpMeta372;
          _expListList = tmpMeta373;

          /* Pattern-matching tuple assignment */
          tmpMeta381 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta382 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta381, _OMC_LIT4, _inargs, &tmpMeta376, &tmpMeta380);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta382,0,8) == 0) goto goto_2;
          tmpMeta377 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta376), 1));
          tmpMeta378 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta376), 2));
          tmpMeta379 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta376), 3));
          _HtCr2U = tmpMeta377;
          _HtS2U = tmpMeta378;
          _HtU2S = tmpMeta379;
          _expListList2 = tmpMeta380;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta383 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta383;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 16: {
          modelica_metatype tmpMeta384;
          modelica_metatype tmpMeta385;
          modelica_metatype tmpMeta386;
          modelica_metatype tmpMeta387;
          modelica_metatype tmpMeta388;
          modelica_metatype tmpMeta389;
          modelica_metatype tmpMeta390;
          modelica_metatype tmpMeta391;
          modelica_metatype tmpMeta392;
          modelica_metatype tmpMeta393;
          modelica_metatype tmpMeta394;
          modelica_metatype tmpMeta395;
          modelica_metatype tmpMeta396;
          modelica_metatype tmpMeta397;
          modelica_metatype tmpMeta398;
          modelica_metatype tmpMeta399;
          modelica_metatype tmpMeta400;
          modelica_metatype tmpMeta401;
          modelica_metatype tmpMeta402;
          modelica_metatype tmpMeta403;
          modelica_metatype tmpMeta404;
          modelica_metatype tmpMeta405;
          modelica_metatype tmpMeta406;
          modelica_metatype tmpMeta407;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta384 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta385 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta385,3,1) == 0) goto tmp3_end;
          tmpMeta386 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta387 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta388 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta389 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta384;
          _exp2 = tmpMeta386;
          _HtCr2U = tmpMeta387;
          _HtS2U = tmpMeta388;
          _HtU2S = tmpMeta389;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta395 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta396 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta395, _OMC_LIT4, _inargs, &tmpMeta390, &tmpMeta394);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta396,1,1) == 0) goto goto_2;
          tmpMeta397 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta396), 2));
          _lcr = tmpMeta397;
          tmpMeta391 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta390), 1));
          tmpMeta392 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta390), 2));
          tmpMeta393 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta390), 3));
          _HtCr2U = tmpMeta391;
          _HtS2U = tmpMeta392;
          _HtU2S = tmpMeta393;
          _expListList = tmpMeta394;

          /* Pattern-matching tuple assignment */
          tmpMeta403 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta404 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta403, _OMC_LIT4, _inargs, &tmpMeta398, &tmpMeta402);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta404,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta404;
          tmpMeta399 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta398), 1));
          tmpMeta400 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta398), 2));
          tmpMeta401 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta398), 3));
          _HtCr2U = tmpMeta399;
          _HtS2U = tmpMeta400;
          _HtU2S = tmpMeta401;
          _expListList2 = tmpMeta402;

          _ut = omc_FUnit_unitMul(threadData, _inUt, _ut2);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta405 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta405, _HtS2U);

          tmpMeta406 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta406, _HtU2S);
          tmpMeta407 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta407;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 17: {
          modelica_metatype tmpMeta408;
          modelica_metatype tmpMeta409;
          modelica_metatype tmpMeta410;
          modelica_metatype tmpMeta411;
          modelica_metatype tmpMeta412;
          modelica_metatype tmpMeta413;
          modelica_metatype tmpMeta414;
          modelica_metatype tmpMeta415;
          modelica_metatype tmpMeta416;
          modelica_metatype tmpMeta417;
          modelica_metatype tmpMeta418;
          modelica_metatype tmpMeta419;
          modelica_metatype tmpMeta420;
          modelica_metatype tmpMeta421;
          modelica_metatype tmpMeta422;
          modelica_metatype tmpMeta423;
          modelica_metatype tmpMeta424;
          modelica_metatype tmpMeta425;
          modelica_metatype tmpMeta426;
          modelica_metatype tmpMeta427;
          modelica_metatype tmpMeta428;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,1) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta408 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta409 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta409,3,1) == 0) goto tmp3_end;
          tmpMeta410 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta411 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta412 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta413 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta408;
          _exp2 = tmpMeta410;
          _HtCr2U = tmpMeta411;
          _HtS2U = tmpMeta412;
          _HtU2S = tmpMeta413;
          tmp4 += 1; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta419 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta420 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta419, _OMC_LIT4, _inargs, &tmpMeta414, &tmpMeta418);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta420,0,8) == 0) goto goto_2;
          tmpMeta415 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta414), 1));
          tmpMeta416 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta414), 2));
          tmpMeta417 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta414), 3));
          _HtCr2U = tmpMeta415;
          _HtS2U = tmpMeta416;
          _HtU2S = tmpMeta417;
          _expListList = tmpMeta418;

          /* Pattern-matching tuple assignment */
          tmpMeta426 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta427 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta426, _OMC_LIT4, _inargs, &tmpMeta421, &tmpMeta425);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta427,1,1) == 0) goto goto_2;
          tmpMeta422 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta421), 1));
          tmpMeta423 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta421), 2));
          tmpMeta424 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta421), 3));
          _HtCr2U = tmpMeta422;
          _HtS2U = tmpMeta423;
          _HtU2S = tmpMeta424;
          _expListList2 = tmpMeta425;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta428 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta428;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 18: {
          modelica_metatype tmpMeta429;
          modelica_metatype tmpMeta430;
          modelica_metatype tmpMeta431;
          modelica_metatype tmpMeta432;
          modelica_metatype tmpMeta433;
          modelica_metatype tmpMeta434;
          modelica_metatype tmpMeta435;
          modelica_metatype tmpMeta436;
          modelica_metatype tmpMeta437;
          modelica_metatype tmpMeta438;
          modelica_metatype tmpMeta439;
          modelica_metatype tmpMeta440;
          modelica_metatype tmpMeta441;
          modelica_metatype tmpMeta442;
          modelica_metatype tmpMeta443;
          modelica_metatype tmpMeta444;
          modelica_metatype tmpMeta445;
          modelica_metatype tmpMeta446;
          modelica_metatype tmpMeta447;
          modelica_metatype tmpMeta448;
          modelica_metatype tmpMeta449;
          modelica_metatype tmpMeta450;
          modelica_metatype tmpMeta451;
          modelica_metatype tmpMeta452;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta429 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta430 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta430,3,1) == 0) goto tmp3_end;
          tmpMeta431 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta432 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta433 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta434 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta429;
          _exp2 = tmpMeta431;
          _HtCr2U = tmpMeta432;
          _HtS2U = tmpMeta433;
          _HtU2S = tmpMeta434;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta440 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta441 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta440, _OMC_LIT4, _inargs, &tmpMeta435, &tmpMeta439);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta441,0,8) == 0) goto goto_2;
          _ut2 = tmpMeta441;
          tmpMeta436 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta435), 1));
          tmpMeta437 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta435), 2));
          tmpMeta438 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta435), 3));
          _HtCr2U = tmpMeta436;
          _HtS2U = tmpMeta437;
          _HtU2S = tmpMeta438;
          _expListList = tmpMeta439;

          /* Pattern-matching tuple assignment */
          tmpMeta447 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta448 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta447, _OMC_LIT4, _inargs, &tmpMeta442, &tmpMeta446);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta448,1,1) == 0) goto goto_2;
          tmpMeta449 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta448), 2));
          _lcr = tmpMeta449;
          tmpMeta443 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta442), 1));
          tmpMeta444 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta442), 2));
          tmpMeta445 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta442), 3));
          _HtCr2U = tmpMeta443;
          _HtS2U = tmpMeta444;
          _HtU2S = tmpMeta445;
          _expListList2 = tmpMeta446;

          _ut = omc_FUnit_unitDiv(threadData, _ut2, _inUt);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta450 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta450, _HtS2U);

          tmpMeta451 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta451, _HtU2S);
          tmpMeta452 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta452;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 19: {
          modelica_metatype tmpMeta453;
          modelica_metatype tmpMeta454;
          modelica_metatype tmpMeta455;
          modelica_metatype tmpMeta456;
          modelica_metatype tmpMeta457;
          modelica_metatype tmpMeta458;
          modelica_metatype tmpMeta459;
          modelica_metatype tmpMeta460;
          modelica_metatype tmpMeta461;
          modelica_metatype tmpMeta462;
          modelica_metatype tmpMeta463;
          modelica_metatype tmpMeta464;
          modelica_metatype tmpMeta465;
          modelica_metatype tmpMeta466;
          modelica_metatype tmpMeta467;
          modelica_metatype tmpMeta468;
          modelica_metatype tmpMeta469;
          modelica_metatype tmpMeta470;
          modelica_metatype tmpMeta471;
          modelica_metatype tmpMeta472;
          modelica_metatype tmpMeta473;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta453 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta454 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta454,3,1) == 0) goto tmp3_end;
          tmpMeta455 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta456 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta457 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta458 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta453;
          _exp2 = tmpMeta455;
          _HtCr2U = tmpMeta456;
          _HtS2U = tmpMeta457;
          _HtU2S = tmpMeta458;
          tmp4 += 19; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta464 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta465 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta464, _OMC_LIT4, _inargs, &tmpMeta459, &tmpMeta463);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta465,1,1) == 0) goto goto_2;
          tmpMeta460 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta459), 1));
          tmpMeta461 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta459), 2));
          tmpMeta462 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta459), 3));
          _HtCr2U = tmpMeta460;
          _HtS2U = tmpMeta461;
          _HtU2S = tmpMeta462;
          _expListList = tmpMeta463;

          /* Pattern-matching tuple assignment */
          tmpMeta471 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta472 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta471, _OMC_LIT4, _inargs, &tmpMeta466, &tmpMeta470);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta472,1,1) == 0) goto goto_2;
          tmpMeta467 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta466), 1));
          tmpMeta468 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta466), 2));
          tmpMeta469 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta466), 3));
          _HtCr2U = tmpMeta467;
          _HtS2U = tmpMeta468;
          _HtU2S = tmpMeta469;
          _expListList2 = tmpMeta470;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta473 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta473;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 20: {
          modelica_metatype tmpMeta474;
          modelica_metatype tmpMeta475;
          modelica_metatype tmpMeta476;
          modelica_metatype tmpMeta477;
          modelica_real tmp478;
          modelica_metatype tmpMeta479;
          modelica_metatype tmpMeta480;
          modelica_metatype tmpMeta481;
          modelica_metatype tmpMeta482;
          modelica_metatype tmpMeta483;
          modelica_metatype tmpMeta484;
          modelica_metatype tmpMeta485;
          modelica_metatype tmpMeta486;
          modelica_metatype tmpMeta487;
          modelica_metatype tmpMeta488;
          modelica_boolean tmp489;
          modelica_metatype tmpMeta490;
          modelica_metatype tmpMeta491;
          modelica_metatype tmpMeta492;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta474 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta475 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta475,4,1) == 0) goto tmp3_end;
          tmpMeta476 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta476,1,1) == 0) goto tmp3_end;
          tmpMeta477 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta476), 2));
          tmp478 = mmc_unbox_real(tmpMeta477);
          tmpMeta479 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta480 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta481 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta474;
          _r = tmp478  /* pattern as ty=Real */;
          _HtCr2U = tmpMeta479;
          _HtS2U = tmpMeta480;
          _HtU2S = tmpMeta481;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta487 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta488 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta487, _OMC_LIT4, _inargs, &tmpMeta482, &tmpMeta486);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta488,0,8) == 0) goto goto_2;
          _ut = tmpMeta488;
          tmpMeta483 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta482), 1));
          tmpMeta484 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta482), 2));
          tmpMeta485 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta482), 3));
          _HtCr2U = tmpMeta483;
          _HtS2U = tmpMeta484;
          _HtU2S = tmpMeta485;
          _expListList = tmpMeta486;

          _i = ((modelica_integer)floor(_r));

          /* Pattern-matching assignment */
          tmp489 = (_r == ((modelica_real)_i));
          if (1 /* true */ != tmp489) goto goto_2;

          _ut = omc_FUnit_unitPow(threadData, _ut, _i);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          tmpMeta490 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta490, _HtS2U);

          tmpMeta491 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta491, _HtU2S);
          tmpMeta492 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta492;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 21: {
          modelica_metatype tmpMeta493;
          modelica_metatype tmpMeta494;
          modelica_metatype tmpMeta495;
          modelica_metatype tmpMeta496;
          modelica_real tmp497;
          modelica_metatype tmpMeta498;
          modelica_metatype tmpMeta499;
          modelica_metatype tmpMeta500;
          modelica_metatype tmpMeta501;
          modelica_metatype tmpMeta502;
          modelica_metatype tmpMeta503;
          modelica_metatype tmpMeta504;
          modelica_metatype tmpMeta505;
          modelica_metatype tmpMeta506;
          modelica_metatype tmpMeta507;
          modelica_metatype tmpMeta508;
          modelica_metatype tmpMeta509;
          modelica_metatype tmpMeta510;
          modelica_real tmp511;
          modelica_metatype tmpMeta512;
          modelica_integer tmp513;
          modelica_metatype tmpMeta514;
          modelica_integer tmp515;
          modelica_metatype tmpMeta516;
          modelica_integer tmp517;
          modelica_metatype tmpMeta518;
          modelica_integer tmp519;
          modelica_metatype tmpMeta520;
          modelica_integer tmp521;
          modelica_metatype tmpMeta522;
          modelica_integer tmp523;
          modelica_metatype tmpMeta524;
          modelica_integer tmp525;
          modelica_metatype tmpMeta526;
          modelica_metatype tmpMeta527;
          modelica_metatype tmpMeta528;
          modelica_metatype tmpMeta529;
          modelica_metatype tmpMeta530;
          modelica_metatype tmpMeta531;
          modelica_metatype tmpMeta532;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta493 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta494 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta494,4,1) == 0) goto tmp3_end;
          tmpMeta495 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta495,1,1) == 0) goto tmp3_end;
          tmpMeta496 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta495), 2));
          tmp497 = mmc_unbox_real(tmpMeta496);
          tmpMeta498 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta499 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta500 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _ut = tmp4_3;
          _exp1 = tmpMeta493;
          _r = tmp497  /* pattern as ty=Real */;
          _HtCr2U = tmpMeta498;
          _HtS2U = tmpMeta499;
          _HtU2S = tmpMeta500;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta506 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta507 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta506, _OMC_LIT4, _inargs, &tmpMeta501, &tmpMeta505);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta507,1,1) == 0) goto goto_2;
          tmpMeta508 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta507), 2));
          _lcr = tmpMeta508;
          tmpMeta502 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta501), 1));
          tmpMeta503 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta501), 2));
          tmpMeta504 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta501), 3));
          _HtCr2U = tmpMeta502;
          _HtS2U = tmpMeta503;
          _HtU2S = tmpMeta504;
          _expListList = tmpMeta505;

          /* Pattern-matching assignment */
          tmpMeta509 = omc_FUnit_unitRoot(threadData, _ut, _r);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta509,0,8) == 0) goto goto_2;
          tmpMeta510 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 2));
          tmp511 = mmc_unbox_real(tmpMeta510);
          tmpMeta512 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 3));
          tmp513 = mmc_unbox_integer(tmpMeta512);
          tmpMeta514 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 4));
          tmp515 = mmc_unbox_integer(tmpMeta514);
          tmpMeta516 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 5));
          tmp517 = mmc_unbox_integer(tmpMeta516);
          tmpMeta518 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 6));
          tmp519 = mmc_unbox_integer(tmpMeta518);
          tmpMeta520 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 7));
          tmp521 = mmc_unbox_integer(tmpMeta520);
          tmpMeta522 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 8));
          tmp523 = mmc_unbox_integer(tmpMeta522);
          tmpMeta524 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta509), 9));
          tmp525 = mmc_unbox_integer(tmpMeta524);
          _factor1 = tmp511  /* pattern as ty=Real */;
          _i1 = tmp513  /* pattern as ty=Integer */;
          _i2 = tmp515  /* pattern as ty=Integer */;
          _i3 = tmp517  /* pattern as ty=Integer */;
          _i4 = tmp519  /* pattern as ty=Integer */;
          _i5 = tmp521  /* pattern as ty=Integer */;
          _i6 = tmp523  /* pattern as ty=Integer */;
          _i7 = tmp525  /* pattern as ty=Integer */;

          tmpMeta526 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, tmpMeta526, _HtCr2U);

          tmpMeta527 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          _s1 = omc_FUnit_unitString(threadData, tmpMeta527, _HtU2S);

          tmpMeta528 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmpMeta529 = mmc_mk_box2(0, _s1, tmpMeta528);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta529, _HtS2U);

          tmpMeta530 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmpMeta531 = mmc_mk_box2(0, _s1, tmpMeta530);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta531, _HtU2S);
          tmpMeta532 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta532;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 22: {
          modelica_metatype tmpMeta533;
          modelica_metatype tmpMeta534;
          modelica_metatype tmpMeta535;
          modelica_metatype tmpMeta536;
          modelica_metatype tmpMeta537;
          modelica_metatype tmpMeta538;
          modelica_metatype tmpMeta539;
          modelica_metatype tmpMeta540;
          modelica_metatype tmpMeta541;
          modelica_metatype tmpMeta542;
          modelica_metatype tmpMeta543;
          modelica_metatype tmpMeta544;
          modelica_metatype tmpMeta545;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,7,3) == 0) goto tmp3_end;
          tmpMeta533 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta534 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta534,4,1) == 0) goto tmp3_end;
          tmpMeta535 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta535,1,1) == 0) goto tmp3_end;
          tmpMeta536 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta537 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta538 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta533;
          _HtCr2U = tmpMeta536;
          _HtS2U = tmpMeta537;
          _HtU2S = tmpMeta538;
          tmp4 += 16; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta544 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta544, _OMC_LIT4, _inargs, &tmpMeta539, &tmpMeta543);
          tmpMeta540 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta539), 1));
          tmpMeta541 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta539), 2));
          tmpMeta542 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta539), 3));
          _HtCr2U = tmpMeta540;
          _HtS2U = tmpMeta541;
          _HtU2S = tmpMeta542;
          _expListList = tmpMeta543;
          tmpMeta545 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta545;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 23: {
          modelica_metatype tmpMeta546;
          modelica_metatype tmpMeta547;
          modelica_metatype tmpMeta548;
          modelica_metatype tmpMeta549;
          modelica_metatype tmpMeta550;
          modelica_metatype tmpMeta551;
          modelica_metatype tmpMeta552;
          modelica_metatype tmpMeta553;
          modelica_metatype tmpMeta554;
          modelica_metatype tmpMeta555;
          modelica_metatype tmpMeta556;
          modelica_metatype tmpMeta557;
          modelica_metatype tmpMeta558;
          modelica_metatype tmpMeta559;
          modelica_metatype tmpMeta560;
          modelica_metatype tmpMeta561;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta546 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta546,1,1) == 0) goto tmp3_end;
          tmpMeta547 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta546), 2));
          if (3 != MMC_STRLEN(tmpMeta547) || strcmp(MMC_STRINGDATA(_OMC_LIT26), MMC_STRINGDATA(tmpMeta547)) != 0) goto tmp3_end;
          tmpMeta548 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta548)) goto tmp3_end;
          tmpMeta549 = MMC_CAR(tmpMeta548);
          tmpMeta550 = MMC_CDR(tmpMeta548);
          if (!listEmpty(tmpMeta550)) goto tmp3_end;
          tmpMeta551 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta552 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta553 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta549;
          _HtCr2U = tmpMeta551;
          _HtS2U = tmpMeta552;
          _HtU2S = tmpMeta553;
          tmp4 += 10; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta559 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta560 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta559, _inUt, _inargs, &tmpMeta554, &tmpMeta558);
          _ut = tmpMeta560;
          tmpMeta555 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta554), 1));
          tmpMeta556 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta554), 2));
          tmpMeta557 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta554), 3));
          _HtCr2U = tmpMeta555;
          _HtS2U = tmpMeta556;
          _HtU2S = tmpMeta557;
          _expListList = tmpMeta558;
          tmpMeta561 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta561;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 24: {
          modelica_metatype tmpMeta562;
          modelica_metatype tmpMeta563;
          modelica_metatype tmpMeta564;
          modelica_metatype tmpMeta565;
          modelica_metatype tmpMeta566;
          modelica_metatype tmpMeta567;
          modelica_metatype tmpMeta568;
          modelica_metatype tmpMeta569;
          modelica_metatype tmpMeta570;
          modelica_metatype tmpMeta571;
          modelica_metatype tmpMeta572;
          modelica_metatype tmpMeta573;
          modelica_metatype tmpMeta574;
          modelica_metatype tmpMeta575;
          modelica_metatype tmpMeta576;
          modelica_metatype tmpMeta577;
          modelica_metatype tmpMeta578;
          modelica_metatype tmpMeta579;
          modelica_metatype tmpMeta580;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta562 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta562,1,1) == 0) goto tmp3_end;
          tmpMeta563 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta562), 2));
          if (3 != MMC_STRLEN(tmpMeta563) || strcmp(MMC_STRINGDATA(_OMC_LIT27), MMC_STRINGDATA(tmpMeta563)) != 0) goto tmp3_end;
          tmpMeta564 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta564)) goto tmp3_end;
          tmpMeta565 = MMC_CAR(tmpMeta564);
          tmpMeta566 = MMC_CDR(tmpMeta564);
          if (!listEmpty(tmpMeta566)) goto tmp3_end;
          tmpMeta567 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta568 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta569 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta565;
          _HtCr2U = tmpMeta567;
          _HtS2U = tmpMeta568;
          _HtU2S = tmpMeta569;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta575 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta576 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta575, _OMC_LIT4, _inargs, &tmpMeta570, &tmpMeta574);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta576,1,1) == 0) goto goto_2;
          tmpMeta577 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta576), 2));
          _lcr = tmpMeta577;
          tmpMeta571 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta570), 1));
          tmpMeta572 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta570), 2));
          tmpMeta573 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta570), 3));
          _HtCr2U = tmpMeta571;
          _HtS2U = tmpMeta572;
          _HtU2S = tmpMeta573;
          _expListList = tmpMeta574;

          _ut = omc_FUnit_unitMul(threadData, _inUt, _OMC_LIT22);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          tmpMeta578 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta578, _HtS2U);

          tmpMeta579 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta579, _HtU2S);
          tmpMeta580 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta580;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 25: {
          modelica_metatype tmpMeta581;
          modelica_metatype tmpMeta582;
          modelica_metatype tmpMeta583;
          modelica_metatype tmpMeta584;
          modelica_metatype tmpMeta585;
          modelica_metatype tmpMeta586;
          modelica_metatype tmpMeta587;
          modelica_metatype tmpMeta588;
          modelica_metatype tmpMeta589;
          modelica_metatype tmpMeta590;
          modelica_metatype tmpMeta591;
          modelica_metatype tmpMeta592;
          modelica_metatype tmpMeta593;
          modelica_metatype tmpMeta594;
          modelica_metatype tmpMeta595;
          modelica_metatype tmpMeta596;
          modelica_metatype tmpMeta597;
          modelica_metatype tmpMeta598;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta581 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta581,1,1) == 0) goto tmp3_end;
          tmpMeta582 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta581), 2));
          if (3 != MMC_STRLEN(tmpMeta582) || strcmp(MMC_STRINGDATA(_OMC_LIT27), MMC_STRINGDATA(tmpMeta582)) != 0) goto tmp3_end;
          tmpMeta583 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta583)) goto tmp3_end;
          tmpMeta584 = MMC_CAR(tmpMeta583);
          tmpMeta585 = MMC_CDR(tmpMeta583);
          if (!listEmpty(tmpMeta585)) goto tmp3_end;
          tmpMeta586 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta587 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta588 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta584;
          _HtCr2U = tmpMeta586;
          _HtS2U = tmpMeta587;
          _HtU2S = tmpMeta588;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta594 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta595 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta594, _OMC_LIT4, _inargs, &tmpMeta589, &tmpMeta593);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta595,0,8) == 0) goto goto_2;
          _ut = tmpMeta595;
          tmpMeta590 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta589), 1));
          tmpMeta591 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta589), 2));
          tmpMeta592 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta589), 3));
          _HtCr2U = tmpMeta590;
          _HtS2U = tmpMeta591;
          _HtU2S = tmpMeta592;
          _expListList = tmpMeta593;

          _ut = omc_FUnit_unitDiv(threadData, _ut, _OMC_LIT22);

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          tmpMeta596 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta596, _HtS2U);

          tmpMeta597 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta597, _HtU2S);
          tmpMeta598 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta598;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 26: {
          modelica_metatype tmpMeta599;
          modelica_metatype tmpMeta600;
          modelica_metatype tmpMeta601;
          modelica_metatype tmpMeta602;
          modelica_metatype tmpMeta603;
          modelica_metatype tmpMeta604;
          modelica_metatype tmpMeta605;
          modelica_metatype tmpMeta606;
          modelica_metatype tmpMeta607;
          modelica_metatype tmpMeta608;
          modelica_metatype tmpMeta609;
          modelica_metatype tmpMeta610;
          modelica_metatype tmpMeta611;
          modelica_metatype tmpMeta612;
          modelica_metatype tmpMeta613;
          modelica_metatype tmpMeta614;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,1,1) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta599 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta599,1,1) == 0) goto tmp3_end;
          tmpMeta600 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta599), 2));
          if (3 != MMC_STRLEN(tmpMeta600) || strcmp(MMC_STRINGDATA(_OMC_LIT27), MMC_STRINGDATA(tmpMeta600)) != 0) goto tmp3_end;
          tmpMeta601 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta601)) goto tmp3_end;
          tmpMeta602 = MMC_CAR(tmpMeta601);
          tmpMeta603 = MMC_CDR(tmpMeta601);
          if (!listEmpty(tmpMeta603)) goto tmp3_end;
          tmpMeta604 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta605 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta606 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta602;
          _HtCr2U = tmpMeta604;
          _HtS2U = tmpMeta605;
          _HtU2S = tmpMeta606;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta612 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta613 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta612, _OMC_LIT4, _inargs, &tmpMeta607, &tmpMeta611);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta613,1,1) == 0) goto goto_2;
          tmpMeta608 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta607), 1));
          tmpMeta609 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta607), 2));
          tmpMeta610 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta607), 3));
          _HtCr2U = tmpMeta608;
          _HtS2U = tmpMeta609;
          _HtU2S = tmpMeta610;
          _expListList = tmpMeta611;
          tmpMeta614 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta614;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 27: {
          modelica_metatype tmpMeta615;
          modelica_metatype tmpMeta616;
          modelica_metatype tmpMeta617;
          modelica_metatype tmpMeta618;
          modelica_metatype tmpMeta619;
          modelica_metatype tmpMeta620;
          modelica_metatype tmpMeta621;
          modelica_metatype tmpMeta622;
          modelica_metatype tmpMeta623;
          modelica_metatype tmpMeta624;
          modelica_metatype tmpMeta625;
          modelica_metatype tmpMeta626;
          modelica_metatype tmpMeta627;
          modelica_metatype tmpMeta628;
          modelica_metatype tmpMeta629;
          modelica_metatype tmpMeta630;
          modelica_metatype tmpMeta631;
          modelica_real tmp632;
          modelica_metatype tmpMeta633;
          modelica_integer tmp634;
          modelica_metatype tmpMeta635;
          modelica_integer tmp636;
          modelica_metatype tmpMeta637;
          modelica_integer tmp638;
          modelica_metatype tmpMeta639;
          modelica_integer tmp640;
          modelica_metatype tmpMeta641;
          modelica_integer tmp642;
          modelica_metatype tmpMeta643;
          modelica_integer tmp644;
          modelica_metatype tmpMeta645;
          modelica_integer tmp646;
          modelica_metatype tmpMeta647;
          modelica_metatype tmpMeta648;
          modelica_metatype tmpMeta649;
          modelica_metatype tmpMeta650;
          modelica_metatype tmpMeta651;
          modelica_metatype tmpMeta652;
          modelica_metatype tmpMeta653;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta615 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta615,1,1) == 0) goto tmp3_end;
          tmpMeta616 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta615), 2));
          if (4 != MMC_STRLEN(tmpMeta616) || strcmp(MMC_STRINGDATA(_OMC_LIT28), MMC_STRINGDATA(tmpMeta616)) != 0) goto tmp3_end;
          tmpMeta617 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta617)) goto tmp3_end;
          tmpMeta618 = MMC_CAR(tmpMeta617);
          tmpMeta619 = MMC_CDR(tmpMeta617);
          if (!listEmpty(tmpMeta619)) goto tmp3_end;
          tmpMeta620 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta621 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta622 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta618;
          _HtCr2U = tmpMeta620;
          _HtS2U = tmpMeta621;
          _HtU2S = tmpMeta622;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta628 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta629 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta628, _OMC_LIT4, _inargs, &tmpMeta623, &tmpMeta627);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta629,0,8) == 0) goto goto_2;
          _ut = tmpMeta629;
          tmpMeta624 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta623), 1));
          tmpMeta625 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta623), 2));
          tmpMeta626 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta623), 3));
          _HtCr2U = tmpMeta624;
          _HtS2U = tmpMeta625;
          _HtU2S = tmpMeta626;
          _expListList = tmpMeta627;

          /* Pattern-matching assignment */
          tmpMeta630 = omc_FUnit_unitRoot(threadData, _ut, 2.0);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta630,0,8) == 0) goto goto_2;
          tmpMeta631 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 2));
          tmp632 = mmc_unbox_real(tmpMeta631);
          tmpMeta633 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 3));
          tmp634 = mmc_unbox_integer(tmpMeta633);
          tmpMeta635 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 4));
          tmp636 = mmc_unbox_integer(tmpMeta635);
          tmpMeta637 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 5));
          tmp638 = mmc_unbox_integer(tmpMeta637);
          tmpMeta639 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 6));
          tmp640 = mmc_unbox_integer(tmpMeta639);
          tmpMeta641 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 7));
          tmp642 = mmc_unbox_integer(tmpMeta641);
          tmpMeta643 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 8));
          tmp644 = mmc_unbox_integer(tmpMeta643);
          tmpMeta645 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta630), 9));
          tmp646 = mmc_unbox_integer(tmpMeta645);
          _factor1 = tmp632  /* pattern as ty=Real */;
          _i1 = tmp634  /* pattern as ty=Integer */;
          _i2 = tmp636  /* pattern as ty=Integer */;
          _i3 = tmp638  /* pattern as ty=Integer */;
          _i4 = tmp640  /* pattern as ty=Integer */;
          _i5 = tmp642  /* pattern as ty=Integer */;
          _i6 = tmp644  /* pattern as ty=Integer */;
          _i7 = tmp646  /* pattern as ty=Integer */;

          tmpMeta647 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          _s1 = omc_FUnit_unitString(threadData, tmpMeta647, _HtU2S);

          tmpMeta648 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmpMeta649 = mmc_mk_box2(0, _s1, tmpMeta648);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta649, _HtS2U);

          tmpMeta650 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmpMeta651 = mmc_mk_box2(0, _s1, tmpMeta650);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta651, _HtU2S);
          tmpMeta652 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
          tmpMeta653 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = tmpMeta652;
          tmpMeta[0+1] = tmpMeta653;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 28: {
          modelica_metatype tmpMeta654;
          modelica_metatype tmpMeta655;
          modelica_metatype tmpMeta656;
          modelica_metatype tmpMeta657;
          modelica_metatype tmpMeta658;
          modelica_metatype tmpMeta659;
          modelica_metatype tmpMeta660;
          modelica_metatype tmpMeta661;
          modelica_metatype tmpMeta662;
          modelica_metatype tmpMeta663;
          modelica_metatype tmpMeta664;
          modelica_metatype tmpMeta665;
          modelica_metatype tmpMeta666;
          modelica_metatype tmpMeta667;
          modelica_metatype tmpMeta668;
          modelica_metatype tmpMeta669;
          modelica_metatype tmpMeta670;
          modelica_metatype tmpMeta671;
          modelica_metatype tmpMeta672;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_3,0,8) == 0) goto tmp3_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta654 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta654,1,1) == 0) goto tmp3_end;
          tmpMeta655 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta654), 2));
          if (4 != MMC_STRLEN(tmpMeta655) || strcmp(MMC_STRINGDATA(_OMC_LIT28), MMC_STRINGDATA(tmpMeta655)) != 0) goto tmp3_end;
          tmpMeta656 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta656)) goto tmp3_end;
          tmpMeta657 = MMC_CAR(tmpMeta656);
          tmpMeta658 = MMC_CDR(tmpMeta656);
          if (!listEmpty(tmpMeta658)) goto tmp3_end;
          tmpMeta659 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta660 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta661 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          _exp1 = tmpMeta657;
          _HtCr2U = tmpMeta659;
          _HtS2U = tmpMeta660;
          _HtU2S = tmpMeta661;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta667 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta668 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta667, _OMC_LIT4, _inargs, &tmpMeta662, &tmpMeta666);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta668,1,1) == 0) goto goto_2;
          tmpMeta669 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta668), 2));
          _lcr = tmpMeta669;
          tmpMeta663 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta662), 1));
          tmpMeta664 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta662), 2));
          tmpMeta665 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta662), 3));
          _HtCr2U = tmpMeta663;
          _HtS2U = tmpMeta664;
          _HtU2S = tmpMeta665;
          _expListList = tmpMeta666;

          _ut = omc_FUnit_unitPow(threadData, _inUt, ((modelica_integer) 2));

          _s1 = omc_FUnit_unitString(threadData, _ut, _HtU2S);

          _HtCr2U = omc_List_fold1(threadData, _lcr, boxvar_FUnitCheck_updateHtCr2U, _ut, _HtCr2U);

          tmpMeta670 = mmc_mk_box2(0, _s1, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta670, _HtS2U);

          tmpMeta671 = mmc_mk_box2(0, _s1, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta671, _HtU2S);
          tmpMeta672 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _inUt;
          tmpMeta[0+1] = tmpMeta672;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 29: {
          modelica_metatype tmpMeta673;
          modelica_metatype tmpMeta674;
          modelica_metatype tmpMeta675;
          modelica_metatype tmpMeta676;
          modelica_metatype tmpMeta677;
          modelica_metatype tmpMeta678;
          modelica_metatype tmpMeta679;
          modelica_metatype tmpMeta680;
          modelica_metatype tmpMeta681;
          modelica_metatype tmpMeta682;
          modelica_metatype tmpMeta683;
          modelica_metatype tmpMeta684;
          modelica_metatype tmpMeta685;
          modelica_metatype tmpMeta686;
          modelica_metatype tmpMeta687;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta673 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta673,1,1) == 0) goto tmp3_end;
          tmpMeta674 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta673), 2));
          if (4 != MMC_STRLEN(tmpMeta674) || strcmp(MMC_STRINGDATA(_OMC_LIT28), MMC_STRINGDATA(tmpMeta674)) != 0) goto tmp3_end;
          tmpMeta675 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (listEmpty(tmpMeta675)) goto tmp3_end;
          tmpMeta676 = MMC_CAR(tmpMeta675);
          tmpMeta677 = MMC_CDR(tmpMeta675);
          if (!listEmpty(tmpMeta677)) goto tmp3_end;
          tmpMeta678 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta679 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta680 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta676;
          _HtCr2U = tmpMeta678;
          _HtS2U = tmpMeta679;
          _HtU2S = tmpMeta680;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta686 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta686, _OMC_LIT4, _inargs, &tmpMeta681, &tmpMeta685);
          tmpMeta682 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta681), 1));
          tmpMeta683 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta681), 2));
          tmpMeta684 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta681), 3));
          _HtCr2U = tmpMeta682;
          _HtS2U = tmpMeta683;
          _HtU2S = tmpMeta684;
          _expListList = tmpMeta685;
          tmpMeta687 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta687;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 30: {
          modelica_metatype tmpMeta688;
          modelica_metatype tmpMeta689;
          modelica_metatype tmpMeta690;
          modelica_metatype tmpMeta691;
          modelica_metatype tmpMeta692;
          modelica_metatype tmpMeta693;
          modelica_metatype tmpMeta694;
          modelica_metatype tmpMeta695;
          modelica_metatype tmpMeta696;
          modelica_metatype tmpMeta697;
          modelica_metatype tmpMeta698;
          modelica_metatype tmpMeta699;
          modelica_metatype tmpMeta700;
          modelica_metatype tmpMeta701;
          modelica_metatype tmpMeta702;
          modelica_metatype tmpMeta703;
          modelica_metatype tmpMeta704;
          modelica_metatype tmpMeta705;
          modelica_metatype tmpMeta706;
          modelica_metatype tmpMeta707;
          modelica_metatype tmpMeta708;
          modelica_boolean tmp709;
          modelica_metatype tmpMeta710;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta688 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta689 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta690 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta691 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta692 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp2 = tmpMeta688;
          _exp3 = tmpMeta689;
          _HtCr2U = tmpMeta690;
          _HtS2U = tmpMeta691;
          _HtU2S = tmpMeta692;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta698 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta699 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta698, _inUt, _inargs, &tmpMeta693, &tmpMeta697);
          _ut = tmpMeta699;
          tmpMeta694 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta693), 1));
          tmpMeta695 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta693), 2));
          tmpMeta696 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta693), 3));
          _HtCr2U = tmpMeta694;
          _HtS2U = tmpMeta695;
          _HtU2S = tmpMeta696;
          _expListList2 = tmpMeta697;

          /* Pattern-matching tuple assignment */
          tmpMeta705 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta706 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp3, tmpMeta705, _ut, _inargs, &tmpMeta700, &tmpMeta704);
          _ut2 = tmpMeta706;
          tmpMeta701 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta700), 1));
          tmpMeta702 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta700), 2));
          tmpMeta703 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta700), 3));
          _HtCr2U = tmpMeta701;
          _HtS2U = tmpMeta702;
          _HtU2S = tmpMeta703;
          _expListList3 = tmpMeta704;

          /* Pattern-matching tuple assignment */
          tmp709 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta707, &tmpMeta708);
          if (1 /* true */ != tmp709) goto goto_2;
          _ut = tmpMeta707;
          _HtCr2U = tmpMeta708;

          _expListList = omc_List_append__reverse(threadData, _expListList2, _expListList3);
          tmpMeta710 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta710;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 31: {
          modelica_metatype tmpMeta711;
          modelica_metatype tmpMeta712;
          modelica_metatype tmpMeta713;
          modelica_metatype tmpMeta714;
          modelica_metatype tmpMeta715;
          modelica_metatype tmpMeta716;
          modelica_metatype tmpMeta717;
          modelica_metatype tmpMeta718;
          modelica_metatype tmpMeta719;
          modelica_metatype tmpMeta720;
          modelica_metatype tmpMeta721;
          modelica_metatype tmpMeta722;
          modelica_metatype tmpMeta723;
          modelica_metatype tmpMeta724;
          modelica_metatype tmpMeta725;
          modelica_metatype tmpMeta726;
          modelica_metatype tmpMeta727;
          modelica_metatype tmpMeta728;
          modelica_metatype tmpMeta729;
          modelica_boolean tmp730;
          modelica_metatype tmpMeta731;
          modelica_metatype tmpMeta732;
          modelica_metatype tmpMeta733;
          modelica_metatype tmpMeta734;
          modelica_metatype tmpMeta735;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,12,3) == 0) goto tmp3_end;
          tmpMeta711 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta712 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta713 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta714 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta715 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp2 = tmpMeta711;
          _exp3 = tmpMeta712;
          _HtCr2U = tmpMeta713;
          _HtS2U = tmpMeta714;
          _HtU2S = tmpMeta715;
          tmp4 += 7; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta721 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta722 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp2, tmpMeta721, _inUt, _inargs, &tmpMeta716, &tmpMeta720);
          _ut = tmpMeta722;
          tmpMeta717 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta716), 1));
          tmpMeta718 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta716), 2));
          tmpMeta719 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta716), 3));
          _HtCr2U = tmpMeta717;
          _HtS2U = tmpMeta718;
          _HtU2S = tmpMeta719;
          _expListList2 = tmpMeta720;

          /* Pattern-matching tuple assignment */
          tmpMeta728 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta729 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp3, tmpMeta728, _ut, _inargs, &tmpMeta723, &tmpMeta727);
          _ut2 = tmpMeta729;
          tmpMeta724 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta723), 1));
          tmpMeta725 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta723), 2));
          tmpMeta726 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta723), 3));
          _HtCr2U = tmpMeta724;
          _HtS2U = tmpMeta725;
          _HtU2S = tmpMeta726;
          _expListList3 = tmpMeta727;

          /* Pattern-matching tuple assignment */
          tmp730 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp730) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList2, _expListList3);

          tmpMeta733 = mmc_mk_box2(0, _exp2, _ut);
          tmpMeta734 = mmc_mk_box2(0, _exp3, _ut2);
          tmpMeta732 = mmc_mk_cons(tmpMeta733, mmc_mk_cons(tmpMeta734, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta731 = mmc_mk_cons(tmpMeta732, _expListList);
          _expListList = tmpMeta731;
          tmpMeta735 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta735;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 32: {
          modelica_metatype tmpMeta736;
          modelica_metatype tmpMeta737;
          modelica_metatype tmpMeta738;
          modelica_metatype tmpMeta739;
          modelica_metatype tmpMeta740;
          modelica_metatype tmpMeta741;
          modelica_metatype tmpMeta742;
          modelica_metatype tmpMeta743;
          modelica_metatype tmpMeta744;
          modelica_metatype tmpMeta745;
          modelica_metatype tmpMeta746;
          modelica_metatype tmpMeta747;
          modelica_metatype tmpMeta748;
          modelica_metatype tmpMeta749;
          modelica_metatype tmpMeta750;
          modelica_metatype tmpMeta751;
          modelica_metatype tmpMeta752;
          modelica_metatype tmpMeta753;
          modelica_metatype tmpMeta754;
          modelica_metatype tmpMeta755;
          modelica_boolean tmp756;
          modelica_metatype tmpMeta757;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta736 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta737 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta738 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta739 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta736;
          _HtCr2U = tmpMeta737;
          _HtS2U = tmpMeta738;
          _HtU2S = tmpMeta739;
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment */
          tmpMeta745 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta746 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta745, _inUt, _inargs, &tmpMeta740, &tmpMeta744);
          _ut = tmpMeta746;
          tmpMeta741 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta740), 1));
          tmpMeta742 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta740), 2));
          tmpMeta743 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta740), 3));
          _HtCr2U = tmpMeta741;
          _HtS2U = tmpMeta742;
          _HtU2S = tmpMeta743;
          _expListList = tmpMeta744;

          /* Pattern-matching tuple assignment */
          tmpMeta752 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta753 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta752, _inUt, _inargs, &tmpMeta747, &tmpMeta751);
          _ut2 = tmpMeta753;
          tmpMeta748 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta747), 1));
          tmpMeta749 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta747), 2));
          tmpMeta750 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta747), 3));
          _HtCr2U = tmpMeta748;
          _HtS2U = tmpMeta749;
          _HtU2S = tmpMeta750;
          _expListList2 = tmpMeta751;

          /* Pattern-matching tuple assignment */
          tmp756 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, &tmpMeta754, &tmpMeta755);
          if (1 /* true */ != tmp756) goto goto_2;
          _ut = tmpMeta754;
          _HtCr2U = tmpMeta755;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);
          tmpMeta757 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta757;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 33: {
          modelica_metatype tmpMeta758;
          modelica_metatype tmpMeta759;
          modelica_metatype tmpMeta760;
          modelica_metatype tmpMeta761;
          modelica_metatype tmpMeta762;
          modelica_metatype tmpMeta763;
          modelica_metatype tmpMeta764;
          modelica_metatype tmpMeta765;
          modelica_metatype tmpMeta766;
          modelica_metatype tmpMeta767;
          modelica_metatype tmpMeta768;
          modelica_metatype tmpMeta769;
          modelica_metatype tmpMeta770;
          modelica_metatype tmpMeta771;
          modelica_metatype tmpMeta772;
          modelica_metatype tmpMeta773;
          modelica_metatype tmpMeta774;
          modelica_metatype tmpMeta775;
          modelica_metatype tmpMeta776;
          modelica_boolean tmp777;
          modelica_metatype tmpMeta778;
          modelica_metatype tmpMeta779;
          modelica_metatype tmpMeta780;
          modelica_metatype tmpMeta781;
          modelica_metatype tmpMeta782;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,11,5) == 0) goto tmp3_end;
          tmpMeta758 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta759 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          tmpMeta760 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta761 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta762 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta758;
          _exp2 = tmpMeta759;
          _HtCr2U = tmpMeta760;
          _HtS2U = tmpMeta761;
          _HtU2S = tmpMeta762;
          tmp4 += 5; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta768 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta769 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta768, _inUt, _inargs, &tmpMeta763, &tmpMeta767);
          _ut = tmpMeta769;
          tmpMeta764 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta763), 1));
          tmpMeta765 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta763), 2));
          tmpMeta766 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta763), 3));
          _HtCr2U = tmpMeta764;
          _HtS2U = tmpMeta765;
          _HtU2S = tmpMeta766;
          _expListList = tmpMeta767;

          /* Pattern-matching tuple assignment */
          tmpMeta775 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta776 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta775, _inUt, _inargs, &tmpMeta770, &tmpMeta774);
          _ut2 = tmpMeta776;
          tmpMeta771 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta770), 1));
          tmpMeta772 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta770), 2));
          tmpMeta773 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta770), 3));
          _HtCr2U = tmpMeta771;
          _HtS2U = tmpMeta772;
          _HtU2S = tmpMeta773;
          _expListList2 = tmpMeta774;

          /* Pattern-matching tuple assignment */
          tmp777 = omc_FUnitCheck_UnitTypesEqual(threadData, _ut, _ut2, _HtCr2U, NULL, NULL);
          if (0 /* false */ != tmp777) goto goto_2;

          _expListList = omc_List_append__reverse(threadData, _expListList, _expListList2);

          tmpMeta780 = mmc_mk_box2(0, _exp1, _ut);
          tmpMeta781 = mmc_mk_box2(0, _exp2, _ut2);
          tmpMeta779 = mmc_mk_cons(tmpMeta780, mmc_mk_cons(tmpMeta781, MMC_REFSTRUCTLIT(mmc_nil)));
          tmpMeta778 = mmc_mk_cons(tmpMeta779, _expListList);
          _expListList = tmpMeta778;
          tmpMeta782 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta782;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 34: {
          modelica_metatype tmpMeta783;
          modelica_metatype tmpMeta784;
          modelica_metatype tmpMeta785;
          modelica_metatype tmpMeta786;
          modelica_metatype tmpMeta787;
          modelica_metatype tmpMeta788;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta783 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta783,1,1) == 0) goto tmp3_end;
          tmpMeta784 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta785 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta786 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta787 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _ExpList = tmpMeta784;
          _HtCr2U = tmpMeta785;
          _HtS2U = tmpMeta786;
          _HtU2S = tmpMeta787;
          tmp4 += 4; /* Pattern matching succeeded; we may skip some cases if we fail */
          _HtCr2U = omc_FUnitCheck_foldCallArg(threadData, _ExpList, _HtCr2U, _HtS2U, _HtU2S ,&_HtS2U ,&_HtU2S ,&_expListList);
          tmpMeta788 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta788;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 35: {
          modelica_metatype tmpMeta789;
          modelica_metatype tmpMeta790;
          modelica_metatype tmpMeta791;
          modelica_metatype tmpMeta792;
          modelica_metatype tmpMeta793;
          modelica_metatype tmpMeta794;
          modelica_metatype tmpMeta795;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,3) == 0) goto tmp3_end;
          tmpMeta789 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta789,2,1) == 0) goto tmp3_end;
          tmpMeta790 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta789), 2));
          tmpMeta791 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta792 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta793 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta794 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _path = tmpMeta790;
          _ExpList = tmpMeta791;
          _HtCr2U = tmpMeta792;
          _HtS2U = tmpMeta793;
          _HtU2S = tmpMeta794;
          tmp4 += 3; /* Pattern matching succeeded; we may skip some cases if we fail */
          _s1 = omc_AbsynUtil_pathString(threadData, _path, _OMC_LIT23, 1 /* true */, 0 /* false */);

          _s1 = omc_System_trim(threadData, _s1, _OMC_LIT23);

          _invars = omc_FUnitCheck_getNamedUnitlist(threadData, _s1, _inargs ,NULL ,&_inunitlist ,NULL);

          _HtCr2U = omc_FUnitCheck_foldCallArg1(threadData, _ExpList, _HtCr2U, _HtS2U, _HtU2S, _inUt, _inunitlist, _invars, _s1 ,&_HtS2U ,&_HtU2S ,&_expListList);
          tmpMeta795 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = tmpMeta795;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 36: {
          modelica_metatype tmpMeta796;
          modelica_metatype tmpMeta797;
          modelica_metatype tmpMeta798;
          modelica_metatype tmpMeta799;
          modelica_metatype tmpMeta800;
          modelica_metatype tmpMeta801;
          modelica_metatype tmpMeta802;
          modelica_metatype tmpMeta803;
          modelica_metatype tmpMeta804;
          modelica_metatype tmpMeta805;
          modelica_metatype tmpMeta806;
          modelica_metatype tmpMeta807;
          modelica_metatype tmpMeta808;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,8,2) == 0) goto tmp3_end;
          tmpMeta796 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta796,5,1) == 0) goto tmp3_end;
          tmpMeta797 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          tmpMeta798 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta799 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta800 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _exp1 = tmpMeta797;
          _HtCr2U = tmpMeta798;
          _HtS2U = tmpMeta799;
          _HtU2S = tmpMeta800;
          tmp4 += 2; /* Pattern matching succeeded; we may skip some cases if we fail */
          /* Pattern-matching tuple assignment */
          tmpMeta806 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta807 = omc_FUnitCheck_insertUnitInEquation(threadData, _exp1, tmpMeta806, _inUt, _inargs, &tmpMeta801, &tmpMeta805);
          _ut = tmpMeta807;
          tmpMeta802 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta801), 1));
          tmpMeta803 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta801), 2));
          tmpMeta804 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta801), 3));
          _HtCr2U = tmpMeta802;
          _HtS2U = tmpMeta803;
          _HtU2S = tmpMeta804;
          _expListList = tmpMeta805;
          tmpMeta808 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta808;
          tmpMeta[0+2] = _expListList;
          goto tmp3_done;
        }
        case 37: {
          modelica_metatype tmpMeta809;
          modelica_metatype tmpMeta810;
          modelica_metatype tmpMeta811;
          modelica_metatype tmpMeta812;
          modelica_boolean tmp813;
          modelica_metatype tmpMeta814;
          modelica_metatype tmpMeta815;
          modelica_metatype tmpMeta816;
          modelica_metatype tmpMeta817;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta809 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta810 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta811 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmpMeta812 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          
          _cr = tmpMeta809;
          _HtCr2U = tmpMeta810;
          _HtS2U = tmpMeta811;
          _HtU2S = tmpMeta812;
          /* Pattern matching succeeded */
          /* Pattern-matching assignment */
          tmp813 = omc_ComponentReferenceBasics_crefEqual(threadData, _cr, _OMC_LIT25);
          if (1 /* true */ != tmp813) goto goto_2;

          _ut = _OMC_LIT22;

          tmpMeta814 = mmc_mk_box2(0, _OMC_LIT24, _ut);
          _HtS2U = omc_FUnitCheck_addUnit2HtS2U(threadData, tmpMeta814, _HtS2U);

          tmpMeta815 = mmc_mk_box2(0, _OMC_LIT24, _ut);
          _HtU2S = omc_FUnitCheck_addUnit2HtU2S(threadData, tmpMeta815, _HtU2S);
          tmpMeta816 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
          tmpMeta817 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = tmpMeta816;
          tmpMeta[0+2] = tmpMeta817;
          goto tmp3_done;
        }
        case 38: {
          modelica_metatype tmpMeta818;
          modelica_metatype tmpMeta819;
          modelica_metatype tmpMeta820;
          modelica_metatype tmpMeta821;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          tmpMeta818 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta819 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta819,1,1) == 0) goto tmp3_end;
          tmpMeta820 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          
          _cr = tmpMeta818;
          _HtCr2U = tmpMeta820;
          /* Pattern matching succeeded */
          _ut = omc_BaseHashTable_get(threadData, _cr, _HtCr2U);
          tmpMeta821 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = _ut;
          tmpMeta[0+1] = _inTpl;
          tmpMeta[0+2] = tmpMeta821;
          goto tmp3_done;
        }
        case 39: {
          modelica_metatype tmpMeta822;
          
          /* Pattern matching succeeded */
          tmpMeta822 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta[0+0] = _OMC_LIT4;
          tmpMeta[0+1] = _inTpl;
          tmpMeta[0+2] = tmpMeta822;
          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 < 40) {
        goto tmp3_top;
      }
      MMC_THROW_INTERNAL();
      tmp3_done2:;
    }
  }
  _outUt = tmpMeta[0+0];
  _outTpl = tmpMeta[0+1];
  _outexpList = tmpMeta[0+2];
  _return: OMC_LABEL_UNUSED
  if (out_outTpl) { *out_outTpl = _outTpl; }
  if (out_outexpList) { *out_outexpList = _outexpList; }
  return _outUt;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_makenewcref(threadData_t *threadData, modelica_metatype _inexp, modelica_string _instring, modelica_string _instring1)
{
  modelica_metatype _outexp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outexp has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_string tmp4_2;modelica_string tmp4_3;
    tmp4_1 = _inexp;
    tmp4_2 = _instring;
    tmp4_3 = _instring1;
    {
      modelica_metatype _cr = NULL;
      modelica_string _name = NULL;
      modelica_string _s1 = NULL;
      modelica_string _s2 = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _cr has no default value.
      // _name has no default value.
      // _s1 has no default value.
      // _s2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          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));
          
          _name = tmpMeta7;
          _s1 = tmp4_2;
          _s2 = tmp4_3;
          /* Pattern matching succeeded */
          tmpMeta8 = stringAppend(_s2,_OMC_LIT29);
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT23);
          tmpMeta10 = stringAppend(tmpMeta9,_s1);
          _name = tmpMeta10;

          _cr = omc_ComponentReference_makeUntypedCrefIdent(threadData, _name);

          tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(4));
          memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_inexp), 4*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[2] = _cr;
          _inexp = tmpMeta11;
          tmpMeta1 = _inexp;
          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_FUnitCheck_foldEquation2(threadData_t *threadData, modelica_metatype _eq, modelica_metatype __omcQ_24in_5FhtCr2U, modelica_metatype __omcQ_24in_5FhtS2U, modelica_metatype __omcQ_24in_5FhtU2S, modelica_metatype _args, modelica_metatype *out_htS2U, modelica_metatype *out_htU2S, modelica_metatype *out_inconsistentUnits)
{
  modelica_metatype _htCr2U = NULL;
  modelica_metatype _htS2U = NULL;
  modelica_metatype _htU2S = NULL;
  modelica_metatype _inconsistentUnits = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _htCr2U = __omcQ_24in_5FhtCr2U;
  _htS2U = __omcQ_24in_5FhtS2U;
  _htU2S = __omcQ_24in_5FhtU2S;
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _inconsistentUnits = tmpMeta1;
  { /* match expression */
    modelica_metatype tmp5_1;
    tmp5_1 = _eq;
    {
      modelica_metatype _temp = NULL;
      modelica_metatype _lhs = NULL;
      modelica_metatype _expList2 = NULL;
      modelica_metatype _expList3 = NULL;
      modelica_metatype _path = NULL;
      modelica_boolean _b;
      modelica_metatype _ut1 = NULL;
      modelica_metatype _ut2 = NULL;
      modelica_string _s1 = NULL;
      modelica_string _formalargs = NULL;
      modelica_string _formalvar = NULL;
      modelica_metatype _outvars = NULL;
      modelica_metatype _outunitlist = NULL;
      modelica_metatype _expl = NULL;
      volatile mmc_switch_type tmp5;
      int tmp6;
      // _temp has no default value.
      // _lhs has no default value.
      // _expList2 has no default value.
      // _expList3 has no default value.
      // _path has no default value.
      // _b has no default value.
      // _ut1 has no default value.
      // _ut2 has no default value.
      // _s1 has no default value.
      // _formalargs has no default value.
      // _formalvar has no default value.
      // _outvars has no default value.
      // _outunitlist has no default value.
      // _expl has no default value.
      tmp5 = 0;
      for (; tmp5 < 24; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,1,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta7 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), _OMC_LIT18);
          _lhs = tmpMeta7;

          tmpMeta8 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, _lhs);
          _temp = tmpMeta8;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta14 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta14, _OMC_LIT4, _args, &tmpMeta9, &tmpMeta13);
          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));
          _htCr2U = tmpMeta10;
          _htS2U = tmpMeta11;
          _htU2S = tmpMeta12;
          _inconsistentUnits = tmpMeta13;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 1: {
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,2,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta15 = mmc_mk_box3(9, &DAE_Exp_CREF__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), _OMC_LIT18);
          _lhs = tmpMeta15;

          tmpMeta16 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, _lhs);
          _temp = tmpMeta16;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta22 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta22, _OMC_LIT4, _args, &tmpMeta17, &tmpMeta21);
          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));
          _htCr2U = tmpMeta18;
          _htS2U = tmpMeta19;
          _htU2S = tmpMeta20;
          _inconsistentUnits = tmpMeta21;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 2: {
          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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,3) == 0) goto tmp4_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta23,19,1) == 0) goto tmp4_end;
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta23), 2));
          tmpMeta25 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta25,13,3) == 0) goto tmp4_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta25), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,2,1) == 0) goto tmp4_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta26), 2));
          
          _expl = tmpMeta24;
          _path = tmpMeta27;
          /* Pattern matching succeeded */
          _s1 = omc_AbsynUtil_pathString(threadData, _path, _OMC_LIT23, 1 /* true */, 0 /* false */);

          _s1 = omc_System_trim(threadData, _s1, _OMC_LIT23);

          omc_FUnitCheck_getNamedUnitlist(threadData, _s1, _args ,&_outvars ,NULL ,&_outunitlist);

          _htCr2U = omc_FUnitCheck_foldCallArg1(threadData, _expl, _htCr2U, _htS2U, _htU2S, _OMC_LIT4, _outunitlist, _outvars, _s1 ,&_htS2U ,&_htU2S ,&_expList2);

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta33 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), tmpMeta33, _OMC_LIT4, _args, &tmpMeta28, &tmpMeta32);
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 1));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 2));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta28), 3));
          _htCr2U = tmpMeta29;
          _htS2U = tmpMeta30;
          _htU2S = tmpMeta31;
          _expList3 = tmpMeta32;
          tmpMeta2 = omc_List_append__reverse(threadData, _expList2, _expList3);
          goto tmp4_done;
        }
        case 3: {
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_metatype tmpMeta42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          modelica_metatype tmpMeta45;
          modelica_metatype tmpMeta46;
          modelica_metatype tmpMeta47;
          modelica_metatype tmpMeta48;
          modelica_metatype tmpMeta49;
          modelica_metatype tmpMeta50;
          modelica_metatype tmpMeta51;
          modelica_metatype tmpMeta52;
          modelica_metatype tmpMeta53;
          modelica_metatype tmpMeta54;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,3) == 0) goto tmp4_end;
          tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 2));
          tmpMeta35 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta35,13,3) == 0) goto tmp4_end;
          tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta35), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta36,2,1) == 0) goto tmp4_end;
          tmpMeta37 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta36), 2));
          
          _lhs = tmpMeta34;
          _path = tmpMeta37;
          /* Pattern matching succeeded */
          _s1 = omc_AbsynUtil_pathString(threadData, _path, _OMC_LIT23, 1 /* true */, 0 /* false */);

          _s1 = omc_System_trim(threadData, _s1, _OMC_LIT23);

          omc_FUnitCheck_getNamedUnitlist(threadData, _s1, _args ,&_outvars ,NULL ,&_outunitlist);

          /* Pattern-matching tuple assignment */
          tmpMeta42 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          tmpMeta43 = omc_FUnitCheck_insertUnitInEquation(threadData, _lhs, tmpMeta42, _OMC_LIT4, _args, &tmpMeta38, NULL);
          _ut1 = tmpMeta43;
          tmpMeta39 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 1));
          tmpMeta40 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 2));
          tmpMeta41 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta38), 3));
          _htCr2U = tmpMeta39;
          _htS2U = tmpMeta40;
          _htU2S = tmpMeta41;

          _formalargs = listHead(_outunitlist);

          _formalvar = listHead(_outvars);

          _ut2 = ((stringEqual(_formalargs, _OMC_LIT5))?_OMC_LIT4:omc_FUnit_parseUnitString(threadData, _formalargs, omc_FUnit_getKnownUnits(threadData)));

          _b = omc_FUnitCheck_UnitTypesEqual(threadData, _ut1, _ut2, _htCr2U, NULL, NULL);

          if(_b)
          {
            tmpMeta44 = MMC_REFSTRUCTLIT(mmc_nil);
            _expList2 = tmpMeta44;
          }
          else
          {
            _temp = omc_FUnitCheck_makenewcref(threadData, _lhs, _formalvar, _s1);

            tmpMeta47 = mmc_mk_box2(0, _lhs, _ut1);
            tmpMeta48 = mmc_mk_box2(0, _temp, _ut2);
            tmpMeta46 = mmc_mk_cons(tmpMeta47, mmc_mk_cons(tmpMeta48, MMC_REFSTRUCTLIT(mmc_nil)));
            tmpMeta45 = mmc_mk_cons(tmpMeta46, MMC_REFSTRUCTLIT(mmc_nil));
            _expList2 = tmpMeta45;
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta54 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), tmpMeta54, _OMC_LIT4, _args, &tmpMeta49, &tmpMeta53);
          tmpMeta50 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 1));
          tmpMeta51 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 2));
          tmpMeta52 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta49), 3));
          _htCr2U = tmpMeta50;
          _htS2U = tmpMeta51;
          _htU2S = tmpMeta52;
          _expList3 = tmpMeta53;
          tmpMeta2 = omc_List_append__reverse(threadData, _expList2, _expList3);
          goto tmp4_done;
        }
        case 4: {
          modelica_metatype tmpMeta55;
          modelica_metatype tmpMeta56;
          modelica_metatype tmpMeta57;
          modelica_metatype tmpMeta58;
          modelica_metatype tmpMeta59;
          modelica_metatype tmpMeta60;
          modelica_metatype tmpMeta61;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta55 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))));
          _temp = tmpMeta55;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta61 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta61, _OMC_LIT4, _args, &tmpMeta56, &tmpMeta60);
          tmpMeta57 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 1));
          tmpMeta58 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 2));
          tmpMeta59 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta56), 3));
          _htCr2U = tmpMeta57;
          _htS2U = tmpMeta58;
          _htU2S = tmpMeta59;
          _inconsistentUnits = tmpMeta60;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 5: {
          modelica_metatype tmpMeta62;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,4,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta62 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta62;
          goto tmp4_done;
        }
        case 6: {
          modelica_metatype tmpMeta63;
          modelica_metatype tmpMeta64;
          modelica_metatype tmpMeta65;
          modelica_metatype tmpMeta66;
          modelica_metatype tmpMeta67;
          modelica_metatype tmpMeta68;
          modelica_metatype tmpMeta69;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,15,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta63 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))));
          _temp = tmpMeta63;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta69 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta69, _OMC_LIT4, _args, &tmpMeta64, &tmpMeta68);
          tmpMeta65 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 1));
          tmpMeta66 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 2));
          tmpMeta67 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta64), 3));
          _htCr2U = tmpMeta65;
          _htS2U = tmpMeta66;
          _htU2S = tmpMeta67;
          _inconsistentUnits = tmpMeta68;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 7: {
          modelica_metatype tmpMeta70;
          modelica_metatype tmpMeta71;
          modelica_metatype tmpMeta72;
          modelica_metatype tmpMeta73;
          modelica_metatype tmpMeta74;
          modelica_metatype tmpMeta75;
          modelica_metatype tmpMeta76;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,5,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta70 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))));
          _temp = tmpMeta70;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta76 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta76, _OMC_LIT4, _args, &tmpMeta71, &tmpMeta75);
          tmpMeta72 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 1));
          tmpMeta73 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 2));
          tmpMeta74 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta71), 3));
          _htCr2U = tmpMeta72;
          _htS2U = tmpMeta73;
          _htU2S = tmpMeta74;
          _inconsistentUnits = tmpMeta75;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 8: {
          modelica_metatype tmpMeta77;
          modelica_metatype tmpMeta78;
          modelica_metatype tmpMeta79;
          modelica_metatype tmpMeta80;
          modelica_metatype tmpMeta81;
          modelica_metatype tmpMeta82;
          modelica_metatype tmpMeta83;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,6,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta77 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 4))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))));
          _temp = tmpMeta77;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta83 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta83, _OMC_LIT4, _args, &tmpMeta78, &tmpMeta82);
          tmpMeta79 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta78), 1));
          tmpMeta80 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta78), 2));
          tmpMeta81 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta78), 3));
          _htCr2U = tmpMeta79;
          _htS2U = tmpMeta80;
          _htU2S = tmpMeta81;
          _inconsistentUnits = tmpMeta82;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 9: {
          modelica_metatype tmpMeta84;
          modelica_metatype tmpMeta85;
          modelica_metatype tmpMeta86;
          modelica_metatype tmpMeta87;
          modelica_metatype tmpMeta88;
          modelica_metatype tmpMeta89;
          modelica_metatype tmpMeta90;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,8,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta84 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))));
          _temp = tmpMeta84;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta90 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta90, _OMC_LIT4, _args, &tmpMeta85, &tmpMeta89);
          tmpMeta86 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta85), 1));
          tmpMeta87 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta85), 2));
          tmpMeta88 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta85), 3));
          _htCr2U = tmpMeta86;
          _htS2U = tmpMeta87;
          _htU2S = tmpMeta88;
          _inconsistentUnits = tmpMeta89;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 10: {
          modelica_metatype tmpMeta91;
          modelica_metatype tmpMeta92;
          modelica_metatype tmpMeta93;
          modelica_metatype tmpMeta94;
          modelica_metatype tmpMeta95;
          modelica_metatype tmpMeta96;
          modelica_metatype tmpMeta97;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,9,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta91 = mmc_mk_box4(10, &DAE_Exp_BINARY__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))), _OMC_LIT30, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))));
          _temp = tmpMeta91;

          if(omc_Flags_isSet(threadData, _OMC_LIT33))
          {
            omc_ExpressionDump_dumpExp(threadData, _temp);
          }

          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta97 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, _temp, tmpMeta97, _OMC_LIT4, _args, &tmpMeta92, &tmpMeta96);
          tmpMeta93 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 1));
          tmpMeta94 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 2));
          tmpMeta95 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta92), 3));
          _htCr2U = tmpMeta93;
          _htS2U = tmpMeta94;
          _htU2S = tmpMeta95;
          _inconsistentUnits = tmpMeta96;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 11: {
          modelica_metatype tmpMeta98;
          modelica_metatype tmpMeta99;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,10,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          {
            modelica_metatype _e;
            for (tmpMeta98 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 3))); !listEmpty(tmpMeta98); tmpMeta98=MMC_CDR(tmpMeta98))
            {
              _e = MMC_CAR(tmpMeta98);
              _htCr2U = omc_FUnitCheck_foldEquation2(threadData, _e, _htCr2U, _htS2U, _htU2S, _args ,&_htS2U ,&_htU2S ,&_inconsistentUnits);
            }
          }
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 12: {
          modelica_metatype tmpMeta100;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,13,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta100 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta100;
          goto tmp4_done;
        }
        case 13: {
          modelica_metatype tmpMeta101;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,14,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta101 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta101;
          goto tmp4_done;
        }
        case 14: {
          modelica_metatype tmpMeta102;
          modelica_metatype tmpMeta103;
          modelica_metatype tmpMeta104;
          modelica_metatype tmpMeta105;
          modelica_metatype tmpMeta106;
          modelica_metatype tmpMeta107;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,25,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta107 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), tmpMeta107, _OMC_LIT4, _args, &tmpMeta102, &tmpMeta106);
          tmpMeta103 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta102), 1));
          tmpMeta104 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta102), 2));
          tmpMeta105 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta102), 3));
          _htCr2U = tmpMeta103;
          _htS2U = tmpMeta104;
          _htU2S = tmpMeta105;
          _inconsistentUnits = tmpMeta106;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 15: {
          modelica_metatype tmpMeta108;
          modelica_metatype tmpMeta109;
          modelica_metatype tmpMeta110;
          modelica_metatype tmpMeta111;
          modelica_metatype tmpMeta112;
          modelica_metatype tmpMeta113;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,26,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          /* Pattern-matching tuple assignment, wild first pattern */
          tmpMeta113 = mmc_mk_box3(0, _htCr2U, _htS2U, _htU2S);
          omc_FUnitCheck_insertUnitInEquation(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eq), 2))), tmpMeta113, _OMC_LIT4, _args, &tmpMeta108, &tmpMeta112);
          tmpMeta109 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta108), 1));
          tmpMeta110 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta108), 2));
          tmpMeta111 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta108), 3));
          _htCr2U = tmpMeta109;
          _htS2U = tmpMeta110;
          _htU2S = tmpMeta111;
          _inconsistentUnits = tmpMeta112;
          tmpMeta2 = _inconsistentUnits;
          goto tmp4_done;
        }
        case 16: {
          modelica_metatype tmpMeta114;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,21,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta114 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta114;
          goto tmp4_done;
        }
        case 17: {
          modelica_metatype tmpMeta115;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,20,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta115 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta115;
          goto tmp4_done;
        }
        case 18: {
          modelica_metatype tmpMeta116;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,22,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta116 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta116;
          goto tmp4_done;
        }
        case 19: {
          modelica_metatype tmpMeta117;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,23,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta117 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta117;
          goto tmp4_done;
        }
        case 20: {
          modelica_metatype tmpMeta118;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,24,3) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta118 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta118;
          goto tmp4_done;
        }
        case 21: {
          modelica_metatype tmpMeta119;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,16,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta119 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta119;
          goto tmp4_done;
        }
        case 22: {
          modelica_metatype tmpMeta120;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,17,2) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta120 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta2 = tmpMeta120;
          goto tmp4_done;
        }
        case 23: {
          modelica_metatype tmpMeta121;
          
          /* Pattern matching succeeded */
          tmpMeta121 = stringAppend(_OMC_LIT34,omc_DAEDump_dumpEquationStr(threadData, _eq));
          omc_Error_addInternalError(threadData, tmpMeta121, _OMC_LIT36);
          goto goto_3;
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  _inconsistentUnits = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  if (out_htS2U) { *out_htS2U = _htS2U; }
  if (out_htU2S) { *out_htU2S = _htU2S; }
  if (out_inconsistentUnits) { *out_inconsistentUnits = _inconsistentUnits; }
  return _htCr2U;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldEquation(threadData_t *threadData, modelica_metatype _inEq, modelica_metatype _inargs, modelica_metatype _inTpl)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _HtCr2U = NULL;
  modelica_metatype _HtS2U = NULL;
  modelica_metatype _HtU2S = NULL;
  modelica_metatype _expListList = NULL;
  modelica_boolean _b;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_integer tmp4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _HtCr2U has no default value.
  // _HtS2U has no default value.
  // _HtU2S has no default value.
  // _expListList has no default value.
  // _b has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _inTpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  tmp4 = mmc_unbox_integer(tmpMeta3);
  tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 3));
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 4));
  _HtCr2U = tmpMeta2;
  _b = tmp4  /* pattern as ty=Boolean */;
  _HtS2U = tmpMeta5;
  _HtU2S = tmpMeta6;

  _HtCr2U = omc_FUnitCheck_foldEquation2(threadData, _inEq, _HtCr2U, _HtS2U, _HtU2S, _inargs ,&_HtS2U ,&_HtU2S ,&_expListList);

  omc_List_map2__0(threadData, _expListList, boxvar_FUnitCheck_Errorfunction, _inEq, _HtU2S);

  tmpMeta7 = mmc_mk_box4(0, _HtCr2U, mmc_mk_boolean(_b), _HtS2U, _HtU2S);
  _outTpl = tmpMeta7;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_foldBindingExp(threadData_t *threadData, modelica_metatype _inVar, 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 = _inVar;
    tmp4_2 = _inTpl;
    {
      modelica_metatype _exp = NULL;
      modelica_metatype _crefExp = NULL;
      modelica_metatype _cref = NULL;
      modelica_metatype _HtCr2U = NULL;
      modelica_metatype _HtS2U = NULL;
      modelica_metatype _HtU2S = NULL;
      modelica_boolean _b;
      modelica_metatype _eq = NULL;
      modelica_metatype _source = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp has no default value.
      // _crefExp has no default value.
      // _cref has no default value.
      // _HtCr2U has no default value.
      // _HtS2U has no default value.
      // _HtU2S has no default value.
      // _b has no default value.
      // _eq has no default value.
      // _source has no default value.
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_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_integer tmp22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          modelica_metatype tmpMeta25;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,1,1) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 11));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta12 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 2));
          tmp13 = mmc_unbox_integer(tmpMeta12);
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _cref = tmpMeta6;
          _exp = tmpMeta9;
          _source = tmpMeta10;
          _HtCr2U = tmpMeta11;
          _b = tmp13  /* pattern as ty=Boolean */;
          _HtS2U = tmpMeta14;
          _HtU2S = tmpMeta15;
          /* Pattern matching succeeded */
          _crefExp = omc_Expression_crefExp(threadData, _cref);

          tmpMeta16 = mmc_mk_box4(6, &DAE_Element_EQUATION__desc, _crefExp, _exp, _source);
          _eq = tmpMeta16;

          /* Pattern-matching assignment */
          tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
          tmpMeta18 = mmc_mk_box4(0, _HtCr2U, mmc_mk_boolean(_b), _HtS2U, _HtU2S);
          tmpMeta19 = omc_FUnitCheck_foldEquation(threadData, _eq, tmpMeta17, tmpMeta18);
          tmpMeta20 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 1));
          tmpMeta21 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 2));
          tmp22 = mmc_unbox_integer(tmpMeta21);
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 3));
          tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta19), 4));
          _HtCr2U = tmpMeta20;
          _b = tmp22  /* pattern as ty=Boolean */;
          _HtS2U = tmpMeta23;
          _HtU2S = tmpMeta24;
          tmpMeta25 = mmc_mk_box4(0, _HtCr2U, mmc_mk_boolean(_b), _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta25;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta26,1,1) == 0) goto tmp3_end;
          tmpMeta27 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 8));
          if (optionNone(tmpMeta27)) goto tmp3_end;
          tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta27), 1));
          tmpMeta29 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 1));
          tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 3));
          tmpMeta31 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_2), 4));
          _HtCr2U = tmpMeta29;
          _HtS2U = tmpMeta30;
          _HtU2S = tmpMeta31;
          /* Pattern matching succeeded */
          tmpMeta32 = mmc_mk_box4(0, _HtCr2U, mmc_mk_boolean(0 /* false */), _HtS2U, _HtU2S);
          tmpMeta1 = tmpMeta32;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inTpl;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

DLLDirection
modelica_metatype omc_FUnitCheck_algo(threadData_t *threadData, modelica_metatype _invarlist, modelica_metatype _ineqList, modelica_metatype _inargs, modelica_metatype _inHtCr2U, modelica_metatype _inHtS2U, modelica_metatype _inHtU2S)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _HtCr2U = NULL;
  modelica_metatype _HtS2U = NULL;
  modelica_metatype _HtU2S = NULL;
  modelica_boolean _b1;
  modelica_boolean _b2;
  modelica_boolean _b3;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_integer tmp5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_integer tmp12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _HtCr2U has no default value.
  // _HtS2U has no default value.
  // _HtU2S has no default value.
  // _b1 has no default value.
  // _b2 has no default value.
  // _b3 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = mmc_mk_box4(0, _inHtCr2U, mmc_mk_boolean(1 /* true */), _inHtS2U, _inHtU2S);
  tmpMeta2 = omc_List_fold(threadData, _invarlist, boxvar_FUnitCheck_foldBindingExp, tmpMeta1);
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
  tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
  tmp5 = mmc_unbox_integer(tmpMeta4);
  tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 3));
  tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 4));
  _HtCr2U = tmpMeta3;
  _b1 = tmp5  /* pattern as ty=Boolean */;
  _HtS2U = tmpMeta6;
  _HtU2S = tmpMeta7;

  /* Pattern-matching assignment */
  tmpMeta8 = mmc_mk_box4(0, _HtCr2U, mmc_mk_boolean(1 /* true */), _HtS2U, _HtU2S);
  tmpMeta9 = omc_List_fold1(threadData, _ineqList, boxvar_FUnitCheck_foldEquation, _inargs, tmpMeta8);
  tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
  tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
  tmp12 = mmc_unbox_integer(tmpMeta11);
  tmpMeta13 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 3));
  tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 4));
  _HtCr2U = tmpMeta10;
  _b2 = tmp12  /* pattern as ty=Boolean */;
  _HtS2U = tmpMeta13;
  _HtU2S = tmpMeta14;

  _b3 = omc_BaseHashTable_hasKey(threadData, _OMC_LIT19, _HtCr2U);

  tmpMeta15 = mmc_mk_box3(0, _HtCr2U, _HtS2U, _HtU2S);
  _outTpl = tmpMeta15;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_FUnitCheck_notification2(threadData_t *threadData, modelica_metatype _inLt1, modelica_metatype _inHtCr2U2, modelica_metatype _inHtU2S)
{
  modelica_string _outS = NULL;
  modelica_metatype _cr1 = NULL;
  modelica_real _factor1;
  modelica_integer _i1;
  modelica_integer _i2;
  modelica_integer _i3;
  modelica_integer _i4;
  modelica_integer _i5;
  modelica_integer _i6;
  modelica_integer _i7;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outS has no default value.
  _cr1 = _OMC_LIT38;
  _factor1 = 0.0;
  _i1 = ((modelica_integer) 0);
  _i2 = ((modelica_integer) 0);
  _i3 = ((modelica_integer) 0);
  _i4 = ((modelica_integer) 0);
  _i5 = ((modelica_integer) 0);
  _i6 = ((modelica_integer) 0);
  _i7 = ((modelica_integer) 0);
  {
    modelica_metatype __omcQ_24tmpVar1;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype tmpMeta4;
    modelica_metatype tmpMeta5;
    modelica_metatype tmpMeta6;
    modelica_metatype tmpMeta7;
    modelica_metatype tmpMeta8;
    modelica_string __omcQ_24tmpVar0;
    modelica_integer tmp9;
    modelica_metatype _t1_loopVar = 0;
    modelica_boolean tmp10 = 0;
    modelica_metatype _t1;
    _t1_loopVar = _inLt1;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar1 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar1;
    while(1) {
      tmp9 = 1;
      while (!listEmpty(_t1_loopVar)) {
        _t1 = MMC_CAR(_t1_loopVar);
        _t1_loopVar = MMC_CDR(_t1_loopVar);
        { /* match expression */
          modelica_metatype tmp13_1;
          tmp13_1 = _t1;
          {
            modelica_boolean _b;
            volatile mmc_switch_type tmp13;
            int tmp14;
            // _b has no default value.
            tmp13 = 0;
            for (; tmp13 < 2; tmp13++) {
              switch (MMC_SWITCH_CAST(tmp13)) {
              case 0: {
                modelica_metatype tmpMeta15;
                modelica_metatype tmpMeta16;
                tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 1));
                tmpMeta16 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp13_1), 2));
                if (mmc__uniontype__metarecord__typedef__equal(tmpMeta16,1,1) == 0) goto tmp12_end;
                
                _cr1 = tmpMeta15;
                /* Pattern matching succeeded */
                _b = 0 /* false */;

                { /* matchcontinue expression */
                  {
                    volatile mmc_switch_type tmp19;
                    int tmp20;
                    tmp19 = 0;
                    MMC_TRY_INTERNAL(mmc_jumper)
                    tmp18_top:
                    threadData->mmc_jumper = &new_mmc_jumper;
                    for (; tmp19 < 2; tmp19++) {
                      switch (MMC_SWITCH_CAST(tmp19)) {
                      case 0: {
                        modelica_metatype tmpMeta21;
                        modelica_metatype tmpMeta22;
                        modelica_real tmp23;
                        modelica_metatype tmpMeta24;
                        modelica_integer tmp25;
                        modelica_metatype tmpMeta26;
                        modelica_integer tmp27;
                        modelica_metatype tmpMeta28;
                        modelica_integer tmp29;
                        modelica_metatype tmpMeta30;
                        modelica_integer tmp31;
                        modelica_metatype tmpMeta32;
                        modelica_integer tmp33;
                        modelica_metatype tmpMeta34;
                        modelica_integer tmp35;
                        modelica_metatype tmpMeta36;
                        modelica_integer tmp37;
                        /* Pattern matching succeeded */
                        /* Pattern-matching assignment */
                        tmpMeta21 = omc_BaseHashTable_get(threadData, _cr1, _inHtCr2U2);
                        if (mmc__uniontype__metarecord__typedef__equal(tmpMeta21,0,8) == 0) goto goto_17;
                        tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 2));
                        tmp23 = mmc_unbox_real(tmpMeta22);
                        tmpMeta24 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 3));
                        tmp25 = mmc_unbox_integer(tmpMeta24);
                        tmpMeta26 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 4));
                        tmp27 = mmc_unbox_integer(tmpMeta26);
                        tmpMeta28 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 5));
                        tmp29 = mmc_unbox_integer(tmpMeta28);
                        tmpMeta30 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 6));
                        tmp31 = mmc_unbox_integer(tmpMeta30);
                        tmpMeta32 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 7));
                        tmp33 = mmc_unbox_integer(tmpMeta32);
                        tmpMeta34 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 8));
                        tmp35 = mmc_unbox_integer(tmpMeta34);
                        tmpMeta36 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta21), 9));
                        tmp37 = mmc_unbox_integer(tmpMeta36);
                        _factor1 = tmp23  /* pattern as ty=Real */;
                        _i1 = tmp25  /* pattern as ty=Integer */;
                        _i2 = tmp27  /* pattern as ty=Integer */;
                        _i3 = tmp29  /* pattern as ty=Integer */;
                        _i4 = tmp31  /* pattern as ty=Integer */;
                        _i5 = tmp33  /* pattern as ty=Integer */;
                        _i6 = tmp35  /* pattern as ty=Integer */;
                        _i7 = tmp37  /* pattern as ty=Integer */;

                        _b = 1 /* true */;
                        goto tmp18_done;
                      }
                      case 1: {
                        /* Pattern matching succeeded */
                        goto tmp18_done;
                      }
                      }
                      goto tmp18_end;
                      tmp18_end: ;
                    }
                    goto goto_17;
                    tmp18_done:
                    (void)tmp19;
                    MMC_RESTORE_INTERNAL(mmc_jumper);
                    goto tmp18_done2;
                    goto_17:;
                    MMC_CATCH_INTERNAL(mmc_jumper);
                    if (++tmp19 < 2) {
                      goto tmp18_top;
                    }
                    goto goto_11;
                    tmp18_done2:;
                  }
                }
                ;
                tmp10 = _b;
                goto tmp12_done;
              }
              case 1: {
                
                /* Pattern matching succeeded */
                tmp10 = 0 /* false */;
                goto tmp12_done;
              }
              }
              goto tmp12_end;
              tmp12_end: ;
            }
            goto goto_11;
            goto_11:;
            MMC_THROW_INTERNAL();
            goto tmp12_done;
            tmp12_done:;
          }
        }
        if (tmp10) {
          tmp9--;
          break;
        }
      }
      if (tmp9 == 0) {
        tmpMeta4 = stringAppend(_OMC_LIT8,omc_ComponentReference_crefStr(threadData, _cr1));
        tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT39);
        tmpMeta6 = mmc_mk_box9(3, &FUnit_Unit_UNIT__desc, mmc_mk_real(_factor1), mmc_mk_integer(_i1), mmc_mk_integer(_i2), mmc_mk_integer(_i3), mmc_mk_integer(_i4), mmc_mk_integer(_i5), mmc_mk_integer(_i6), mmc_mk_integer(_i7));
        tmpMeta7 = stringAppend(tmpMeta5,omc_FUnit_unitString(threadData, tmpMeta6, _inHtU2S));
        tmpMeta8 = stringAppend(tmpMeta7,_OMC_LIT9);
        __omcQ_24tmpVar0 = tmpMeta8;
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar0,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp9 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar1;
  }
  _outS = stringAppendList(tmpMeta1);
  _return: OMC_LABEL_UNUSED
  return _outS;
}

PROTECTED_FUNCTION_STATIC void omc_FUnitCheck_notification(threadData_t *threadData, modelica_metatype _inHtCr2U1, modelica_metatype _inHtCr2U2, modelica_metatype _inHtU2S)
{
  modelica_string _str = NULL;
  modelica_metatype _lt1 = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _lt1 has no default value.
  _lt1 = omc_BaseHashTable_hashTableList(threadData, _inHtCr2U1);

  _str = omc_FUnitCheck_notification2(threadData, _lt1, _inHtCr2U2, _inHtU2S);

  if((omc_Flags_isSet(threadData, _OMC_LIT42) && (!stringEqual(_str, _OMC_LIT0))))
  {
    omc_Error_addCompilerNotification(threadData, _str);
  }
  _return: OMC_LABEL_UNUSED
  return;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_returnVar(threadData_t *threadData, modelica_metatype _inVar, modelica_metatype _inHtCr2U, modelica_metatype _inHtU2S)
{
  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 = _inVar;
    {
      modelica_metatype _var = NULL;
      modelica_metatype _cr = NULL;
      modelica_metatype _ut = NULL;
      modelica_metatype _attr = NULL;
      modelica_string _s = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _var has no default value.
      // _cr has no default value.
      // _ut has no default value.
      // _attr has no default value.
      // _s 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;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 12));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,0,15) == 0) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 3));
          if (optionNone(tmpMeta8)) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 1));
          
          /* Pattern matching succeeded */
          tmpMeta1 = _inVar;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 12));
          
          _cr = tmpMeta10;
          _attr = tmpMeta11;
          /* Pattern matching succeeded */
          if(omc_BaseHashTable_hasKey(threadData, _cr, _inHtCr2U))
          {
            _ut = omc_BaseHashTable_get(threadData, _cr, _inHtCr2U);

            if(omc_FUnit_isUnit(threadData, _ut))
            {
              _s = omc_FUnit_unitString(threadData, _ut, _inHtU2S);

              tmpMeta12 = mmc_mk_box2(5, &DAE_Exp_SCONST__desc, _s);
              _attr = omc_DAEUtil_setUnitAttr(threadData, _attr, tmpMeta12);

              tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(16));
              memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_inVar), 16*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[12] = _attr;
              _inVar = tmpMeta13;

              _var = _inVar;
            }
            else
            {
              _var = _inVar;
            }
          }
          else
          {
            _var = _inVar;
          }
          tmpMeta1 = _var;
          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_FUnitCheck_updateDAElist(threadData_t *threadData, modelica_metatype _indaelist, modelica_metatype _indaevarlist)
{
  modelica_metatype _outdaelist = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outdaelist has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = _indaelist;
    tmp4_2 = _indaevarlist;
    {
      modelica_metatype _varlist2 = NULL;
      modelica_string _ident = NULL;
      modelica_metatype _eltsrc = NULL;
      modelica_metatype _comment = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _varlist2 has no default value.
      // _ident has no default value.
      // _eltsrc has no default value.
      // _comment has no default value.
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (listEmpty(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_CAR(tmpMeta6);
          tmpMeta8 = MMC_CDR(tmpMeta6);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta7,18,4) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 2));
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 4));
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 5));
          if (!listEmpty(tmpMeta8)) goto tmp3_end;
          
          _ident = tmpMeta9;
          _eltsrc = tmpMeta10;
          _comment = tmpMeta11;
          _varlist2 = tmp4_2;
          /* Pattern matching succeeded */
          tmpMeta13 = mmc_mk_box5(21, &DAE_Element_COMP__desc, _ident, _varlist2, _eltsrc, _comment);
          tmpMeta12 = mmc_mk_cons(tmpMeta13, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta14 = mmc_mk_box2(3, &DAE_DAElist_DAE__desc, tmpMeta12);
          tmpMeta1 = tmpMeta14;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outdaelist = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outdaelist;
}

DLLDirection
modelica_string omc_FUnitCheck_getUnits(threadData_t *threadData, modelica_metatype _inElement)
{
  modelica_string _outString = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outString has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inElement;
    {
      modelica_string _unitString = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _unitString has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 7));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,1,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 12));
          if (optionNone(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta7), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,0,15) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          if (optionNone(tmpMeta9)) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,2,1) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 2));
          
          _unitString = tmpMeta11;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(!stringEqual(_unitString, _OMC_LIT0))) goto tmp3_end;
          tmp1 = _unitString;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT5;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outString = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outString;
}

DLLDirection
modelica_string omc_FUnitCheck_getVars(threadData_t *threadData, modelica_metatype _inElement)
{
  modelica_string _outString = NULL;
  modelica_string tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outString has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _inElement;
    {
      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,0,14) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          
          _cr = tmpMeta6;
          /* Pattern matching succeeded */
          tmp1 = omc_ComponentReference_crefStr(threadData, _cr);
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmp1 = _OMC_LIT0;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _outString = tmp1;
  _return: OMC_LABEL_UNUSED
  return _outString;
}

DLLDirection
modelica_string omc_FUnitCheck_getFunctionName(threadData_t *threadData, modelica_metatype _inFunction)
{
  modelica_string _outString = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outString = omc_AbsynUtil_pathString(threadData, omc_AbsynUtil_makeNotFullyQualified(threadData, omc_DAEUtil_functionName(threadData, _inFunction)), _OMC_LIT23, 1 /* true */, 0 /* false */);
  _return: OMC_LABEL_UNUSED
  return _outString;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_FUnitCheck_parseFunctionList(threadData_t *threadData, modelica_metatype _infunction)
{
  modelica_metatype _outTpl = NULL;
  modelica_metatype _inelt = NULL;
  modelica_metatype _outelt = NULL;
  modelica_metatype _inunits = NULL;
  modelica_metatype _outunits = NULL;
  modelica_metatype _inargs = NULL;
  modelica_metatype _outargs = NULL;
  modelica_string _s = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _outTpl has no default value.
  // _inelt has no default value.
  // _outelt has no default value.
  // _inunits has no default value.
  // _outunits has no default value.
  // _inargs has no default value.
  // _outargs has no default value.
  // _s has no default value.
  _s = omc_FUnitCheck_getFunctionName(threadData, _infunction);

  _inelt = omc_DAEUtil_getFunctionInputVars(threadData, _infunction);

  _outelt = omc_DAEUtil_getFunctionOutputVars(threadData, _infunction);

  _inunits = omc_List_filterMap(threadData, _inelt, boxvar_FUnitCheck_getUnits);

  _outunits = omc_List_filterMap(threadData, _outelt, boxvar_FUnitCheck_getUnits);

  _inargs = omc_List_filterMap(threadData, _inelt, boxvar_FUnitCheck_getVars);

  _outargs = omc_List_filterMap(threadData, _outelt, boxvar_FUnitCheck_getVars);

  tmpMeta2 = mmc_mk_box6(3, &FUnitCheck_Functionargs_FUNCTIONUNITS__desc, _s, _inargs, _outargs, _inunits, _outunits);
  tmpMeta1 = mmc_mk_cons(tmpMeta2, MMC_REFSTRUCTLIT(mmc_nil));
  _outTpl = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _outTpl;
}

DLLDirection
modelica_metatype omc_FUnitCheck_checkUnits(threadData_t *threadData, modelica_metatype _inDAE, modelica_metatype _func)
{
  jmp_buf *old_mmc_jumper = threadData->mmc_jumper;
  modelica_metatype _outDAE = NULL;
  modelica_metatype _elts1 = NULL;
  modelica_metatype _elts2 = NULL;
  modelica_metatype _eqlist = NULL;
  modelica_metatype _varlist = NULL;
  modelica_metatype _newdaelist = NULL;
  modelica_metatype _functionlist = NULL;
  modelica_metatype _args = NULL;
  modelica_metatype _HtCr2U1 = NULL;
  modelica_metatype _HtCr2U2 = NULL;
  modelica_metatype _HtS2U = NULL;
  modelica_metatype _HtU2S = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _outDAE = _inDAE;
  // _elts1 has no default value.
  // _elts2 has no default value.
  // _eqlist has no default value.
  // _varlist has no default value.
  // _newdaelist has no default value.
  // _functionlist has no default value.
  // _args has no default value.
  // _HtCr2U1 has no default value.
  // _HtCr2U2 has no default value.
  // _HtS2U has no default value.
  // _HtU2S has no default value.
  if((!(omc_Flags_getConfigBool(threadData, _OMC_LIT47) || (omc_Flags_getConfigBool(threadData, _OMC_LIT51) && omc_Flags_isSet(threadData, _OMC_LIT54)))))
  {
    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;
          /* Pattern matching succeeded */
          _elts1 = omc_DAEUtil_splitDAEIntoVarsAndEquations(threadData, _inDAE ,&_elts2);

          _varlist = omc_FUnitCheck_GetVarList(threadData, _elts1);

          _eqlist = omc_FUnitCheck_GetElementList(threadData, _elts2);

          _functionlist = omc_DAEUtil_getFunctionList(threadData, _func, 0 /* false */);

          _HtCr2U1 = omc_FHashTableCrToUnit_emptyHashTableSized(threadData, omc_Util_nextPrime(threadData, ((modelica_integer)floor(10.0 + (1.4) * (((modelica_real)listLength(_varlist)))))));

          _HtS2U = omc_FUnit_getKnownUnits(threadData);

          _HtU2S = omc_FUnit_getKnownUnitsInverse(threadData);

          _args = _OMC_LIT56;

          _args = omc_List_mapFlat(threadData, _functionlist, boxvar_FUnitCheck_parseFunctionList);

          /* Pattern-matching assignment */
          tmpMeta5 = mmc_mk_box3(0, _HtCr2U1, _HtS2U, _HtU2S);
          tmpMeta6 = omc_List_fold(threadData, _varlist, boxvar_FUnitCheck_convertUnitString2unit__old, tmpMeta5);
          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));
          _HtCr2U1 = tmpMeta7;
          _HtS2U = tmpMeta8;
          _HtU2S = tmpMeta9;

          _HtCr2U2 = omc_BaseHashTable_copy(threadData, _HtCr2U1);

          /* Pattern-matching assignment */
          tmpMeta10 = omc_FUnitCheck_algo(threadData, _varlist, _eqlist, _args, _HtCr2U2, _HtS2U, _HtU2S);
          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));
          _HtCr2U2 = tmpMeta11;
          _HtS2U = tmpMeta12;
          _HtU2S = tmpMeta13;

          _varlist = omc_List_map2(threadData, _varlist, boxvar_FUnitCheck_returnVar, _HtCr2U2, _HtU2S);

          _newdaelist = listAppend(_varlist, _eqlist);

          if(omc_Flags_isSet(threadData, _OMC_LIT42))
          {
            omc_BaseHashTable_dumpHashTable(threadData, _HtCr2U2);

            fputs(MMC_STRINGDATA(_OMC_LIT57),stdout);
          }

          omc_FUnitCheck_notification(threadData, _HtCr2U1, _HtCr2U2, _HtU2S);

          _outDAE = omc_FUnitCheck_updateDAElist(threadData, _inDAE, _newdaelist);
          goto tmp2_done;
        }
        case 1: {
          /* Pattern matching succeeded */
          omc_Error_addInternalError(threadData, _OMC_LIT58, _OMC_LIT59);
          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:;
    }
  }
  ;

  omc_ExecStat_execStat(threadData, _OMC_LIT60);
  _return: OMC_LABEL_UNUSED
  threadData->mmc_jumper = old_mmc_jumper;
  return _outDAE;
}

