#include "omc_simulation_settings.h"
#include "NBEvents.h"
#define _OMC_LIT0_data "sample"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT0,6,_OMC_LIT0_data);
#define _OMC_LIT0 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT0)
#define _OMC_LIT1_data "pre"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT1,3,_OMC_LIT1_data);
#define _OMC_LIT1 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT1)
#define _OMC_LIT2_data "/projects/OpenModelica-session2/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT2,86,_OMC_LIT2_data);
#define _OMC_LIT2 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT2)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT3_6,1.782113391e9);
#define _OMC_LIT3_6 MMC_REFREALLIT(_OMC_LIT_STRUCT3_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT3,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT2,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1155)),MMC_IMMEDIATE(MMC_TAGFIXNUM(12)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1155)),MMC_IMMEDIATE(MMC_TAGFIXNUM(30)),_OMC_LIT3_6}};
#define _OMC_LIT3 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT3)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT4,1,3) {&NFType_INTEGER__desc,}};
#define _OMC_LIT4 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT4)
#define _OMC_LIT5_data "noEvent"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT5,7,_OMC_LIT5_data);
#define _OMC_LIT5 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT5)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT6,1,5) {&ErrorTypes_MessageType_TRANSLATION__desc,}};
#define _OMC_LIT6 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT7,1,4) {&ErrorTypes_Severity_ERROR__desc,}};
#define _OMC_LIT7 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT7)
#define _OMC_LIT8_data "Internal error %s"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT8,17,_OMC_LIT8_data);
#define _OMC_LIT8 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT8)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT9,5,3) {&ErrorTypes_Message_MESSAGE__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(63)),_OMC_LIT6,_OMC_LIT7,_OMC_LIT8}};
#define _OMC_LIT9 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT9)
#define _OMC_LIT10_data "NBEvents.eventsDefault failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT10,30,_OMC_LIT10_data);
#define _OMC_LIT10 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT10)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT11,2,1) {_OMC_LIT10,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT11 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT11)
#define _OMC_LIT12_data " for {"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT12,6,_OMC_LIT12_data);
#define _OMC_LIT12 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT12)
#define _OMC_LIT13_data "}"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT13,1,_OMC_LIT13_data);
#define _OMC_LIT13 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT13)
#define _OMC_LIT14_data "("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT14,1,_OMC_LIT14_data);
#define _OMC_LIT14 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT14)
#define _OMC_LIT15_data ")"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT15,1,_OMC_LIT15_data);
#define _OMC_LIT15 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT15)
#define _OMC_LIT16_data "$TEV"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT16,4,_OMC_LIT16_data);
#define _OMC_LIT16 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT16)
#define _OMC_LIT17_data ") "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT17,2,_OMC_LIT17_data);
#define _OMC_LIT17 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT17)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT18_6,1.782113391e9);
#define _OMC_LIT18_6 MMC_REFREALLIT(_OMC_LIT_STRUCT18_6)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT18,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT2,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(747)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(747)),MMC_IMMEDIATE(MMC_TAGFIXNUM(169)),_OMC_LIT18_6}};
#define _OMC_LIT18 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT18)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT19,1,4) {&NFComponentRef_EMPTY__desc,}};
#define _OMC_LIT19 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT19)
#define _OMC_LIT20_data "$SEV"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT20,4,_OMC_LIT20_data);
#define _OMC_LIT20 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT20)
#define _OMC_LIT21_data "State Events"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT21,12,_OMC_LIT21_data);
#define _OMC_LIT21 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT21)
#define _OMC_LIT22_data "\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT22,1,_OMC_LIT22_data);
#define _OMC_LIT22 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT22)
#define _OMC_LIT23_data "	<No State Events>\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT23,19,_OMC_LIT23_data);
#define _OMC_LIT23 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT23)
#define _OMC_LIT24_data ""
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT24,0,_OMC_LIT24_data);
#define _OMC_LIT24 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT24)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT25,1,4) {&NFType_REAL__desc,}};
#define _OMC_LIT25 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT25)
#define _OMC_LIT26_data "NBEvents.TimeEvent.convert failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT26,34,_OMC_LIT26_data);
#define _OMC_LIT26 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT26)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT27,2,1) {_OMC_LIT26,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT27 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT27)
#define _OMC_LIT28_data "NBEvents.TimeEvent.createSample failed for sample operator: "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT28,60,_OMC_LIT28_data);
#define _OMC_LIT28 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT28)
#define _OMC_LIT29_data "$TMP"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT29,4,_OMC_LIT29_data);
#define _OMC_LIT29 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT29)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT30,1,5) {&NBEquation_Iterator_EMPTY__desc,}};
#define _OMC_LIT30 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT30)
#define _OMC_LIT31_data "time"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT31,4,_OMC_LIT31_data);
#define _OMC_LIT31 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT31)
#define _OMC_LIT32_data "Real"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT32,4,_OMC_LIT32_data);
#define _OMC_LIT32 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT32)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT33,1,3) {&SCode_Visibility_PUBLIC__desc,}};
#define _OMC_LIT33 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT33)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT34,1,4) {&SCode_Redeclare_NOT__REDECLARE__desc,}};
#define _OMC_LIT34 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT34)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT35,1,4) {&SCode_Final_NOT__FINAL__desc,}};
#define _OMC_LIT35 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT35)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT36,1,6) {&Absyn_InnerOuter_NOT__INNER__OUTER__desc,}};
#define _OMC_LIT36 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT36)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT37,1,4) {&SCode_Replaceable_NOT__REPLACEABLE__desc,}};
#define _OMC_LIT37 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT37)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT38,6,3) {&SCode_Prefixes_PREFIXES__desc,_OMC_LIT33,_OMC_LIT34,_OMC_LIT35,_OMC_LIT36,_OMC_LIT37}};
#define _OMC_LIT38 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT38)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT39,1,4) {&SCode_Encapsulated_NOT__ENCAPSULATED__desc,}};
#define _OMC_LIT39 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT39)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT40,1,4) {&SCode_Partial_NOT__PARTIAL__desc,}};
#define _OMC_LIT40 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT40)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT41,1,10) {&SCode_Restriction_R__TYPE__desc,}};
#define _OMC_LIT41 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT41)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT42,9,3) {&SCode_ClassDef_PARTS__desc,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_none)}};
#define _OMC_LIT42 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT42)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT43,3,3) {&SCode_Comment_COMMENT__desc,MMC_REFSTRUCTLIT(mmc_none),MMC_REFSTRUCTLIT(mmc_none)}};
#define _OMC_LIT43 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT43)
static const MMC_DEFREALLIT(_OMC_LIT_STRUCT44,0.0);
#define _OMC_LIT44 MMC_REFREALLIT(_OMC_LIT_STRUCT44)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT45,8,3) {&SourceInfo_SOURCEINFO__desc,_OMC_LIT24,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),_OMC_LIT44}};
#define _OMC_LIT45 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT45)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT46,9,5) {&SCode_Element_CLASS__desc,_OMC_LIT32,_OMC_LIT38,_OMC_LIT39,_OMC_LIT40,_OMC_LIT41,_OMC_LIT42,_OMC_LIT43,_OMC_LIT45}};
#define _OMC_LIT46 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT46)
#define _OMC_LIT47_data "quantity"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT47,8,_OMC_LIT47_data);
#define _OMC_LIT47 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT47)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT48,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT48 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT48)
#define _OMC_LIT49_data "max"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT49,3,_OMC_LIT49_data);
#define _OMC_LIT49 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT49)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT50,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(5))}};
#define _OMC_LIT50 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT50)
#define _OMC_LIT51_data "displayUnit"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT51,11,_OMC_LIT51_data);
#define _OMC_LIT51 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT51)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT52,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(3))}};
#define _OMC_LIT52 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT52)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT53,1,5) {&NFLookupTree_Tree_EMPTY__desc,}};
#define _OMC_LIT53 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT53)
#define _OMC_LIT54_data "fixed"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT54,5,_OMC_LIT54_data);
#define _OMC_LIT54 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT54)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT55,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(7))}};
#define _OMC_LIT55 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT55)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT56,3,4) {&NFLookupTree_Tree_LEAF__desc,_OMC_LIT54,_OMC_LIT55}};
#define _OMC_LIT56 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT56)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT57,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT51,_OMC_LIT52,MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),_OMC_LIT53,_OMC_LIT56}};
#define _OMC_LIT57 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT57)
#define _OMC_LIT58_data "min"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT58,3,_OMC_LIT58_data);
#define _OMC_LIT58 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT58)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT59,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(4))}};
#define _OMC_LIT59 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT59)
#define _OMC_LIT60_data "nominal"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT60,7,_OMC_LIT60_data);
#define _OMC_LIT60 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT60)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT61,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(8))}};
#define _OMC_LIT61 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT61)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT62,3,4) {&NFLookupTree_Tree_LEAF__desc,_OMC_LIT60,_OMC_LIT61}};
#define _OMC_LIT62 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT62)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT63,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT58,_OMC_LIT59,MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),_OMC_LIT53,_OMC_LIT62}};
#define _OMC_LIT63 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT63)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT64,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT49,_OMC_LIT50,MMC_IMMEDIATE(MMC_TAGFIXNUM(3)),_OMC_LIT57,_OMC_LIT63}};
#define _OMC_LIT64 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT64)
#define _OMC_LIT65_data "unbounded"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT65,9,_OMC_LIT65_data);
#define _OMC_LIT65 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT65)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT66,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(9))}};
#define _OMC_LIT66 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT66)
#define _OMC_LIT67_data "start"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT67,5,_OMC_LIT67_data);
#define _OMC_LIT67 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT67)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT68,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(6))}};
#define _OMC_LIT68 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT68)
#define _OMC_LIT69_data "stateSelect"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT69,11,_OMC_LIT69_data);
#define _OMC_LIT69 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT69)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT70,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(10))}};
#define _OMC_LIT70 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT70)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT71,3,4) {&NFLookupTree_Tree_LEAF__desc,_OMC_LIT69,_OMC_LIT70}};
#define _OMC_LIT71 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT71)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT72,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT67,_OMC_LIT68,MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),_OMC_LIT53,_OMC_LIT71}};
#define _OMC_LIT72 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT72)
#define _OMC_LIT73_data "unit"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT73,4,_OMC_LIT73_data);
#define _OMC_LIT73 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT73)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT74,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(2))}};
#define _OMC_LIT74 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT74)
#define _OMC_LIT75_data "uncertain"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT75,9,_OMC_LIT75_data);
#define _OMC_LIT75 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT75)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT76,2,4) {&NFLookupTree_Entry_COMPONENT__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(11))}};
#define _OMC_LIT76 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT76)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT77,3,4) {&NFLookupTree_Tree_LEAF__desc,_OMC_LIT75,_OMC_LIT76}};
#define _OMC_LIT77 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT77)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT78,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT73,_OMC_LIT74,MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),_OMC_LIT77,_OMC_LIT53}};
#define _OMC_LIT78 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT78)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT79,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT65,_OMC_LIT66,MMC_IMMEDIATE(MMC_TAGFIXNUM(3)),_OMC_LIT72,_OMC_LIT78}};
#define _OMC_LIT79 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT79)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT80,6,3) {&NFLookupTree_Tree_NODE__desc,_OMC_LIT47,_OMC_LIT48,MMC_IMMEDIATE(MMC_TAGFIXNUM(4)),_OMC_LIT64,_OMC_LIT79}};
#define _OMC_LIT80 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT80)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT81,1,5) {&NFType_STRING__desc,}};
#define _OMC_LIT81 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT81)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT82,1,5) {&NFModifier_Modifier_NOMOD__desc,}};
#define _OMC_LIT82 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT82)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT83,3,7) {&NFComponent_TYPE__ATTRIBUTE__desc,_OMC_LIT81,_OMC_LIT82}};
#define _OMC_LIT83 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT83)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT84,1,1) {_OMC_LIT83}};
#define _OMC_LIT84 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT84)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT85,1,11) {&NFInstNode_InstNode_EMPTY__NODE__desc,}};
#define _OMC_LIT85 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT85)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT86,1,9) {&NFInstNode_InstNodeType_NORMAL__COMP__desc,}};
#define _OMC_LIT86 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT86)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT87,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT47,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT84,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT87 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT87)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT88,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT73,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT84,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT88 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT88)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT89,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT51,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT84,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT89 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT89)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT90,3,7) {&NFComponent_TYPE__ATTRIBUTE__desc,_OMC_LIT25,_OMC_LIT82}};
#define _OMC_LIT90 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT90)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT91,1,1) {_OMC_LIT90}};
#define _OMC_LIT91 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT91)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT92,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT58,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT91,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT92 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT92)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT93,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT49,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT91,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT93 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT93)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT94,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT67,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT91,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT94 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT94)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT95,1,6) {&NFType_BOOLEAN__desc,}};
#define _OMC_LIT95 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT95)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT96,3,7) {&NFComponent_TYPE__ATTRIBUTE__desc,_OMC_LIT95,_OMC_LIT82}};
#define _OMC_LIT96 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT96)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT97,1,1) {_OMC_LIT96}};
#define _OMC_LIT97 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT97)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT98,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT54,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT97,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT98 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT98)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT99,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT60,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT91,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT99 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT99)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT100,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT65,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT97,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT100 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT100)
#define _OMC_LIT101_data "StateSelect"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT101,11,_OMC_LIT101_data);
#define _OMC_LIT101 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT101)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT102,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT101}};
#define _OMC_LIT102 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT102)
#define _OMC_LIT103_data "never"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT103,5,_OMC_LIT103_data);
#define _OMC_LIT103 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT103)
#define _OMC_LIT104_data "avoid"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT104,5,_OMC_LIT104_data);
#define _OMC_LIT104 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT104)
#define _OMC_LIT105_data "default"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT105,7,_OMC_LIT105_data);
#define _OMC_LIT105 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT105)
#define _OMC_LIT106_data "prefer"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT106,6,_OMC_LIT106_data);
#define _OMC_LIT106 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT106)
#define _OMC_LIT107_data "always"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT107,6,_OMC_LIT107_data);
#define _OMC_LIT107 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT107)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT108,2,1) {_OMC_LIT107,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT108 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT108)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT109,2,1) {_OMC_LIT106,_OMC_LIT108}};
#define _OMC_LIT109 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT109)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT110,2,1) {_OMC_LIT105,_OMC_LIT109}};
#define _OMC_LIT110 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT110)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT111,2,1) {_OMC_LIT104,_OMC_LIT110}};
#define _OMC_LIT111 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT111)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT112,2,1) {_OMC_LIT103,_OMC_LIT111}};
#define _OMC_LIT112 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT112)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT113,3,8) {&NFType_ENUMERATION__desc,_OMC_LIT102,_OMC_LIT112}};
#define _OMC_LIT113 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT113)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT114,3,7) {&NFComponent_TYPE__ATTRIBUTE__desc,_OMC_LIT113,_OMC_LIT82}};
#define _OMC_LIT114 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT114)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT115,1,1) {_OMC_LIT114}};
#define _OMC_LIT115 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT115)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT116,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT69,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT115,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT116 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT116)
#define _OMC_LIT117_data "Uncertainty"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT117,11,_OMC_LIT117_data);
#define _OMC_LIT117 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT117)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT118,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT117}};
#define _OMC_LIT118 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT118)
#define _OMC_LIT119_data "given"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT119,5,_OMC_LIT119_data);
#define _OMC_LIT119 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT119)
#define _OMC_LIT120_data "sought"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT120,6,_OMC_LIT120_data);
#define _OMC_LIT120 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT120)
#define _OMC_LIT121_data "refine"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT121,6,_OMC_LIT121_data);
#define _OMC_LIT121 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT121)
#define _OMC_LIT122_data "propagate"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT122,9,_OMC_LIT122_data);
#define _OMC_LIT122 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT122)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT123,2,1) {_OMC_LIT122,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT123 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT123)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT124,2,1) {_OMC_LIT121,_OMC_LIT123}};
#define _OMC_LIT124 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT124)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT125,2,1) {_OMC_LIT120,_OMC_LIT124}};
#define _OMC_LIT125 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT125)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT126,2,1) {_OMC_LIT119,_OMC_LIT125}};
#define _OMC_LIT126 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT126)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT127,3,8) {&NFType_ENUMERATION__desc,_OMC_LIT118,_OMC_LIT126}};
#define _OMC_LIT127 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT127)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT128,3,7) {&NFComponent_TYPE__ATTRIBUTE__desc,_OMC_LIT127,_OMC_LIT82}};
#define _OMC_LIT128 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT128)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT129,1,1) {_OMC_LIT128}};
#define _OMC_LIT129 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT129)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT130,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT75,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT129,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT130 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT130)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT131,2,1) {_OMC_LIT130,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT131 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT131)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT132,2,1) {_OMC_LIT116,_OMC_LIT131}};
#define _OMC_LIT132 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT132)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT133,2,1) {_OMC_LIT100,_OMC_LIT132}};
#define _OMC_LIT133 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT133)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT134,2,1) {_OMC_LIT99,_OMC_LIT133}};
#define _OMC_LIT134 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT134)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT135,2,1) {_OMC_LIT98,_OMC_LIT134}};
#define _OMC_LIT135 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT135)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT136,2,1) {_OMC_LIT94,_OMC_LIT135}};
#define _OMC_LIT136 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT136)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT137,2,1) {_OMC_LIT93,_OMC_LIT136}};
#define _OMC_LIT137 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT137)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT138,2,1) {_OMC_LIT92,_OMC_LIT137}};
#define _OMC_LIT138 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT138)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT139,2,1) {_OMC_LIT89,_OMC_LIT138}};
#define _OMC_LIT139 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT139)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT140,2,1) {_OMC_LIT88,_OMC_LIT139}};
#define _OMC_LIT140 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT140)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT141,2,1) {_OMC_LIT87,_OMC_LIT140}};
#define _OMC_LIT141 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT141)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT142,11,MMC_ARRAY_TAG) {_OMC_LIT87,_OMC_LIT88,_OMC_LIT89,_OMC_LIT92,_OMC_LIT93,_OMC_LIT94,_OMC_LIT98,_OMC_LIT99,_OMC_LIT100,_OMC_LIT116,_OMC_LIT130}};
#define _OMC_LIT142 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT142)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT143,1,5) {&NFDuplicateTree_Tree_EMPTY__desc,}};
#define _OMC_LIT143 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT143)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT144,6,3) {&NFClass_Prefixes_PREFIXES__desc,_OMC_LIT39,_OMC_LIT40,_OMC_LIT35,_OMC_LIT36,_OMC_LIT37}};
#define _OMC_LIT144 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT144)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT145,1,15) {&NFRestriction_TYPE__desc,}};
#define _OMC_LIT145 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT145)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT146,4,5) {&NFInstNode_CachedData_FUNCTION__desc,MMC_REFSTRUCTLIT(mmc_nil),MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1 /* true */))}};
#define _OMC_LIT146 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT146)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT147,2,1) {_OMC_LIT146,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT147 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT147)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT148,1,MMC_ARRAY_TAG) {_OMC_LIT146}};
#define _OMC_LIT148 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT148)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT149,1,6) {&NFInstNode_InstNodeType_BUILTIN__CLASS__desc,}};
#define _OMC_LIT149 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT149)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT150,1,3) {&NFBinding_UNBOUND__desc,}};
#define _OMC_LIT150 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT150)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT151,1,4) {&NFPrefixes_Replaceable_NOT__REPLACEABLE__desc,}};
#define _OMC_LIT151 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT151)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT152,10,3) {&NFAttributes_ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT151,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT152 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT152)
#define _OMC_LIT153_data "OMC_NO_CLOCK"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT153,12,_OMC_LIT153_data);
#define _OMC_LIT153 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT153)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT154,2,4) {&Absyn_Path_IDENT__desc,_OMC_LIT0}};
#define _OMC_LIT154 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT154)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT155,3,3) {&Absyn_Path_QUALIFIED__desc,_OMC_LIT153,_OMC_LIT154}};
#define _OMC_LIT155 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT155)
#define _OMC_LIT156_data "r"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT156,1,_OMC_LIT156_data);
#define _OMC_LIT156 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT156)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT157,10,3) {&NFAttributes_ATTRIBUTES__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(7)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT151,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT157 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT157)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT158,9,4) {&NFComponent_COMPONENT__desc,_OMC_LIT85,_OMC_LIT25,_OMC_LIT150,_OMC_LIT150,_OMC_LIT157,_OMC_LIT43,MMC_IMMEDIATE(MMC_TAGFIXNUM(4)),_OMC_LIT45}};
#define _OMC_LIT158 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT158)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT159,1,1) {_OMC_LIT158}};
#define _OMC_LIT159 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT159)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT160,7,4) {&NFInstNode_InstNode_COMPONENT__NODE__desc,_OMC_LIT156,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(1)),_OMC_LIT159,_OMC_LIT85,_OMC_LIT86}};
#define _OMC_LIT160 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT160)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT161,2,1) {_OMC_LIT160,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT161 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT161)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT162,2,1) {_OMC_LIT160,_OMC_LIT161}};
#define _OMC_LIT162 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT162)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT163,1,7) {&DAE_InlineType_NO__INLINE__desc,}};
#define _OMC_LIT163 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT163)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT164,3,4) {&DAE_FunctionBuiltin_FUNCTION__BUILTIN__desc,MMC_REFSTRUCTLIT(mmc_none),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT164 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT164)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT165,1,3) {&DAE_FunctionParallelism_FP__NON__PARALLEL__desc,}};
#define _OMC_LIT165 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT165)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT166,8,3) {&DAE_FunctionAttributes_FUNCTION__ATTRIBUTES__desc,_OMC_LIT163,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),MMC_IMMEDIATE(MMC_TAGFIXNUM(2)),MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT164,_OMC_LIT165,MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT166 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT166)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT167,1,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(1))}};
#define _OMC_LIT167 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT167)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT168,1,1) {MMC_IMMEDIATE(MMC_TAGFIXNUM(0))}};
#define _OMC_LIT168 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT168)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT169,2,6) {&NFExpression_BOOLEAN__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */))}};
#define _OMC_LIT169 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT169)
#define _OMC_LIT170_data "Time Events"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT170,11,_OMC_LIT170_data);
#define _OMC_LIT170 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT170)
#define _OMC_LIT171_data "	<No Time Events>\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT171,18,_OMC_LIT171_data);
#define _OMC_LIT171 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT171)
#define _OMC_LIT172_data "time > "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT172,7,_OMC_LIT172_data);
#define _OMC_LIT172 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT172)
#define _OMC_LIT173_data "sample("
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT173,7,_OMC_LIT173_data);
#define _OMC_LIT173 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT173)
#define _OMC_LIT174_data ", "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT174,2,_OMC_LIT174_data);
#define _OMC_LIT174 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT174)
#define _OMC_LIT175_data "NBEvents.TimeEvent.toString failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT175,35,_OMC_LIT175_data);
#define _OMC_LIT175 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT175)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT176,2,1) {_OMC_LIT175,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT176 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT176)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT177,1,4) {&DAE_ComponentPrefix_NOCOMPPRE__desc,}};
#define _OMC_LIT177 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT177)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT178,8,3) {&DAE_ElementSource_SOURCE__desc,_OMC_LIT45,MMC_REFSTRUCTLIT(mmc_nil),_OMC_LIT177,MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil),MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT178 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT178)
#define _OMC_LIT179_data "EVT"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT179,3,_OMC_LIT179_data);
#define _OMC_LIT179 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT179)
#define _OMC_LIT180_data "  "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT180,2,_OMC_LIT180_data);
#define _OMC_LIT180 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT180)
#define _OMC_LIT181_data "Event Equations"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT181,15,_OMC_LIT181_data);
#define _OMC_LIT181 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT181)
#define _OMC_LIT182_data "\n\n"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT182,2,_OMC_LIT182_data);
#define _OMC_LIT182 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT182)
#define _OMC_LIT183_data "dumpEvents"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT183,10,_OMC_LIT183_data);
#define _OMC_LIT183 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT183)
#define _OMC_LIT184_data "Dumps information about the detected event functions."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT184,53,_OMC_LIT184_data);
#define _OMC_LIT184 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT184)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT185,5,3) {&Flags_DebugFlag_DEBUG__FLAG__desc,MMC_IMMEDIATE(MMC_TAGFIXNUM(193)),_OMC_LIT183,MMC_IMMEDIATE(MMC_TAGFIXNUM(0 /* false */)),_OMC_LIT184}};
#define _OMC_LIT185 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT185)
#define _OMC_LIT186_data " = "
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT186,3,_OMC_LIT186_data);
#define _OMC_LIT186 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT186)
#define _OMC_LIT187_data "Event Info"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT187,10,_OMC_LIT187_data);
#define _OMC_LIT187 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT187)
#define _OMC_LIT188_data "Composite Events"
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT188,16,_OMC_LIT188_data);
#define _OMC_LIT188 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT188)
#define _OMC_LIT189_data "NBEvents.main failed."
static const MMC_DEFSTRINGLIT(_OMC_LIT_STRUCT189,21,_OMC_LIT189_data);
#define _OMC_LIT189 MMC_REFSTRINGLIT(_OMC_LIT_STRUCT189)
static const MMC_DEFSTRUCTLIT(_OMC_LIT_STRUCT190,2,1) {_OMC_LIT189,MMC_REFSTRUCTLIT(mmc_nil)}};
#define _OMC_LIT190 MMC_REFSTRUCTLIT(_OMC_LIT_STRUCT190)
#include "util/modelica.h"

#include "NBEvents_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_NBEvents_containsTimeTraverseCref(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcref, modelica_metatype _b);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_containsTimeTraverseCref,2,0) {(void*) boxptr_NBEvents_containsTimeTraverseCref,0}};
#define boxvar_NBEvents_containsTimeTraverseCref MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_containsTimeTraverseCref)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_containsTimeTraverseExp(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _b);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_containsTimeTraverseExp,2,0) {(void*) boxptr_NBEvents_containsTimeTraverseExp,0}};
#define boxvar_NBEvents_containsTimeTraverseExp MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_containsTimeTraverseExp)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEventsCondition(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_boolean _createEqn, modelica_metatype *out_bucket);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_NBEvents_collectEventsCondition(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype _createEqn, modelica_metatype *out_bucket);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_collectEventsCondition,2,0) {(void*) boxptr_NBEvents_collectEventsCondition,0}};
#define boxvar_NBEvents_collectEventsCondition MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_collectEventsCondition)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEventsTraverse(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _bucket_ptr, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_boolean _createEqn);
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_NBEvents_collectEventsTraverse(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _bucket_ptr, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype _createEqn);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_collectEventsTraverse,2,0) {(void*) boxptr_NBEvents_collectEventsTraverse,0}};
#define boxvar_NBEvents_collectEventsTraverse MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_collectEventsTraverse)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEvents(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqn_5Fptr, modelica_metatype _bucket_ptr, modelica_metatype _variables, modelica_metatype _funcMap);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_collectEvents,2,0) {(void*) boxptr_NBEvents_collectEvents,0}};
#define boxvar_NBEvents_collectEvents MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_collectEvents)
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_eventsDefault(threadData_t *threadData, modelica_metatype __omcQ_24in_5FvarData, modelica_metatype __omcQ_24in_5FeqData, modelica_metatype __omcQ_24in_5FeventInfo, modelica_metatype _funcMap, modelica_metatype *out_eqData, modelica_metatype *out_eventInfo);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_eventsDefault,2,0) {(void*) boxptr_NBEvents_eventsDefault,0}};
#define boxvar_NBEvents_eventsDefault MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_eventsDefault)
PROTECTED_FUNCTION_STATIC modelica_string omc_NBEvents_EventInfo_toString_tplString(threadData_t *threadData, modelica_metatype _tpl, modelica_fnptr _f1, modelica_fnptr _f2);
static const MMC_DEFSTRUCTLIT(boxvar_lit_NBEvents_EventInfo_toString_tplString,2,0) {(void*) boxptr_NBEvents_EventInfo_toString_tplString,0}};
#define boxvar_NBEvents_EventInfo_toString_tplString MMC_REFSTRUCTLIT(boxvar_lit_NBEvents_EventInfo_toString_tplString)

PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_containsTimeTraverseCref(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcref, modelica_metatype _b)
{
  modelica_metatype _cref = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _cref = __omcQ_24in_5Fcref;
  if(((!mmc_unbox_boolean(omc_Pointer_access(threadData, _b))) && omc_NFComponentRef_isTime(threadData, _cref)))
  {
    omc_Pointer_update(threadData, _b, mmc_mk_boolean(1 /* true */));
  }
  _return: OMC_LABEL_UNUSED
  return _cref;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_containsTimeTraverseExp(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _b)
{
  modelica_metatype _exp = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  if(((!mmc_unbox_boolean(omc_Pointer_access(threadData, _b))) && omc_NFExpression_isTime(threadData, _exp)))
  {
    omc_Pointer_update(threadData, _b, mmc_mk_boolean(1 /* true */));
  }
  _return: OMC_LABEL_UNUSED
  return _exp;
}

PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEventsCondition(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_boolean _createEqn, modelica_metatype *out_bucket)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  _failed = 1 /* true */;
  if(omc_NBBackendUtil_isOnlyTimeDependent(threadData, _exp))
  {
    _exp = omc_NBEvents_TimeEvent_create(threadData, _exp, _bucket, _iter, _eqn, _funcMap, _createEqn ,&_bucket ,&_failed);
  }
  else
  {
    _exp = omc_NBEvents_CompositeEvent_create(threadData, _exp, _bucket, _iter, _createEqn ,&_bucket ,&_failed);
  }

  if(_failed)
  {
    _exp = omc_NBEvents_StateEvent_create(threadData, _exp, _bucket, _iter, _eqn, _createEqn ,&_bucket);
  }
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  return _exp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_NBEvents_collectEventsCondition(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype _createEqn, modelica_metatype *out_bucket)
{
  modelica_integer tmp1;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_collectEventsCondition(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, _eqn, _funcMap, tmp1, out_bucket);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  return _exp;
}

static modelica_metatype closure0_NBEvents_collectEventsTraverse(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype iter = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype eqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype createEqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_NBEvents_collectEventsTraverse(thData, $in_exp, bucket_ptr, iter, eqn, funcMap, createEqn);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEventsTraverse(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _bucket_ptr, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_boolean _createEqn)
{
  modelica_metatype _exp = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _bucket = NULL;
      modelica_metatype _clk = NULL;
      modelica_metatype _condition = NULL;
      modelica_metatype _call = NULL;
      modelica_metatype _new_frames = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _bucket has no default value.
      // _clk has no default value.
      // _condition has no default value.
      // _call has no default value.
      // _new_frames has no default value.
      tmp4 = 0;
      for (; tmp4 < 11; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,19,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _exp = omc_NBEvents_collectEventsCondition(threadData, _exp, omc_Pointer_access(threadData, _bucket_ptr), _iter, _eqn, _funcMap, _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _exp = omc_NBEvents_collectEventsCondition(threadData, _exp, omc_Pointer_access(threadData, _bucket_ptr), _iter, _eqn, _funcMap, _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 2: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,20,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _exp = omc_NBEvents_collectEventsCondition(threadData, _exp, omc_Pointer_access(threadData, _bucket_ptr), _iter, _eqn, _funcMap, _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 3: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NFCall_isNamed(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _OMC_LIT0)) goto tmp3_end;
          _exp = omc_NBEvents_collectEventsCondition(threadData, _exp, omc_Pointer_access(threadData, _bucket_ptr), _iter, _eqn, _funcMap, _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,5,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,3,2) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          
          _clk = tmpMeta6;
          _condition = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(4));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_clk), 4*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[2] = omc_NBEvents_collectEventsTraverse(threadData, _condition, _bucket_ptr, _iter, _eqn, _funcMap, _createEqn);
          _clk = tmpMeta8;

          tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(3));
          memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_exp), 3*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[2] = _clk;
          _exp = tmpMeta9;
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 5: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta10,2,6) == 0) goto tmp3_end;
          tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta10), 6));
          if (listEmpty(tmpMeta11)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta12,6,2) == 0) goto tmp3_end;
          if (!listEmpty(tmpMeta13)) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NFCall_isNamed(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _OMC_LIT1)) goto tmp3_end;
          _exp = omc_NBEvents_CompositeEvent_add(threadData, _exp, _iter, omc_Pointer_access(threadData, _bucket_ptr), _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 6: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NBVariable_isPrevious(threadData, omc_NBVariable_getVarPointer(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3))), _OMC_LIT3))) goto tmp3_end;
          _exp = omc_NBEvents_CompositeEvent_add(threadData, _exp, _iter, omc_Pointer_access(threadData, _bucket_ptr), _createEqn ,&_bucket);

          omc_Pointer_update(threadData, _bucket_ptr, _bucket);
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 7: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,6,8) == 0) goto tmp3_end;
          
          _call = tmpMeta14;
          /* Pattern matching succeeded */
          {
            modelica_metatype __omcQ_24tmpVar1;
            modelica_metatype* tmp16;
            modelica_metatype tmpMeta17;
            modelica_metatype tmpMeta18;
            modelica_metatype tmpMeta19;
            modelica_metatype __omcQ_24tmpVar0;
            modelica_integer tmp20;
            modelica_metatype _tpl_loopVar = 0;
            modelica_metatype _tpl;
            _tpl_loopVar = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 7)));
            tmpMeta17 = MMC_REFSTRUCTLIT(mmc_nil);
            __omcQ_24tmpVar1 = tmpMeta17; /* defaultValue */
            tmp16 = &__omcQ_24tmpVar1;
            while(1) {
              tmp20 = 1;
              if (!listEmpty(_tpl_loopVar)) {
                _tpl = MMC_CAR(_tpl_loopVar);
                _tpl_loopVar = MMC_CDR(_tpl_loopVar);
                tmp20--;
              }
              if (tmp20 == 0) {
                tmpMeta18 = MMC_REFSTRUCTLIT(mmc_nil);
                tmpMeta19 = mmc_mk_box3(0, omc_NFComponentRef_fromNode(threadData, omc_Util_tuple21(threadData, _tpl), _OMC_LIT4, tmpMeta18, 1), omc_Util_tuple22(threadData, _tpl), mmc_mk_none());
                __omcQ_24tmpVar0 = tmpMeta19;
                *tmp16 = mmc_mk_cons(__omcQ_24tmpVar0,0);
                tmp16 = &MMC_CDR(*tmp16);
              } else if (tmp20 == 1) {
                break;
              } else {
                goto goto_2;
              }
            }
            *tmp16 = mmc_mk_nil();
            tmpMeta15 = __omcQ_24tmpVar1;
          }
          _new_frames = tmpMeta15;

          tmpMeta21 = MMC_TAGPTR(mmc_alloc_words(10));
          memcpy(MMC_UNTAGPTR(tmpMeta21), MMC_UNTAGPTR(_call), 10*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta21))[6] = omc_NBEvents_collectEventsTraverse(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_call), 6))), _bucket_ptr, omc_NBEquation_Iterator_addFrames(threadData, _iter, _new_frames), _eqn, _funcMap, _createEqn);
          _call = tmpMeta21;

          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(3));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_exp), 3*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[2] = _call;
          _exp = tmpMeta22;
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 8: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NFCall_isNamed(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _OMC_LIT5)) goto tmp3_end;
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 9: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,6,2) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 10: {
          modelica_metatype tmpMeta23;
          
          /* Pattern matching succeeded */
          tmpMeta23 = mmc_mk_box5(0, _bucket_ptr, _iter, _eqn, _funcMap, mmc_mk_boolean(_createEqn));
          tmpMeta1 = omc_NFExpression_mapShallow(threadData, _exp, (modelica_fnptr) mmc_mk_box2(0,closure0_NBEvents_collectEventsTraverse,tmpMeta23));
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _exp;
}
PROTECTED_FUNCTION_STATIC modelica_metatype boxptr_NBEvents_collectEventsTraverse(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype _bucket_ptr, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype _createEqn)
{
  modelica_integer tmp1;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_collectEventsTraverse(threadData, __omcQ_24in_5Fexp, _bucket_ptr, _iter, _eqn, _funcMap, tmp1);
  /* skip box _exp; NFExpression */
  return _exp;
}

static modelica_metatype closure1_NBEvents_collectEventsTraverse(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype iter = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype eqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype createEqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_NBEvents_collectEventsTraverse(thData, $in_exp, bucket_ptr, iter, eqn, funcMap, createEqn);
}static modelica_metatype closure2_NBEvents_collectEvents(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_eqn_ptr)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  return boxptr_NBEvents_collectEvents(thData, $in_eqn_ptr, bucket_ptr, variables, funcMap);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_collectEvents(threadData_t *threadData, modelica_metatype __omcQ_24in_5Feqn_5Fptr, modelica_metatype _bucket_ptr, modelica_metatype _variables, modelica_metatype _funcMap)
{
  modelica_metatype _eqn_ptr = NULL;
  modelica_metatype _eqn = NULL;
  modelica_metatype _body_eqn = NULL;
  modelica_metatype _iter = NULL;
  modelica_boolean _createEqn;
  modelica_fnptr _collector;
  modelica_metatype _alg = NULL;
  modelica_metatype _new_stmts = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _eqn_ptr = __omcQ_24in_5Feqn_5Fptr;
  _eqn = omc_Pointer_access(threadData, _eqn_ptr);
  // _body_eqn has no default value.
  // _iter has no default value.
  _createEqn = (!omc_NBEquation_Equation_isAlgorithm(threadData, _eqn_ptr));
  // _alg has no default value.
  // _new_stmts has no default value.
  _iter = omc_NBEquation_Equation_getForIterator(threadData, _eqn);

  tmpMeta1 = mmc_mk_box5(0, _bucket_ptr, _iter, _eqn_ptr, _funcMap, mmc_mk_boolean(_createEqn));
  _collector = (modelica_fnptr) (modelica_fnptr) mmc_mk_box2(0,closure1_NBEvents_collectEventsTraverse,tmpMeta1);

  { /* match expression */
    modelica_metatype tmp5_1;
    tmp5_1 = _eqn;
    {
      volatile mmc_switch_type tmp5;
      int tmp6;
      tmp5 = 0;
      for (; tmp5 < 5; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,3,5) == 0) goto tmp4_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 3));
          
          _alg = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _new_stmts = tmpMeta8;

          {
            modelica_metatype _stmt;
            for (tmpMeta9 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_alg), 2))); !listEmpty(tmpMeta9); tmpMeta9=MMC_CDR(tmpMeta9))
            {
              _stmt = MMC_CAR(tmpMeta9);
              tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
              _stmt = omc_NBEvents_StateEvent_fromStatement(threadData, _stmt, _bucket_ptr, _eqn_ptr, _variables, _funcMap, tmpMeta10);

              _new_stmts = omc_NBEvents_EventInfo_createAuxStatements(threadData, _new_stmts, _bucket_ptr, _variables);

              tmpMeta11 = mmc_mk_cons(_stmt, _new_stmts);
              _new_stmts = tmpMeta11;
            }
          }

          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(8));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_alg), 8*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[2] = listReverse(_new_stmts);
          _alg = tmpMeta13;

          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[3] = omc_NFAlgorithm_setInputsOutputs(threadData, _alg);
          _eqn = tmpMeta14;

          {
            modelica_integer __omcQ_24tmpVar3;
            modelica_integer __omcQ_24tmpVar2;
            modelica_integer tmp17;
            modelica_metatype _out_loopVar = 0;
            modelica_metatype _out;
            _out_loopVar = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3)))), 4)));
            __omcQ_24tmpVar3 = ((modelica_integer) 0); /* defaultValue */
            while(1) {
              tmp17 = 1;
              if (!listEmpty(_out_loopVar)) {
                _out = MMC_CAR(_out_loopVar);
                _out_loopVar = MMC_CDR(_out_loopVar);
                tmp17--;
              }
              if (tmp17 == 0) {
                __omcQ_24tmpVar2 = omc_NFComponentRef_size(threadData, _out, 1 /* true */, 0 /* false */);
                __omcQ_24tmpVar3 = __omcQ_24tmpVar3 + __omcQ_24tmpVar2;
              } else if (tmp17 == 1) {
                break;
              } else {
                goto goto_3;
              }
            }
            tmp16 = __omcQ_24tmpVar3;
          }
          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[2] = mmc_mk_integer(tmp16);
          _eqn = tmpMeta15;
          tmpMeta2 = _eqn;
          goto tmp4_done;
        }
        case 1: {
          modelica_metatype tmpMeta18;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,6,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta18 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta18), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta18))[3] = omc_NBEquation_WhenEquationBody_mapCondition(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), ((modelica_fnptr) _collector), mmc_mk_none(), boxvar_NFExpression_fakeMap);
          _eqn = tmpMeta18;
          tmpMeta2 = _eqn;
          goto tmp4_done;
        }
        case 2: {
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_metatype tmpMeta24;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,5,5) == 0) goto tmp4_end;
          tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp5_1), 4));
          if (listEmpty(tmpMeta19)) goto tmp4_end;
          tmpMeta20 = MMC_CAR(tmpMeta19);
          tmpMeta21 = MMC_CDR(tmpMeta19);
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta20,6,4) == 0) goto tmp4_end;
          if (!listEmpty(tmpMeta21)) goto tmp4_end;
          
          _body_eqn = tmpMeta20;
          /* Pattern matching succeeded */
          tmpMeta22 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta22), MMC_UNTAGPTR(_body_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta22))[3] = omc_NBEquation_WhenEquationBody_mapCondition(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_body_eqn), 3))), ((modelica_fnptr) _collector), mmc_mk_none(), boxvar_NFExpression_fakeMap);
          _body_eqn = tmpMeta22;

          tmpMeta24 = mmc_mk_cons(_body_eqn, MMC_REFSTRUCTLIT(mmc_nil));
          tmpMeta23 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta23), MMC_UNTAGPTR(_eqn), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta23))[4] = tmpMeta24;
          _eqn = tmpMeta23;
          tmpMeta2 = _eqn;
          goto tmp4_done;
        }
        case 3: {
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,4,4) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          tmpMeta26 = mmc_mk_box3(0, _bucket_ptr, _variables, _funcMap);
          tmpMeta25 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta25), MMC_UNTAGPTR(_eqn), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta25))[3] = omc_NBEquation_IfEquationBody_mapEqnExpCref(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqn), 3))), (modelica_fnptr) mmc_mk_box2(0,closure2_NBEvents_collectEvents,tmpMeta26), ((modelica_fnptr) _collector), mmc_mk_none(), boxvar_NFExpression_mapReverse);
          _eqn = tmpMeta25;
          tmpMeta2 = _eqn;
          goto tmp4_done;
        }
        case 4: {
          
          /* Pattern matching succeeded */
          tmpMeta2 = omc_NBEquation_Equation_map(threadData, _eqn, ((modelica_fnptr) _collector), mmc_mk_none(), boxvar_NFExpression_fakeMap);
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  _eqn = tmpMeta2;

  if((!referenceEq(_eqn, omc_Pointer_access(threadData, _eqn_ptr))))
  {
    omc_Pointer_update(threadData, _eqn_ptr, _eqn);
  }
  _return: OMC_LABEL_UNUSED
  return _eqn_ptr;
}

static modelica_metatype closure3_NBEvents_collectEvents(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_eqn_ptr)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  return boxptr_NBEvents_collectEvents(thData, $in_eqn_ptr, bucket_ptr, variables, funcMap);
}static modelica_metatype closure4_NBEvents_collectEvents(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_eqn_ptr)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  return boxptr_NBEvents_collectEvents(thData, $in_eqn_ptr, bucket_ptr, variables, funcMap);
}static modelica_metatype closure5_NBEvents_collectEvents(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_eqn_ptr)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  return boxptr_NBEvents_collectEvents(thData, $in_eqn_ptr, bucket_ptr, variables, funcMap);
}
PROTECTED_FUNCTION_STATIC modelica_metatype omc_NBEvents_eventsDefault(threadData_t *threadData, modelica_metatype __omcQ_24in_5FvarData, modelica_metatype __omcQ_24in_5FeqData, modelica_metatype __omcQ_24in_5FeventInfo, modelica_metatype _funcMap, modelica_metatype *out_eqData, modelica_metatype *out_eventInfo)
{
  modelica_metatype _varData = NULL;
  modelica_metatype _eqData = NULL;
  modelica_metatype _eventInfo = NULL;
  modelica_metatype _bucket = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _bucket_ptr = NULL;
  modelica_metatype _auxiliary_vars = NULL;
  modelica_metatype _auxiliary_eqns = NULL;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _varData = __omcQ_24in_5FvarData;
  _eqData = __omcQ_24in_5FeqData;
  _eventInfo = __omcQ_24in_5FeventInfo;
  tmpMeta1 = mmc_mk_box6(3, &NBEvents_Bucket_BUCKET__desc, omc_UnorderedSet_new(threadData, boxvar_NBEvents_TimeEvent_hash, boxvar_NBEvents_TimeEvent_isEqual, ((modelica_integer) 13)), omc_UnorderedMap_new(threadData, boxvar_NBEvents_Condition_hash, boxvar_NBEvents_Condition_isEqual, ((modelica_integer) 1)), omc_UnorderedMap_new(threadData, boxvar_NBEvents_Condition_hash, boxvar_NBEvents_Condition_isEqual, ((modelica_integer) 1)), mmc_mk_none(), mmc_mk_integer(((modelica_integer) 1)));
  _bucket = tmpMeta1;
  // _bucket_ptr has no default value.
  // _auxiliary_vars has no default value.
  // _auxiliary_eqns has no default value.
  { /* match expression */
    modelica_metatype tmp5_1;modelica_metatype tmp5_2;
    tmp5_1 = _varData;
    tmp5_2 = _eqData;
    {
      volatile mmc_switch_type tmp5;
      int tmp6;
      tmp5 = 0;
      for (; tmp5 < 2; 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;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,0,24) == 0) goto tmp4_end;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_2,0,9) == 0) goto tmp4_end;
          
          /* Pattern matching succeeded */
          _bucket_ptr = omc_Pointer_create(threadData, _bucket);

          tmpMeta7 = mmc_mk_box3(0, _bucket_ptr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 3))), _funcMap);
          omc_NBEquation_EquationPointers_mapPtr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 4))), (modelica_fnptr) mmc_mk_box2(0,closure3_NBEvents_collectEvents,tmpMeta7));

          tmpMeta8 = mmc_mk_box3(0, _bucket_ptr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 3))), _funcMap);
          omc_NBEquation_EquationPointers_mapPtr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 6))), (modelica_fnptr) mmc_mk_box2(0,closure4_NBEvents_collectEvents,tmpMeta8));

          tmpMeta9 = mmc_mk_box3(0, _bucket_ptr, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 3))), _funcMap);
          omc_NBEquation_EquationPointers_mapPtr(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 10))), (modelica_fnptr) mmc_mk_box2(0,closure5_NBEvents_collectEvents,tmpMeta9));

          _bucket = omc_Pointer_access(threadData, _bucket_ptr);

          _eventInfo = omc_NBEvents_EventInfo_create(threadData, _bucket, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 2))) ,&_auxiliary_vars ,&_auxiliary_eqns);

          tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(26));
          memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_varData), 26*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[3] = omc_NBVariable_VariablePointers_addList(threadData, _auxiliary_vars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 3))));
          _varData = tmpMeta10;

          tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(26));
          memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_varData), 26*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[4] = omc_NBVariable_VariablePointers_addList(threadData, _auxiliary_vars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 4))));
          _varData = tmpMeta11;

          tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(26));
          memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_varData), 26*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[6] = omc_NBVariable_VariablePointers_addList(threadData, _auxiliary_vars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 6))));
          _varData = tmpMeta12;

          tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(26));
          memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_varData), 26*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[12] = omc_NBVariable_VariablePointers_addList(threadData, _auxiliary_vars, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_varData), 12))));
          _varData = tmpMeta13;

          tmpMeta14 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta14), MMC_UNTAGPTR(_eqData), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta14))[3] = omc_NBEquation_EquationPointers_addList(threadData, _auxiliary_eqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 3))));
          _eqData = tmpMeta14;

          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_eqData), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[4] = omc_NBEquation_EquationPointers_addList(threadData, _auxiliary_eqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 4))));
          _eqData = tmpMeta15;

          tmpMeta16 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta16), MMC_UNTAGPTR(_eqData), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta16))[8] = omc_NBEquation_EquationPointers_addList(threadData, _auxiliary_eqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 8))));
          _eqData = tmpMeta16;

          tmpMeta17 = MMC_TAGPTR(mmc_alloc_words(11));
          memcpy(MMC_UNTAGPTR(tmpMeta17), MMC_UNTAGPTR(_eqData), 11*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta17))[7] = omc_NBEquation_EquationPointers_addList(threadData, _auxiliary_eqns, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eqData), 7))));
          _eqData = tmpMeta17;
          tmpMeta2 = _eventInfo;
          goto tmp4_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT9, _OMC_LIT11);
          goto goto_3;
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  _eventInfo = tmpMeta2;
  _return: OMC_LABEL_UNUSED
  if (out_eqData) { *out_eqData = _eqData; }
  if (out_eventInfo) { *out_eventInfo = _eventInfo; }
  return _varData;
}

DLLDirection
modelica_metatype omc_NBEvents_convertEventIterator(threadData_t *threadData, modelica_metatype _iter)
{
  modelica_metatype _sim_iter = NULL;
  modelica_metatype tmpMeta1;
  modelica_boolean tmp5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _sim_iter has no default value.
  tmp5 = (modelica_boolean)omc_NBEquation_Iterator_isEmpty(threadData, _iter);
  if(tmp5)
  {
    tmpMeta6 = mmc_mk_none();
  }
  else
  {
    {
      modelica_metatype __omcQ_24tmpVar5;
      modelica_metatype* tmp2;
      modelica_metatype tmpMeta3;
      modelica_metatype __omcQ_24tmpVar4;
      modelica_integer tmp4;
      modelica_metatype _it_loopVar = 0;
      modelica_metatype _it;
      _it_loopVar = omc_NSimGenericCall_SimIterator_fromIterator(threadData, _iter);
      tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
      __omcQ_24tmpVar5 = tmpMeta3; /* defaultValue */
      tmp2 = &__omcQ_24tmpVar5;
      while(1) {
        tmp4 = 1;
        if (!listEmpty(_it_loopVar)) {
          _it = MMC_CAR(_it_loopVar);
          _it_loopVar = MMC_CDR(_it_loopVar);
          tmp4--;
        }
        if (tmp4 == 0) {
          __omcQ_24tmpVar4 = omc_NSimGenericCall_SimIterator_convert(threadData, _it);
          *tmp2 = mmc_mk_cons(__omcQ_24tmpVar4,0);
          tmp2 = &MMC_CDR(*tmp2);
        } else if (tmp4 == 1) {
          break;
        } else {
          MMC_THROW_INTERNAL();
        }
      }
      *tmp2 = mmc_mk_nil();
      tmpMeta1 = __omcQ_24tmpVar5;
    }
    tmpMeta6 = mmc_mk_some(tmpMeta1);
  }
  _sim_iter = tmpMeta6;
  _return: OMC_LABEL_UNUSED
  return _sim_iter;
}

DLLDirection
modelica_metatype omc_NBEvents_Condition_setRelationIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcond, modelica_integer _index)
{
  modelica_metatype _cond = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _cond = __omcQ_24in_5Fcond;
  { /* match expression */
    modelica_metatype tmp5_1;
    tmp5_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2)));
    {
      modelica_metatype _exp = NULL;
      volatile mmc_switch_type tmp5;
      int tmp6;
      // _exp has no default value.
      tmp5 = 0;
      for (; tmp5 < 2; tmp5++) {
        switch (MMC_SWITCH_CAST(tmp5)) {
        case 0: {
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp5_1,20,4) == 0) goto tmp4_end;
          
          _exp = tmp5_1;
          /* Pattern matching succeeded */
          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_exp), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[5] = mmc_mk_integer(_index);
          _exp = tmpMeta7;
          tmpMeta2 = _exp;
          goto tmp4_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta2 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2)));
          goto tmp4_done;
        }
        }
        goto tmp4_end;
        tmp4_end: ;
      }
      goto goto_3;
      goto_3:;
      MMC_THROW_INTERNAL();
      goto tmp4_done;
      tmp4_done:;
    }
  }
  tmpMeta1 = MMC_TAGPTR(mmc_alloc_words(5));
  memcpy(MMC_UNTAGPTR(tmpMeta1), MMC_UNTAGPTR(_cond), 5*sizeof(modelica_metatype));
  ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta1))[2] = tmpMeta2;
  _cond = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _cond;
}
modelica_metatype boxptr_NBEvents_Condition_setRelationIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcond, modelica_metatype _index)
{
  modelica_integer tmp1;
  modelica_metatype _cond = NULL;
  tmp1 = mmc_unbox_integer(_index);
  _cond = omc_NBEvents_Condition_setRelationIndex(threadData, __omcQ_24in_5Fcond, tmp1);
  /* skip box _cond; NBEvents.Condition */
  return _cond;
}

DLLDirection
modelica_integer omc_NBEvents_Condition_size(threadData_t *threadData, modelica_metatype _cond)
{
  modelica_integer _s;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _s = omc_NBEquation_Iterator_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 3))), 0 /* false */);
  _return: OMC_LABEL_UNUSED
  return _s;
}
modelica_metatype boxptr_NBEvents_Condition_size(threadData_t *threadData, modelica_metatype _cond)
{
  modelica_integer _s;
  modelica_metatype out_s;
  _s = omc_NBEvents_Condition_size(threadData, _cond);
  out_s = mmc_mk_icon(_s);
  return out_s;
}

DLLDirection
modelica_boolean omc_NBEvents_Condition_isEqual(threadData_t *threadData, modelica_metatype _cond1, modelica_metatype _cond2)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _b = ((omc_NFExpression_isEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond1), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond2), 2)))) && omc_NBEquation_Iterator_isEqual(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond1), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond2), 3))))) && (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond1), 4)))) == mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond2), 4))))));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_NBEvents_Condition_isEqual(threadData_t *threadData, modelica_metatype _cond1, modelica_metatype _cond2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_NBEvents_Condition_isEqual(threadData, _cond1, _cond2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_integer omc_NBEvents_Condition_hash(threadData_t *threadData, modelica_metatype _cond)
{
  modelica_integer _h;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _h = stringHashDjb2(omc_NBEvents_Condition_toString(threadData, _cond));
  _return: OMC_LABEL_UNUSED
  return _h;
}
modelica_metatype boxptr_NBEvents_Condition_hash(threadData_t *threadData, modelica_metatype _cond)
{
  modelica_integer _h;
  modelica_metatype out_h;
  _h = omc_NBEvents_Condition_hash(threadData, _cond);
  out_h = mmc_mk_icon(_h);
  return out_h;
}

DLLDirection
modelica_string omc_NBEvents_Condition_toString(threadData_t *threadData, modelica_metatype _cond)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  _str = omc_NFExpression_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2))));

  if((!omc_NBEquation_Iterator_isEmpty(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 3))))))
  {
    tmpMeta1 = stringAppend(_str,_OMC_LIT12);
    tmpMeta2 = stringAppend(tmpMeta1,omc_NBEquation_Iterator_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 3)))));
    tmpMeta3 = stringAppend(tmpMeta2,_OMC_LIT13);
    _str = tmpMeta3;
  }

  if((!(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 4)))) == ((modelica_integer) 0))))
  {
    tmpMeta4 = stringAppend(_str,_OMC_LIT14);
    tmpMeta5 = stringAppend(tmpMeta4,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 4))))));
    tmpMeta6 = stringAppend(tmpMeta5,_OMC_LIT15);
    _str = tmpMeta6;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_metatype omc_NBEvents_CompositeEvent_add(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _iter, modelica_metatype __omcQ_24in_5Fbucket, modelica_boolean _createEqn, modelica_metatype *out_bucket)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_metatype _condition = NULL;
  modelica_metatype _cev_opt = NULL;
  modelica_metatype _cev = NULL;
  modelica_metatype _aux_var = NULL;
  modelica_metatype _aux_cref = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _exp has no default value.
  _bucket = __omcQ_24in_5Fbucket;
  // _condition has no default value.
  // _cev_opt has no default value.
  // _cev has no default value.
  // _aux_var has no default value.
  // _aux_cref has no default value.
  if(_createEqn)
  {
    tmpMeta1 = mmc_mk_box4(3, &NBEvents_Condition_CONDITION__desc, _cond, _iter, mmc_mk_integer(((modelica_integer) 0)));
    _condition = tmpMeta1;
  }
  else
  {
    tmpMeta2 = mmc_mk_box4(3, &NBEvents_Condition_CONDITION__desc, _cond, _iter, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 6))));
    _condition = tmpMeta2;

    tmpMeta3 = MMC_TAGPTR(mmc_alloc_words(7));
    memcpy(MMC_UNTAGPTR(tmpMeta3), MMC_UNTAGPTR(_bucket), 7*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta3))[6] = mmc_mk_integer(((modelica_integer) 1) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 6)))));
    _bucket = tmpMeta3;
  }

  _cev_opt = omc_UnorderedMap_get(threadData, _condition, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3))));

  if(isSome(_cev_opt))
  {
    /* Pattern-matching assignment */
    tmpMeta4 = _cev_opt;
    if (optionNone(tmpMeta4)) MMC_THROW_INTERNAL();
    tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
    _cev = tmpMeta5;

    _aux_cref = omc_NBVariable_getVarName(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev), 3))));

    _exp = omc_NFExpression_fromCref(threadData, _aux_cref, 0 /* false */);
  }
  else
  {
    _aux_var = omc_NBVariable_makeEventVar(threadData, _OMC_LIT16, omc_UnorderedMap_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3)))), omc_NFExpression_typeOf(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_condition), 2)))), _iter ,&_aux_cref);

    _exp = omc_NFExpression_fromCref(threadData, _aux_cref, 0 /* false */);

    tmpMeta6 = mmc_mk_box3(3, &NBEvents_CompositeEvent_COMPOSITE__EVENT__desc, mmc_mk_integer(omc_UnorderedMap_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3))))), _aux_var);
    _cev = tmpMeta6;

    omc_UnorderedMap_add(threadData, _condition, _cev, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3))));
  }

  if((!_createEqn))
  {
    tmpMeta9 = mmc_mk_box2(0, _condition, _aux_cref);
    tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
    tmpMeta8 = mmc_mk_cons(tmpMeta9, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 5))), tmpMeta10));
    tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(7));
    memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_bucket), 7*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[5] = mmc_mk_some(tmpMeta8);
    _bucket = tmpMeta7;
  }
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  return _exp;
}
modelica_metatype boxptr_NBEvents_CompositeEvent_add(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _iter, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _createEqn, modelica_metatype *out_bucket)
{
  modelica_integer tmp1;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_CompositeEvent_add(threadData, _cond, _iter, __omcQ_24in_5Fbucket, tmp1, out_bucket);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  return _exp;
}

DLLDirection
modelica_metatype omc_NBEvents_CompositeEvent_checkDirectComposite(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcall, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_boolean _createEqn, modelica_metatype *out_exp, modelica_metatype *out_bucket, modelica_boolean *out_failed)
{
  modelica_metatype _call = NULL;
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  modelica_boolean _failed2;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _call = __omcQ_24in_5Fcall;
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  // _failed has no default value.
  // _failed2 has no default value.
  _call = omc_NBEvents_TimeEvent_createSample(threadData, _call, _bucket, _iter ,&_bucket ,&_failed ,NULL);

  if((!_failed))
  {
    _exp = omc_NBEvents_CompositeEvent_create(threadData, _exp, _bucket, _iter, _createEqn ,&_bucket ,&_failed2);

    if((!_failed2))
    {
    }
  }
  _return: OMC_LABEL_UNUSED
  if (out_exp) { *out_exp = _exp; }
  if (out_bucket) { *out_bucket = _bucket; }
  if (out_failed) { *out_failed = _failed; }
  return _call;
}
modelica_metatype boxptr_NBEvents_CompositeEvent_checkDirectComposite(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcall, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _createEqn, modelica_metatype *out_exp, modelica_metatype *out_bucket, modelica_metatype *out_failed)
{
  modelica_integer tmp1;
  modelica_boolean _failed;
  modelica_metatype _call = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _call = omc_NBEvents_CompositeEvent_checkDirectComposite(threadData, __omcQ_24in_5Fcall, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, tmp1, out_exp, out_bucket, &_failed);
  /* skip box _call; NFCall */
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  if (out_failed) { *out_failed = mmc_mk_icon(_failed); }
  return _call;
}

DLLDirection
modelica_metatype omc_NBEvents_CompositeEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_boolean _createEqn, modelica_metatype *out_bucket, modelica_boolean *out_failed)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  modelica_boolean tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  _failed = 0 /* false */;
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_metatype _call = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _call has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_integer tmp10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,3) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta6,13,1) == 0) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 2));
          tmpMeta8 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta8,0,2) == 0) goto tmp3_end;
          tmpMeta9 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta8), 3));
          tmp10 = mmc_unbox_integer(tmpMeta9);
          if (27 != tmp10) goto tmp3_end;
          
          _exp1 = tmpMeta6;
          _call = tmpMeta7;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NBBackendUtil_isOnlyTimeDependent(threadData, _exp1)) goto tmp3_end;
          _call = omc_NBEvents_CompositeEvent_checkDirectComposite(threadData, _call, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))), _bucket, _iter, _createEqn ,&_exp2 ,&_bucket ,&_failed);

          if((!_failed))
          {
            tmpMeta11 = MMC_TAGPTR(mmc_alloc_words(3));
            memcpy(MMC_UNTAGPTR(tmpMeta11), MMC_UNTAGPTR(_exp1), 3*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta11))[2] = _call;
            _exp1 = tmpMeta11;

            tmpMeta12 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta12), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta12))[2] = _exp1;
            _exp = tmpMeta12;

            if((!referenceEq(_exp2, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))))))
            {
              tmpMeta13 = MMC_TAGPTR(mmc_alloc_words(5));
              memcpy(MMC_UNTAGPTR(tmpMeta13), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta13))[4] = _exp2;
              _exp = tmpMeta13;
            }
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _bucket;
          tmp1_c2 = _failed;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_integer tmp16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_metatype tmpMeta21;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,3) == 0) goto tmp3_end;
          tmpMeta14 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta14,0,2) == 0) goto tmp3_end;
          tmpMeta15 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta14), 3));
          tmp16 = mmc_unbox_integer(tmpMeta15);
          if (27 != tmp16) goto tmp3_end;
          tmpMeta17 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 4));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta17,13,1) == 0) goto tmp3_end;
          tmpMeta18 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta17), 2));
          _exp2 = tmpMeta17;
          _call = tmpMeta18;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NBBackendUtil_isOnlyTimeDependent(threadData, _exp2)) goto tmp3_end;
          _call = omc_NBEvents_CompositeEvent_checkDirectComposite(threadData, _call, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _bucket, _iter, _createEqn ,&_exp1 ,&_bucket ,&_failed);

          if((!_failed))
          {
            tmpMeta19 = MMC_TAGPTR(mmc_alloc_words(3));
            memcpy(MMC_UNTAGPTR(tmpMeta19), MMC_UNTAGPTR(_exp2), 3*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta19))[2] = _call;
            _exp2 = tmpMeta19;

            tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[4] = _exp2;
            _exp = tmpMeta20;

            if((!referenceEq(_exp1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))))))
            {
              tmpMeta21 = MMC_TAGPTR(mmc_alloc_words(5));
              memcpy(MMC_UNTAGPTR(tmpMeta21), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta21))[2] = _exp1;
              _exp = tmpMeta21;
            }
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _bucket;
          tmp1_c2 = _failed;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta22;
          modelica_metatype tmpMeta23;
          modelica_integer tmp24;
          modelica_metatype tmpMeta25;
          modelica_metatype tmpMeta26;
          modelica_metatype tmpMeta27;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,3) == 0) goto tmp3_end;
          tmpMeta22 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (mmc__uniontype__metarecord__typedef__equal(tmpMeta22,0,2) == 0) goto tmp3_end;
          tmpMeta23 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta22), 3));
          tmp24 = mmc_unbox_integer(tmpMeta23);
          if (27 != tmp24) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _exp1 = omc_NBEvents_CompositeEvent_create(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _bucket, _iter, _createEqn ,&_bucket ,&_failed);

          if((!_failed))
          {
            tmpMeta25 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta25), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta25))[2] = _exp1;
            _exp = tmpMeta25;

            _exp2 = omc_NBEvents_CompositeEvent_create(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))), _bucket, _iter, _createEqn ,&_bucket ,&_failed);

            if((!_failed))
            {
              tmpMeta26 = MMC_TAGPTR(mmc_alloc_words(5));
              memcpy(MMC_UNTAGPTR(tmpMeta26), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta26))[4] = _exp2;
              _exp = tmpMeta26;
            }

            _failed = 0 /* false */;
          }
          else
          {
            _exp2 = omc_NBEvents_CompositeEvent_create(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))), _bucket, _iter, _createEqn ,&_bucket ,&_failed);

            if((!_failed))
            {
              tmpMeta27 = MMC_TAGPTR(mmc_alloc_words(5));
              memcpy(MMC_UNTAGPTR(tmpMeta27), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta27))[4] = _exp2;
              _exp = tmpMeta27;
            }
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _bucket;
          tmp1_c2 = _failed;
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _bucket;
          tmp1_c2 = 1 /* true */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta[0+0];
  _bucket = tmpMeta[0+1];
  _failed = tmp1_c2;

  if((!_failed))
  {
    _exp = omc_NBEvents_CompositeEvent_add(threadData, _exp, _iter, _bucket, _createEqn ,&_bucket);
  }
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  if (out_failed) { *out_failed = _failed; }
  return _exp;
}
modelica_metatype boxptr_NBEvents_CompositeEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _createEqn, modelica_metatype *out_bucket, modelica_metatype *out_failed)
{
  modelica_integer tmp1;
  modelica_boolean _failed;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_CompositeEvent_create(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, tmp1, out_bucket, &_failed);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  if (out_failed) { *out_failed = mmc_mk_icon(_failed); }
  return _exp;
}

DLLDirection
modelica_boolean omc_NBEvents_CompositeEvent_indexGt(threadData_t *threadData, modelica_metatype _tpl1, modelica_metatype _tpl2)
{
  modelica_boolean _b;
  modelica_metatype _cev1 = NULL;
  modelica_metatype _cev2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _cev1 has no default value.
  // _cev2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _cev1 = tmpMeta2;

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

  _b = (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev1), 2)))) > mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev2), 2)))));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_NBEvents_CompositeEvent_indexGt(threadData_t *threadData, modelica_metatype _tpl1, modelica_metatype _tpl2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_NBEvents_CompositeEvent_indexGt(threadData, _tpl1, _tpl2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_string omc_NBEvents_CompositeEvent_toString(threadData_t *threadData, modelica_metatype _cev)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_OMC_LIT14,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev), 2))))));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT17);
  tmpMeta3 = stringAppend(tmpMeta2,omc_NBVariable_pointerToString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev), 3)))));
  _str = tmpMeta3;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_metatype omc_NBEvents_StateEvent_convert(threadData_t *threadData, modelica_metatype _sev_tpl, modelica_metatype _equation_map)
{
  modelica_metatype _oldZc = NULL;
  modelica_metatype _cond = NULL;
  modelica_metatype _sev = NULL;
  modelica_metatype _iter = NULL;
  modelica_metatype _eqn_names = NULL;
  modelica_metatype _eqn_indices = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta12;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oldZc has no default value.
  // _cond has no default value.
  // _sev has no default value.
  // _iter has no default value.
  // _eqn_names has no default value.
  // _eqn_indices has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _sev_tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _cond = tmpMeta2;
  _sev = tmpMeta3;

  _iter = omc_NBEvents_convertEventIterator(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 3))));

  {
    modelica_metatype __omcQ_24tmpVar7;
    modelica_metatype* tmp5;
    modelica_metatype tmpMeta6;
    modelica_metatype __omcQ_24tmpVar6;
    modelica_integer tmp7;
    modelica_metatype _eqn_loopVar = 0;
    modelica_metatype _eqn;
    _eqn_loopVar = omc_UnorderedSet_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 4))));
    tmpMeta6 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar7 = tmpMeta6; /* defaultValue */
    tmp5 = &__omcQ_24tmpVar7;
    while(1) {
      tmp7 = 1;
      while (!listEmpty(_eqn_loopVar)) {
        _eqn = MMC_CAR(_eqn_loopVar);
        _eqn_loopVar = MMC_CDR(_eqn_loopVar);
        if ((!omc_NBEquation_Equation_isDummy(threadData, omc_Pointer_access(threadData, _eqn)))) {
          tmp7--;
          break;
        }
      }
      if (tmp7 == 0) {
        __omcQ_24tmpVar6 = omc_NBEquation_Equation_getEqnName(threadData, _eqn);
        *tmp5 = mmc_mk_cons(__omcQ_24tmpVar6,0);
        tmp5 = &MMC_CDR(*tmp5);
      } else if (tmp7 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp5 = mmc_mk_nil();
    tmpMeta4 = __omcQ_24tmpVar7;
  }
  _eqn_names = tmpMeta4;

  {
    modelica_metatype __omcQ_24tmpVar9;
    modelica_metatype* tmp9;
    modelica_metatype tmpMeta10;
    modelica_metatype __omcQ_24tmpVar8;
    modelica_integer tmp11;
    modelica_metatype _name_loopVar = 0;
    modelica_metatype _name;
    _name_loopVar = _eqn_names;
    tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar9 = tmpMeta10; /* defaultValue */
    tmp9 = &__omcQ_24tmpVar9;
    while(1) {
      tmp11 = 1;
      while (!listEmpty(_name_loopVar)) {
        _name = MMC_CAR(_name_loopVar);
        _name_loopVar = MMC_CDR(_name_loopVar);
        if (omc_UnorderedMap_contains(threadData, _name, _equation_map)) {
          tmp11--;
          break;
        }
      }
      if (tmp11 == 0) {
        __omcQ_24tmpVar8 = mmc_mk_integer(omc_NSimStrongComponent_Block_getIndex(threadData, omc_UnorderedMap_getSafe(threadData, _name, _equation_map, _OMC_LIT18)));
        *tmp9 = mmc_mk_cons(__omcQ_24tmpVar8,0);
        tmp9 = &MMC_CDR(*tmp9);
      } else if (tmp11 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp9 = mmc_mk_nil();
    tmpMeta8 = __omcQ_24tmpVar9;
  }
  _eqn_indices = tmpMeta8;

  tmpMeta12 = mmc_mk_box5(3, &BackendDAE_ZeroCrossing_ZERO__CROSSING__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 2))), omc_NFExpression_toDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2))), 0 /* false */), _eqn_indices, _iter);
  _oldZc = tmpMeta12;
  _return: OMC_LABEL_UNUSED
  return _oldZc;
}

static modelica_metatype closure6_NBEvents_TimeEvent_createSampleTraverse(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp, modelica_metatype $in_bucket, modelica_metatype tmp1)
{
  modelica_metatype iter = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype clocked = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_NBEvents_TimeEvent_createSampleTraverse(thData, $in_exp, $in_bucket, iter, clocked, tmp1);
}
DLLDirection
modelica_metatype omc_NBEvents_StateEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_boolean _createEqn, modelica_metatype *out_bucket)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_metatype _condition = NULL;
  modelica_metatype _sev_opt = NULL;
  modelica_metatype _sev = NULL;
  modelica_metatype _aux_var = NULL;
  modelica_metatype _aux_cref = NULL;
  modelica_metatype _clocked = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  // _condition has no default value.
  // _sev_opt has no default value.
  // _sev has no default value.
  // _aux_var has no default value.
  _aux_cref = _OMC_LIT19;
  _clocked = omc_Pointer_create(threadData, mmc_mk_boolean(0 /* false */));
  tmpMeta2 = mmc_mk_box2(0, _iter, _clocked);
  _exp = omc_NFExpression_mapFold(threadData, _exp, (modelica_fnptr) mmc_mk_box2(0,closure6_NBEvents_TimeEvent_createSampleTraverse,tmpMeta2), _bucket ,&_bucket);

  if(_createEqn)
  {
    tmpMeta3 = mmc_mk_box4(3, &NBEvents_Condition_CONDITION__desc, _exp, _iter, mmc_mk_integer(((modelica_integer) 0)));
    _condition = tmpMeta3;
  }
  else
  {
    tmpMeta4 = mmc_mk_box4(3, &NBEvents_Condition_CONDITION__desc, _exp, _iter, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 6))));
    _condition = tmpMeta4;

    tmpMeta5 = MMC_TAGPTR(mmc_alloc_words(7));
    memcpy(MMC_UNTAGPTR(tmpMeta5), MMC_UNTAGPTR(_bucket), 7*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta5))[6] = mmc_mk_integer(((modelica_integer) 1) + mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 6)))));
    _bucket = tmpMeta5;
  }

  _sev_opt = omc_UnorderedMap_get(threadData, _condition, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4))));

  if(isSome(_sev_opt))
  {
    /* Pattern-matching assignment */
    tmpMeta6 = _sev_opt;
    if (optionNone(tmpMeta6)) MMC_THROW_INTERNAL();
    tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
    _sev = tmpMeta7;

    omc_UnorderedSet_add(threadData, _eqn, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 4))));

    omc_UnorderedMap_add(threadData, _condition, _sev, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4))));

    _aux_cref = omc_NBVariable_getVarName(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 3))));

    _exp = omc_NFExpression_fromCref(threadData, _aux_cref, 0 /* false */);
  }
  else
  {
    if((!mmc_unbox_boolean(omc_Pointer_access(threadData, _clocked))))
    {
      _aux_var = omc_NBVariable_makeEventVar(threadData, _OMC_LIT20, omc_UnorderedMap_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4)))), omc_NFExpression_typeOf(threadData, _exp), _iter ,&_aux_cref);

      _exp = omc_NFExpression_fromCref(threadData, _aux_cref, 0 /* false */);

      tmpMeta8 = mmc_mk_cons(_eqn, MMC_REFSTRUCTLIT(mmc_nil));
      tmpMeta9 = mmc_mk_box4(3, &NBEvents_StateEvent_STATE__EVENT__desc, mmc_mk_integer(omc_UnorderedMap_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4))))), _aux_var, omc_UnorderedSet_fromList(threadData, tmpMeta8, boxvar_NBEquation_Equation_hash, boxvar_NBEquation_Equation_equalName));
      _sev = tmpMeta9;

      _condition = omc_NBEvents_Condition_setRelationIndex(threadData, _condition, mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 2)))));

      omc_UnorderedMap_add(threadData, _condition, _sev, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4))));
    }
  }

  if((!(_createEqn || mmc_unbox_boolean(omc_Pointer_access(threadData, _clocked)))))
  {
    tmpMeta12 = mmc_mk_box2(0, _condition, _aux_cref);
    tmpMeta13 = MMC_REFSTRUCTLIT(mmc_nil);
    tmpMeta11 = mmc_mk_cons(tmpMeta12, omc_Util_getOptionOrDefault(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 5))), tmpMeta13));
    tmpMeta10 = MMC_TAGPTR(mmc_alloc_words(7));
    memcpy(MMC_UNTAGPTR(tmpMeta10), MMC_UNTAGPTR(_bucket), 7*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta10))[5] = mmc_mk_some(tmpMeta11);
    _bucket = tmpMeta10;
  }
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  return _exp;
}
modelica_metatype boxptr_NBEvents_StateEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _createEqn, modelica_metatype *out_bucket)
{
  modelica_integer tmp1;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_StateEvent_create(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, _eqn, tmp1, out_bucket);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  return _exp;
}

static modelica_metatype closure8_NBEvents_collectEventsTraverse(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype bucket_ptr = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype iter = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  modelica_metatype eqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),3));
  modelica_metatype funcMap = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),4));
  modelica_metatype createEqn = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),5));
  return boxptr_NBEvents_collectEventsTraverse(thData, $in_exp, bucket_ptr, iter, eqn, funcMap, createEqn);
}static modelica_metatype closure7_NFExpression_fakeMap(threadData_t *thData, modelica_metatype closure, modelica_metatype exp)
{
  modelica_fnptr func = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NFExpression_fakeMap(thData, exp, func);
}
DLLDirection
modelica_metatype omc_NBEvents_StateEvent_fromStatement(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fstmt, modelica_metatype _bucket_ptr, modelica_metatype _eqn, modelica_metatype _variables, modelica_metatype _funcMap, modelica_metatype _frames)
{
  modelica_metatype _stmt = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _stmt = __omcQ_24in_5Fstmt;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _stmt;
    {
      modelica_metatype _name = NULL;
      modelica_metatype _range = NULL;
      modelica_metatype _new_frames = NULL;
      modelica_metatype _iter = NULL;
      modelica_metatype _new_stmt = NULL;
      modelica_metatype _new_stmts = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _name has no default value.
      // _range has no default value.
      // _new_frames has no default value.
      // _iter has no default value.
      // _new_stmt has no default value.
      // _new_stmts 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,5,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta1 = _stmt;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,2,5) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 3));
          if (optionNone(tmpMeta6)) goto tmp3_end;
          tmpMeta7 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta6), 1));
          
          _range = tmpMeta7;
          /* Pattern matching succeeded */
          tmpMeta8 = MMC_REFSTRUCTLIT(mmc_nil);
          _new_stmts = tmpMeta8;

          tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
          _name = omc_NFComponentRef_fromNode(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt), 2))), _OMC_LIT4, tmpMeta9, 1);

          _name = omc_NBackendDAE_lowerComponentReference(threadData, _name, _variables, 1 /* true */);

          tmpMeta11 = mmc_mk_box3(0, _name, _range, mmc_mk_none());
          tmpMeta10 = mmc_mk_cons(tmpMeta11, _frames);
          _new_frames = tmpMeta10;

          {
            modelica_metatype _elem;
            for (tmpMeta12 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_stmt), 4))); !listEmpty(tmpMeta12); tmpMeta12=MMC_CDR(tmpMeta12))
            {
              _elem = MMC_CAR(tmpMeta12);
              _new_stmt = omc_NBEvents_StateEvent_fromStatement(threadData, _elem, _bucket_ptr, _eqn, _variables, _funcMap, _new_frames);

              tmpMeta13 = mmc_mk_cons(_new_stmt, _new_stmts);
              _new_stmts = tmpMeta13;

              _new_stmts = omc_NBEvents_EventInfo_createAuxStatements(threadData, _new_stmts, _bucket_ptr, _variables);
            }
          }

          tmpMeta15 = MMC_TAGPTR(mmc_alloc_words(7));
          memcpy(MMC_UNTAGPTR(tmpMeta15), MMC_UNTAGPTR(_stmt), 7*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta15))[4] = listReverse(_new_stmts);
          _stmt = tmpMeta15;
          tmpMeta1 = _stmt;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          
          /* Pattern matching succeeded */
          _iter = omc_NBEquation_Iterator_fromFrames(threadData, listReverse(_frames));
          tmpMeta17 = mmc_mk_box5(0, _bucket_ptr, _iter, _eqn, _funcMap, mmc_mk_boolean(0 /* false */));
          tmpMeta16 = mmc_mk_box1(0, (modelica_fnptr) mmc_mk_box2(0,closure8_NBEvents_collectEventsTraverse,tmpMeta17));
          tmpMeta1 = omc_NFStatement_mapExp(threadData, _stmt, (modelica_fnptr) mmc_mk_box2(0,closure7_NFExpression_fakeMap,tmpMeta16));
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _stmt = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _stmt;
}

DLLDirection
modelica_boolean omc_NBEvents_StateEvent_indexGt(threadData_t *threadData, modelica_metatype _tpl1, modelica_metatype _tpl2)
{
  modelica_boolean _b;
  modelica_metatype _sev1 = NULL;
  modelica_metatype _sev2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  // _sev1 has no default value.
  // _sev2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl1;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _sev1 = tmpMeta2;

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

  _b = (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev1), 2)))) > mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev2), 2)))));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_NBEvents_StateEvent_indexGt(threadData_t *threadData, modelica_metatype _tpl1, modelica_metatype _tpl2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_NBEvents_StateEvent_indexGt(threadData, _tpl1, _tpl2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_string omc_NBEvents_StateEvent_toStringList(threadData_t *threadData, modelica_metatype _events_lst)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  _str = omc_StringUtil_headline__4(threadData, _OMC_LIT21);

  if(listEmpty(_events_lst))
  {
    tmpMeta1 = stringAppend(_str,_OMC_LIT23);
    _str = tmpMeta1;
  }
  else
  {
    {
      modelica_metatype __omcQ_24tmpVar11;
      modelica_metatype* tmp3;
      modelica_metatype tmpMeta4;
      modelica_string __omcQ_24tmpVar10;
      modelica_integer tmp5;
      modelica_metatype _te_loopVar = 0;
      modelica_metatype _te;
      _te_loopVar = _events_lst;
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      __omcQ_24tmpVar11 = tmpMeta4; /* defaultValue */
      tmp3 = &__omcQ_24tmpVar11;
      while(1) {
        tmp5 = 1;
        if (!listEmpty(_te_loopVar)) {
          _te = MMC_CAR(_te_loopVar);
          _te_loopVar = MMC_CDR(_te_loopVar);
          tmp5--;
        }
        if (tmp5 == 0) {
          __omcQ_24tmpVar10 = omc_NBEvents_StateEvent_toString(threadData, _te);
          *tmp3 = mmc_mk_cons(__omcQ_24tmpVar10,0);
          tmp3 = &MMC_CDR(*tmp3);
        } else if (tmp5 == 1) {
          break;
        } else {
          MMC_THROW_INTERNAL();
        }
      }
      *tmp3 = mmc_mk_nil();
      tmpMeta2 = __omcQ_24tmpVar11;
    }
    tmpMeta6 = stringAppend(_str,stringDelimitList(tmpMeta2, _OMC_LIT22));
    _str = tmpMeta6;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_string omc_NBEvents_StateEvent_toString(threadData_t *threadData, modelica_metatype _sev)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  tmpMeta1 = stringAppend(_OMC_LIT14,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 2))))));
  tmpMeta2 = stringAppend(tmpMeta1,_OMC_LIT17);
  tmpMeta3 = stringAppend(tmpMeta2,omc_NBVariable_toString(threadData, omc_Pointer_access(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 3)))), _OMC_LIT24));
  _str = tmpMeta3;
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_convert(threadData_t *threadData, modelica_metatype _timeEvent)
{
  modelica_metatype _oldTimeEvent = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _oldTimeEvent has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _timeEvent;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          
          /* Pattern matching succeeded */
          tmpMeta5 = mmc_mk_box5(4, &BackendDAE_TimeEvent_SAMPLE__TIME__EVENT__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 2))), omc_NFExpression_toDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 3))), 0 /* false */), omc_NFExpression_toDAE(threadData, omc_NFExpression_makeMaxValue(threadData, _OMC_LIT25), 0 /* false */), omc_NBEvents_convertEventIterator(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 4)))));
          tmpMeta1 = tmpMeta5;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          
          /* Pattern matching succeeded */
          tmpMeta6 = mmc_mk_box5(4, &BackendDAE_TimeEvent_SAMPLE__TIME__EVENT__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 2))), omc_NFExpression_toDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 3))), 0 /* false */), omc_NFExpression_toDAE(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 4))), 0 /* false */), omc_NBEvents_convertEventIterator(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 5)))));
          tmpMeta1 = tmpMeta6;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT9, _OMC_LIT27);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _oldTimeEvent = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _oldTimeEvent;
}

DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_setIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5FtimeEvent, modelica_integer _index)
{
  modelica_metatype _timeEvent = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _timeEvent = __omcQ_24in_5FtimeEvent;
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _timeEvent;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          
          /* Pattern matching succeeded */
          tmpMeta5 = MMC_TAGPTR(mmc_alloc_words(5));
          memcpy(MMC_UNTAGPTR(tmpMeta5), MMC_UNTAGPTR(_timeEvent), 5*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta5))[2] = mmc_mk_integer(_index);
          _timeEvent = tmpMeta5;
          tmpMeta1 = _timeEvent;
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          
          /* Pattern matching succeeded */
          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(6));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_timeEvent), 6*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = mmc_mk_integer(_index);
          _timeEvent = tmpMeta6;
          tmpMeta1 = _timeEvent;
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _timeEvent;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _timeEvent = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _timeEvent;
}
modelica_metatype boxptr_NBEvents_TimeEvent_setIndex(threadData_t *threadData, modelica_metatype __omcQ_24in_5FtimeEvent, modelica_metatype _index)
{
  modelica_integer tmp1;
  modelica_metatype _timeEvent = NULL;
  tmp1 = mmc_unbox_integer(_index);
  _timeEvent = omc_NBEvents_TimeEvent_setIndex(threadData, __omcQ_24in_5FtimeEvent, tmp1);
  /* skip box _timeEvent; NBEvents.TimeEvent */
  return _timeEvent;
}

DLLDirection
modelica_integer omc_NBEvents_TimeEvent_getIndex(threadData_t *threadData, modelica_metatype _timeEvent)
{
  modelica_integer _index;
  modelica_integer tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _index has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _timeEvent;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 2))));
          goto tmp3_done;
        }
        case 1: {
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,1,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmp1 = mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 2))));
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _index = tmp1;
  _return: OMC_LABEL_UNUSED
  return _index;
}
modelica_metatype boxptr_NBEvents_TimeEvent_getIndex(threadData_t *threadData, modelica_metatype _timeEvent)
{
  modelica_integer _index;
  modelica_metatype out_index;
  _index = omc_NBEvents_TimeEvent_getIndex(threadData, _timeEvent);
  out_index = mmc_mk_icon(_index);
  return out_index;
}

DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_createSampleTraverse(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _clocked, modelica_metatype *out_bucket)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _c;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  // _c has no default value.
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _call = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _call has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmp4_1), 2));
          _call = tmpMeta6;
          /* Pattern matching succeeded */
          _call = omc_NBEvents_TimeEvent_createSample(threadData, _call, _bucket, _iter ,&_bucket ,NULL ,&_c);

          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(3));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_exp), 3*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[2] = _call;
          _exp = tmpMeta7;

          if(_c)
          {
            omc_Pointer_update(threadData, _clocked, mmc_mk_boolean(_c));
          }
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta1 = _exp;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  return _exp;
}

DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_createSample(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcall, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype *out_bucket, modelica_boolean *out_failed, modelica_boolean *out_clocked)
{
  modelica_metatype _call = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  modelica_boolean _clocked;
  modelica_boolean tmp1_c0 __attribute__((unused)) = 0;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _call = __omcQ_24in_5Fcall;
  _bucket = __omcQ_24in_5Fbucket;
  // _failed has no default value.
  // _clocked has no default value.
  
  
  { /* match expression */
    modelica_string tmp4_1;modelica_metatype tmp4_2;
    tmp4_1 = omc_AbsynUtil_pathLastIdent(threadData, omc_NFCall_functionName(threadData, _call));
    tmp4_2 = omc_NFCall_arguments(threadData, _call);
    {
      modelica_metatype _clock = NULL;
      modelica_metatype _start = NULL;
      modelica_metatype _interval = NULL;
      modelica_metatype _timeEvent = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _clock has no default value.
      // _start has no default value.
      // _interval has no default value.
      // _timeEvent has no default value.
      tmp4 = 0;
      for (; tmp4 < 4; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          if (6 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT0), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta6 = MMC_CAR(tmp4_2);
          tmpMeta7 = MMC_CDR(tmp4_2);
          if (listEmpty(tmpMeta7)) goto tmp3_end;
          tmpMeta8 = MMC_CAR(tmpMeta7);
          tmpMeta9 = MMC_CDR(tmpMeta7);
          if (!listEmpty(tmpMeta9)) goto tmp3_end;
          _clock = tmpMeta8;
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!omc_NFType_isClock(threadData, omc_NFExpression_typeOf(threadData, _clock))) goto tmp3_end;
          tmp1_c0 = 0 /* false */;
          tmp1_c1 = 1 /* true */;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          if (6 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT0), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
          if (listEmpty(tmp4_2)) goto tmp3_end;
          tmpMeta10 = MMC_CAR(tmp4_2);
          tmpMeta11 = MMC_CDR(tmp4_2);
          if (listEmpty(tmpMeta11)) goto tmp3_end;
          tmpMeta12 = MMC_CAR(tmpMeta11);
          tmpMeta13 = MMC_CDR(tmpMeta11);
          if (!listEmpty(tmpMeta13)) goto tmp3_end;
          _start = tmpMeta10;
          _interval = tmpMeta12;
          /* Pattern matching succeeded */
          tmpMeta14 = mmc_mk_box5(4, &NBEvents_TimeEvent_SAMPLE__desc, mmc_mk_integer(omc_UnorderedSet_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))))), _start, _interval, _iter);
          _timeEvent = tmpMeta14;

          if((!omc_UnorderedSet_contains(threadData, _timeEvent, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))))))
          {
            omc_UnorderedSet_add(threadData, _timeEvent, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))));
          }

          tmpMeta16 = mmc_mk_box2(3, &NFExpression_INTEGER__desc, mmc_mk_integer(((modelica_integer) 1) + omc_NBEvents_TimeEvent_getIndex(threadData, _timeEvent)));
          tmpMeta15 = mmc_mk_cons(tmpMeta16, mmc_mk_cons(_start, mmc_mk_cons(_interval, MMC_REFSTRUCTLIT(mmc_nil))));
          _call = omc_NFCall_setArguments(threadData, _call, tmpMeta15);
          tmp1_c0 = 0 /* false */;
          tmp1_c1 = 0 /* false */;
          goto tmp3_done;
        }
        case 2: {
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          if (6 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT0), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          tmpMeta18 = stringAppend(_OMC_LIT28,omc_NFCall_toString(threadData, _call));
          tmpMeta17 = mmc_mk_cons(tmpMeta18, MMC_REFSTRUCTLIT(mmc_nil));
          omc_Error_addMessage(threadData, _OMC_LIT9, tmpMeta17);
          goto goto_2;
          goto tmp3_done;
        }
        case 3: {
          
          /* Pattern matching succeeded */
          tmp1_c0 = 1 /* true */;
          tmp1_c1 = 0 /* false */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _failed = tmp1_c0;
  _clocked = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  if (out_failed) { *out_failed = _failed; }
  if (out_clocked) { *out_clocked = _clocked; }
  return _call;
}
modelica_metatype boxptr_NBEvents_TimeEvent_createSample(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fcall, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype *out_bucket, modelica_metatype *out_failed, modelica_metatype *out_clocked)
{
  modelica_boolean _failed;
  modelica_boolean _clocked;
  modelica_metatype _call = NULL;
  _call = omc_NBEvents_TimeEvent_createSample(threadData, __omcQ_24in_5Fcall, __omcQ_24in_5Fbucket, _iter, out_bucket, &_failed, &_clocked);
  /* skip box _call; NFCall */
  /* skip box _bucket; NBEvents.Bucket */
  if (out_failed) { *out_failed = mmc_mk_icon(_failed); }
  if (out_clocked) { *out_clocked = mmc_mk_icon(_clocked); }
  return _call;
}

static modelica_metatype closure9_NBEvents_containsTimeTraverseExp(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype b = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NBEvents_containsTimeTraverseExp(thData, $in_exp, b);
}static modelica_metatype closure10_NBEvents_containsTimeTraverseCref(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_cref)
{
  modelica_metatype b = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NBEvents_containsTimeTraverseCref(thData, $in_cref, b);
}
DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_createSingleOrSample(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype *out_bucket, modelica_boolean *out_failed)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  modelica_boolean tmp1_c1 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  // _failed has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _tmpEqn = NULL;
      modelica_integer _status;
      modelica_boolean _can_trigger;
      modelica_integer _invert;
      modelica_metatype _call = NULL;
      modelica_metatype _trigger = NULL;
      modelica_metatype _new_exp = NULL;
      modelica_metatype _timeEvent = NULL;
      modelica_metatype _containsTime = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _tmpEqn has no default value.
      // _status has no default value.
      // _can_trigger has no default value.
      // _invert has no default value.
      // _call has no default value.
      // _trigger has no default value.
      // _new_exp has no default value.
      // _timeEvent has no default value.
      _containsTime = omc_Pointer_create(threadData, mmc_mk_boolean(0 /* false */));
      tmp4 = 0;
      for (; tmp4 < 3; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,13,1) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _call = omc_NBEvents_TimeEvent_createSample(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _bucket, _iter ,&_bucket ,&_failed ,NULL);

          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(3));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_exp), 3*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = _call;
          _exp = tmpMeta6;
          tmpMeta[0+0] = _exp;
          tmp1_c1 = _failed;
          goto tmp3_done;
        }
        case 1: {
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          modelica_metatype tmpMeta12;
          modelica_metatype tmpMeta13;
          modelica_metatype tmpMeta14;
          modelica_metatype tmpMeta15;
          modelica_metatype tmpMeta16;
          modelica_metatype tmpMeta17;
          modelica_metatype tmpMeta18;
          modelica_metatype tmpMeta19;
          modelica_metatype tmpMeta20;
          modelica_boolean tmp21 = 0;
          modelica_metatype tmpMeta27;
          modelica_metatype tmpMeta28;
          modelica_metatype tmpMeta29;
          modelica_metatype tmpMeta30;
          modelica_metatype tmpMeta31;
          modelica_metatype tmpMeta32;
          modelica_metatype tmpMeta33;
          modelica_metatype tmpMeta34;
          modelica_metatype tmpMeta35;
          modelica_metatype tmpMeta36;
          modelica_metatype tmpMeta37;
          modelica_metatype tmpMeta38;
          modelica_metatype tmpMeta39;
          modelica_metatype tmpMeta40;
          modelica_metatype tmpMeta41;
          modelica_boolean tmp42;
          modelica_metatype tmpMeta43;
          modelica_metatype tmpMeta44;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,20,4) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_NFOperator_getMathClassification(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3)))) == 7)) goto tmp3_end;
          _tmpEqn = omc_Pointer_access(threadData, omc_NBEquation_Equation_makeAssignment(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))), omc_Pointer_create(threadData, mmc_mk_integer(((modelica_integer) 0))), _OMC_LIT29, _OMC_LIT30, omc_NBEquation_default(threadData, 5, 0 /* false */, mmc_mk_none(), mmc_mk_none())));

          tmpMeta7 = mmc_mk_box1(0, _containsTime);
          tmpMeta8 = mmc_mk_box1(0, _containsTime);
          omc_NBEquation_Equation_map(threadData, _tmpEqn, (modelica_fnptr) mmc_mk_box2(0,closure9_NBEvents_containsTimeTraverseExp,tmpMeta7), mmc_mk_some((modelica_fnptr) mmc_mk_box2(0,closure10_NBEvents_containsTimeTraverseCref,tmpMeta8)), boxvar_NFExpression_map);

          if(mmc_unbox_boolean(omc_Pointer_access(threadData, _containsTime)))
          {
            tmpMeta9 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta10 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta11 = mmc_mk_box6(6, &NFClassTree_ClassTree_FLAT__TREE__desc, _OMC_LIT80, listArray(tmpMeta9), _OMC_LIT142, listArray(tmpMeta10), _OMC_LIT143);
            tmpMeta12 = mmc_mk_box6(5, &NFClass_PARTIAL__BUILTIN__desc, _OMC_LIT25, tmpMeta11, _OMC_LIT82, _OMC_LIT144, _OMC_LIT145);
            tmpMeta13 = mmc_mk_box8(3, &NFInstNode_InstNode_CLASS__NODE__desc, _OMC_LIT32, _OMC_LIT46, mmc_mk_integer(1), mmc_mk_some(tmpMeta12), _OMC_LIT148, _OMC_LIT85, _OMC_LIT149);
            tmpMeta14 = mmc_mk_box9(4, &NFComponent_COMPONENT__desc, tmpMeta13, _OMC_LIT25, _OMC_LIT150, _OMC_LIT150, _OMC_LIT152, _OMC_LIT43, mmc_mk_integer(4), _OMC_LIT45);
            tmpMeta15 = mmc_mk_box7(4, &NFInstNode_InstNode_COMPONENT__NODE__desc, _OMC_LIT31, mmc_mk_none(), mmc_mk_integer(1), mmc_mk_some(tmpMeta14), _OMC_LIT85, _OMC_LIT86);
            tmpMeta16 = MMC_REFSTRUCTLIT(mmc_nil);
            tmpMeta17 = mmc_mk_box6(3, &NFComponentRef_CREF__desc, tmpMeta15, tmpMeta16, _OMC_LIT25, mmc_mk_integer(1), _OMC_LIT19);
            _tmpEqn = omc_NBSolve_solveBody(threadData, _tmpEqn, tmpMeta17, _funcMap ,&_status ,&_invert);

            if((((modelica_integer)_status == 2) && ((modelica_integer)_invert != 3)))
            {
              /* Pattern-matching assignment */
              tmpMeta18 = omc_NBEquation_Equation_getRHS(threadData, _tmpEqn);
              if (optionNone(tmpMeta18)) goto goto_2;
              tmpMeta19 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta18), 1));
              _trigger = tmpMeta19;

              tmpMeta20 = MMC_TAGPTR(mmc_alloc_words(6));
              memcpy(MMC_UNTAGPTR(tmpMeta20), MMC_UNTAGPTR(_exp), 6*sizeof(modelica_metatype));
              ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta20))[3] = (((modelica_integer)_invert == 1)?omc_NFOperator_invert(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3)))):(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3))));
              _exp = tmpMeta20;

              if(omc_NBEquation_Equation_isWhenEquation(threadData, _eqn))
              {
                { /* match expression */
                  modelica_metatype tmp24_1;
                  tmp24_1 = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3)))), 3)));
                  {
                    int tmp24;
                    {
                      switch (MMC_SWITCH_CAST(mmc_unbox_integer(tmp24_1))) {
                      case 32: {
                        modelica_integer tmp25;
                        tmp25 = mmc_unbox_integer(tmp24_1);
                        if (32 != tmp25) goto tmp23_end;
                        /* Pattern matching succeeded */
                        tmp21 = 1 /* true */;
                        goto tmp23_done;
                      }
                      case 33: {
                        modelica_integer tmp26;
                        tmp26 = mmc_unbox_integer(tmp24_1);
                        if (33 != tmp26) goto tmp23_end;
                        /* Pattern matching succeeded */
                        tmp21 = 1 /* true */;
                        goto tmp23_done;
                      }
                      default:
                      tmp23_default: OMC_LABEL_UNUSED; {
                        
                        /* Pattern matching succeeded */
                        tmp21 = 0 /* false */;
                        goto tmp23_done;
                      }
                      }
                      goto tmp23_end;
                      tmp23_end: ;
                    }
                    goto goto_22;
                    goto_22:;
                    goto goto_2;
                    goto tmp23_done;
                    tmp23_done:;
                  }
                }
                _can_trigger = tmp21;

                tmp42 = (modelica_boolean)_can_trigger;
                if(tmp42)
                {
                  tmpMeta27 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta28 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta29 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta30 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta31 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta32 = mmc_mk_box15(3, &NFFunction_Function_FUNCTION__desc, _OMC_LIT155, _OMC_LIT85, _OMC_LIT162, _OMC_LIT161, tmpMeta27, mmc_mk_none(), tmpMeta28, _OMC_LIT95, _OMC_LIT166, tmpMeta29, tmpMeta30, listArray(tmpMeta31), _OMC_LIT167, _OMC_LIT168);
                  tmpMeta34 = mmc_mk_box2(3, &NFExpression_INTEGER__desc, mmc_mk_integer(((modelica_integer) 1) + omc_UnorderedSet_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))))));
                  tmpMeta33 = mmc_mk_cons(tmpMeta34, mmc_mk_cons(_trigger, mmc_mk_cons(omc_NFExpression_makeMaxValue(threadData, _OMC_LIT25), MMC_REFSTRUCTLIT(mmc_nil))));
                  tmpMeta35 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta36 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta37 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta38 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta39 = MMC_REFSTRUCTLIT(mmc_nil);
                  tmpMeta40 = mmc_mk_box15(3, &NFFunction_Function_FUNCTION__desc, _OMC_LIT155, _OMC_LIT85, _OMC_LIT162, _OMC_LIT161, tmpMeta35, mmc_mk_none(), tmpMeta36, _OMC_LIT95, _OMC_LIT166, tmpMeta37, tmpMeta38, listArray(tmpMeta39), _OMC_LIT167, _OMC_LIT168);
                  tmpMeta41 = mmc_mk_box2(16, &NFExpression_CALL__desc, omc_NFCall_makeTypedCall(threadData, tmpMeta32, tmpMeta33, 5, 1, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta40), 9)))));
                  tmpMeta43 = tmpMeta41;
                }
                else
                {
                  tmpMeta43 = _OMC_LIT169;
                }
                _new_exp = tmpMeta43;
              }
              else
              {
                _can_trigger = 1 /* true */;

                _new_exp = _exp;
              }

              if(_can_trigger)
              {
                tmpMeta44 = mmc_mk_box4(3, &NBEvents_TimeEvent_SINGLE__desc, mmc_mk_integer(omc_UnorderedSet_size(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))))), _trigger, _iter);
                _timeEvent = tmpMeta44;

                if((!omc_UnorderedSet_contains(threadData, _timeEvent, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))))))
                {
                  omc_UnorderedSet_add(threadData, _timeEvent, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))));
                }
              }

              _failed = 0 /* false */;
            }
            else
            {
              _failed = 1 /* true */;

              _new_exp = _exp;
            }
          }
          else
          {
            _failed = 1 /* true */;

            _new_exp = _exp;
          }
          tmpMeta[0+0] = _new_exp;
          tmp1_c1 = _failed;
          goto tmp3_done;
        }
        case 2: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = _exp;
          tmp1_c1 = 1 /* true */;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta[0+0];
  _failed = tmp1_c1;
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  if (out_failed) { *out_failed = _failed; }
  return _exp;
}
modelica_metatype boxptr_NBEvents_TimeEvent_createSingleOrSample(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype *out_bucket, modelica_metatype *out_failed)
{
  modelica_boolean _failed;
  modelica_metatype _exp = NULL;
  _exp = omc_NBEvents_TimeEvent_createSingleOrSample(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, _eqn, _funcMap, out_bucket, &_failed);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  if (out_failed) { *out_failed = mmc_mk_icon(_failed); }
  return _exp;
}

DLLDirection
modelica_metatype omc_NBEvents_TimeEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_boolean _createEqn, modelica_metatype *out_bucket, modelica_boolean *out_failed)
{
  modelica_metatype _exp = NULL;
  modelica_metatype _bucket = NULL;
  modelica_boolean _failed;
  modelica_boolean tmp1_c2 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta[3] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _exp = __omcQ_24in_5Fexp;
  _bucket = __omcQ_24in_5Fbucket;
  _failed = 0 /* false */;
  
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _exp;
    {
      modelica_metatype _exp1 = NULL;
      modelica_metatype _exp2 = NULL;
      modelica_boolean _b1;
      modelica_boolean _b2;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _exp1 has no default value.
      // _exp2 has no default value.
      // _b1 has no default value.
      // _b2 has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,18,3) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          /* Check guard condition after assignments */
          if (!(omc_NFOperator_getMathClassification(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 3)))) == 6)) goto tmp3_end;
          _exp1 = omc_NBEvents_TimeEvent_create(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 2))), _bucket, _iter, _eqn, _funcMap, _createEqn ,&_bucket ,&_b1);

          _exp2 = omc_NBEvents_TimeEvent_create(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_exp), 4))), _bucket, _iter, _eqn, _funcMap, _createEqn ,&_bucket ,&_b2);

          _failed = (_b1 || _b2);

          if((!_failed))
          {
            tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[2] = _exp1;
            _exp = tmpMeta6;

            tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(5));
            memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_exp), 5*sizeof(modelica_metatype));
            ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[4] = _exp2;
            _exp = tmpMeta7;
          }
          tmpMeta[0+0] = _exp;
          tmpMeta[0+1] = _bucket;
          tmp1_c2 = _failed;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          tmpMeta[0+0] = omc_NBEvents_TimeEvent_createSingleOrSample(threadData, _exp, _bucket, _iter, _eqn, _funcMap, &tmpMeta[0+1], &tmp1_c2);
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _exp = tmpMeta[0+0];
  _bucket = tmpMeta[0+1];
  _failed = tmp1_c2;

  if((!_failed))
  {
    _exp = omc_NBEvents_CompositeEvent_add(threadData, _exp, _iter, _bucket, _createEqn ,&_bucket);
  }
  _return: OMC_LABEL_UNUSED
  if (out_bucket) { *out_bucket = _bucket; }
  if (out_failed) { *out_failed = _failed; }
  return _exp;
}
modelica_metatype boxptr_NBEvents_TimeEvent_create(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fexp, modelica_metatype __omcQ_24in_5Fbucket, modelica_metatype _iter, modelica_metatype _eqn, modelica_metatype _funcMap, modelica_metatype _createEqn, modelica_metatype *out_bucket, modelica_metatype *out_failed)
{
  modelica_integer tmp1;
  modelica_boolean _failed;
  modelica_metatype _exp = NULL;
  tmp1 = mmc_unbox_integer(_createEqn);
  _exp = omc_NBEvents_TimeEvent_create(threadData, __omcQ_24in_5Fexp, __omcQ_24in_5Fbucket, _iter, _eqn, _funcMap, tmp1, out_bucket, &_failed);
  /* skip box _exp; NFExpression */
  /* skip box _bucket; NBEvents.Bucket */
  if (out_failed) { *out_failed = mmc_mk_icon(_failed); }
  return _exp;
}

DLLDirection
modelica_boolean omc_NBEvents_TimeEvent_indexGt(threadData_t *threadData, modelica_metatype _tev1, modelica_metatype _tev2)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _b = (omc_NBEvents_TimeEvent_getIndex(threadData, _tev1) > omc_NBEvents_TimeEvent_getIndex(threadData, _tev2));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_NBEvents_TimeEvent_indexGt(threadData_t *threadData, modelica_metatype _tev1, modelica_metatype _tev2)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_NBEvents_TimeEvent_indexGt(threadData, _tev1, _tev2);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

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

DLLDirection
modelica_integer omc_NBEvents_TimeEvent_hash(threadData_t *threadData, modelica_metatype _tev)
{
  modelica_integer _h;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _h = stringHashDjb2(omc_NBEvents_TimeEvent_toString(threadData, _tev, 0 /* false */));
  _return: OMC_LABEL_UNUSED
  return _h;
}
modelica_metatype boxptr_NBEvents_TimeEvent_hash(threadData_t *threadData, modelica_metatype _tev)
{
  modelica_integer _h;
  modelica_metatype out_h;
  _h = omc_NBEvents_TimeEvent_hash(threadData, _tev);
  out_h = mmc_mk_icon(_h);
  return out_h;
}

DLLDirection
modelica_string omc_NBEvents_TimeEvent_toStringList(threadData_t *threadData, modelica_metatype _events_lst)
{
  modelica_string _str = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta6;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  _str = omc_StringUtil_headline__4(threadData, _OMC_LIT170);

  if(listEmpty(_events_lst))
  {
    tmpMeta1 = stringAppend(_str,_OMC_LIT171);
    _str = tmpMeta1;
  }
  else
  {
    {
      modelica_metatype __omcQ_24tmpVar13;
      modelica_metatype* tmp3;
      modelica_metatype tmpMeta4;
      modelica_string __omcQ_24tmpVar12;
      modelica_integer tmp5;
      modelica_metatype _te_loopVar = 0;
      modelica_metatype _te;
      _te_loopVar = _events_lst;
      tmpMeta4 = MMC_REFSTRUCTLIT(mmc_nil);
      __omcQ_24tmpVar13 = tmpMeta4; /* defaultValue */
      tmp3 = &__omcQ_24tmpVar13;
      while(1) {
        tmp5 = 1;
        if (!listEmpty(_te_loopVar)) {
          _te = MMC_CAR(_te_loopVar);
          _te_loopVar = MMC_CDR(_te_loopVar);
          tmp5--;
        }
        if (tmp5 == 0) {
          __omcQ_24tmpVar12 = omc_NBEvents_TimeEvent_toString(threadData, _te, 1 /* true */);
          *tmp3 = mmc_mk_cons(__omcQ_24tmpVar12,0);
          tmp3 = &MMC_CDR(*tmp3);
        } else if (tmp5 == 1) {
          break;
        } else {
          MMC_THROW_INTERNAL();
        }
      }
      *tmp3 = mmc_mk_nil();
      tmpMeta2 = __omcQ_24tmpVar13;
    }
    tmpMeta6 = stringAppend(_str,stringDelimitList(tmpMeta2, _OMC_LIT22));
    _str = tmpMeta6;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_string omc_NBEvents_TimeEvent_toString(threadData_t *threadData, modelica_metatype _timeEvent, modelica_boolean _printIndex)
{
  modelica_string _str = NULL;
  modelica_metatype _iter = NULL;
  modelica_string tmp1_c0 __attribute__((unused)) = 0;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  modelica_metatype tmpMeta15;
  modelica_metatype tmpMeta16;
  modelica_metatype tmpMeta17;
  modelica_metatype tmpMeta[2] __attribute__((unused)) = {0};
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _iter has no default value.
  
  
  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _timeEvent;
    {
      int tmp4;
      {
        switch (MMC_SWITCH_CAST(valueConstructor(tmp4_1))) {
        case 3: {
          modelica_metatype tmpMeta5;
          
          /* Pattern matching succeeded */
          tmpMeta5 = stringAppend(_OMC_LIT172,omc_NFExpression_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 3)))));
          tmp1_c0 = tmpMeta5;
          tmpMeta[0+1] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 4)));
          goto tmp3_done;
        }
        case 4: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          modelica_metatype tmpMeta9;
          modelica_metatype tmpMeta10;
          modelica_metatype tmpMeta11;
          
          /* Pattern matching succeeded */
          tmpMeta6 = stringAppend(_OMC_LIT173,intString(mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 2))))));
          tmpMeta7 = stringAppend(tmpMeta6,_OMC_LIT174);
          tmpMeta8 = stringAppend(tmpMeta7,omc_NFExpression_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 3)))));
          tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT174);
          tmpMeta10 = stringAppend(tmpMeta9,omc_NFExpression_toString(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 4)))));
          tmpMeta11 = stringAppend(tmpMeta10,_OMC_LIT15);
          tmp1_c0 = tmpMeta11;
          tmpMeta[0+1] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_timeEvent), 5)));
          goto tmp3_done;
        }
        default:
        tmp3_default: OMC_LABEL_UNUSED; {
          
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT9, _OMC_LIT176);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _str = tmp1_c0;
  _iter = tmpMeta[0+1];

  if((!omc_NBEquation_Iterator_isEmpty(threadData, _iter)))
  {
    tmpMeta12 = stringAppend(_str,_OMC_LIT12);
    tmpMeta13 = stringAppend(tmpMeta12,omc_NBEquation_Iterator_toString(threadData, _iter));
    tmpMeta14 = stringAppend(tmpMeta13,_OMC_LIT13);
    _str = tmpMeta14;
  }

  if(_printIndex)
  {
    tmpMeta15 = stringAppend(_OMC_LIT14,intString(omc_NBEvents_TimeEvent_getIndex(threadData, _timeEvent)));
    tmpMeta16 = stringAppend(tmpMeta15,_OMC_LIT17);
    tmpMeta17 = stringAppend(tmpMeta16,_str);
    _str = tmpMeta17;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}
modelica_metatype boxptr_NBEvents_TimeEvent_toString(threadData_t *threadData, modelica_metatype _timeEvent, modelica_metatype _printIndex)
{
  modelica_integer tmp1;
  modelica_string _str = NULL;
  tmp1 = mmc_unbox_integer(_printIndex);
  _str = omc_NBEvents_TimeEvent_toString(threadData, _timeEvent, tmp1);
  /* skip box _str; String */
  return _str;
}

DLLDirection
modelica_metatype omc_NBEvents_EventInfo_convert(threadData_t *threadData, modelica_metatype _eventInfo, modelica_metatype _equation_map, modelica_metatype *out_relations, modelica_metatype *out_timeEvents)
{
  modelica_metatype _zeroCrossings = NULL;
  modelica_metatype _relations = NULL;
  modelica_metatype _timeEvents = NULL;
  modelica_metatype _tev_lst = NULL;
  modelica_metatype _cev_lst = NULL;
  modelica_metatype _sev_lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _zeroCrossings has no default value.
  // _relations has no default value.
  // _timeEvents has no default value.
  // _tev_lst has no default value.
  // _cev_lst has no default value.
  // _sev_lst has no default value.
  _tev_lst = omc_NBEvents_EventInfo_toLists(threadData, _eventInfo ,&_cev_lst ,&_sev_lst);

  {
    modelica_metatype __omcQ_24tmpVar15;
    modelica_metatype* tmp2;
    modelica_metatype tmpMeta3;
    modelica_metatype __omcQ_24tmpVar14;
    modelica_integer tmp4;
    modelica_metatype _sev_tpl_loopVar = 0;
    modelica_metatype _sev_tpl;
    _sev_tpl_loopVar = _sev_lst;
    tmpMeta3 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar15 = tmpMeta3; /* defaultValue */
    tmp2 = &__omcQ_24tmpVar15;
    while(1) {
      tmp4 = 1;
      if (!listEmpty(_sev_tpl_loopVar)) {
        _sev_tpl = MMC_CAR(_sev_tpl_loopVar);
        _sev_tpl_loopVar = MMC_CDR(_sev_tpl_loopVar);
        tmp4--;
      }
      if (tmp4 == 0) {
        __omcQ_24tmpVar14 = omc_NBEvents_StateEvent_convert(threadData, _sev_tpl, _equation_map);
        *tmp2 = mmc_mk_cons(__omcQ_24tmpVar14,0);
        tmp2 = &MMC_CDR(*tmp2);
      } else if (tmp4 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp2 = mmc_mk_nil();
    tmpMeta1 = __omcQ_24tmpVar15;
  }
  _zeroCrossings = tmpMeta1;

  _relations = _zeroCrossings;

  {
    modelica_metatype __omcQ_24tmpVar17;
    modelica_metatype* tmp6;
    modelica_metatype tmpMeta7;
    modelica_metatype __omcQ_24tmpVar16;
    modelica_integer tmp8;
    modelica_metatype _tev_loopVar = 0;
    modelica_metatype _tev;
    _tev_loopVar = _tev_lst;
    tmpMeta7 = MMC_REFSTRUCTLIT(mmc_nil);
    __omcQ_24tmpVar17 = tmpMeta7; /* defaultValue */
    tmp6 = &__omcQ_24tmpVar17;
    while(1) {
      tmp8 = 1;
      if (!listEmpty(_tev_loopVar)) {
        _tev = MMC_CAR(_tev_loopVar);
        _tev_loopVar = MMC_CDR(_tev_loopVar);
        tmp8--;
      }
      if (tmp8 == 0) {
        __omcQ_24tmpVar16 = omc_NBEvents_TimeEvent_convert(threadData, _tev);
        *tmp6 = mmc_mk_cons(__omcQ_24tmpVar16,0);
        tmp6 = &MMC_CDR(*tmp6);
      } else if (tmp8 == 1) {
        break;
      } else {
        MMC_THROW_INTERNAL();
      }
    }
    *tmp6 = mmc_mk_nil();
    tmpMeta5 = __omcQ_24tmpVar17;
  }
  _timeEvents = tmpMeta5;
  _return: OMC_LABEL_UNUSED
  if (out_relations) { *out_relations = _relations; }
  if (out_timeEvents) { *out_timeEvents = _timeEvents; }
  return _zeroCrossings;
}

DLLDirection
modelica_boolean omc_NBEvents_EventInfo_isEmpty(threadData_t *threadData, modelica_metatype _eventInfo)
{
  modelica_boolean _b;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _b has no default value.
  _b = (((omc_UnorderedSet_isEmpty(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 2)))) && omc_UnorderedMap_isEmpty(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 3))))) && omc_UnorderedMap_isEmpty(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 4))))) && (mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 5)))) == ((modelica_integer) 0)));
  _return: OMC_LABEL_UNUSED
  return _b;
}
modelica_metatype boxptr_NBEvents_EventInfo_isEmpty(threadData_t *threadData, modelica_metatype _eventInfo)
{
  modelica_boolean _b;
  modelica_metatype out_b;
  _b = omc_NBEvents_EventInfo_isEmpty(threadData, _eventInfo);
  out_b = mmc_mk_icon(_b);
  return out_b;
}

DLLDirection
modelica_metatype omc_NBEvents_EventInfo_empty(threadData_t *threadData)
{
  modelica_metatype _eventInfo = NULL;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eventInfo has no default value.
  tmpMeta1 = mmc_mk_box5(3, &NBEvents_EventInfo_EVENT__INFO__desc, omc_UnorderedSet_new(threadData, boxvar_NBEvents_TimeEvent_hash, boxvar_NBEvents_TimeEvent_isEqual, ((modelica_integer) 13)), omc_UnorderedMap_new(threadData, boxvar_NBEvents_Condition_hash, boxvar_NBEvents_Condition_isEqual, ((modelica_integer) 1)), omc_UnorderedMap_new(threadData, boxvar_NBEvents_Condition_hash, boxvar_NBEvents_Condition_isEqual, ((modelica_integer) 1)), mmc_mk_integer(((modelica_integer) 0)));
  _eventInfo = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _eventInfo;
}

static modelica_metatype closure12_NBackendDAE_lowerComponentReferenceExp(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype complete = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_NBackendDAE_lowerComponentReferenceExp(thData, $in_exp, variables, complete);
}static modelica_metatype closure11_NFSubscript_mapExp(threadData_t *thData, modelica_metatype closure, modelica_metatype subscript)
{
  modelica_fnptr func = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NFSubscript_mapExp(thData, subscript, func);
}
DLLDirection
modelica_metatype omc_NBEvents_EventInfo_createAuxStatements(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fnew_5Fstmts, modelica_metatype _bucket_ptr, modelica_metatype _variables)
{
  modelica_metatype _new_stmts = NULL;
  modelica_metatype _bucket = NULL;
  modelica_metatype _new_stmt = NULL;
  modelica_metatype _cond = NULL;
  modelica_metatype _aux = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _new_stmts = __omcQ_24in_5Fnew_5Fstmts;
  _bucket = omc_Pointer_access(threadData, _bucket_ptr);
  // _new_stmt has no default value.
  // _cond has no default value.
  // _aux has no default value.
  if(isSome((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 5)))))
  {
    {
      modelica_metatype _tpl;
      for (tmpMeta1 = omc_Util_getOption(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 5)))); !listEmpty(tmpMeta1); tmpMeta1=MMC_CDR(tmpMeta1))
      {
        _tpl = MMC_CAR(tmpMeta1);
        /* Pattern-matching assignment */
        tmpMeta2 = _tpl;
        tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 1));
        tmpMeta4 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta2), 2));
        _cond = tmpMeta3;
        _aux = tmpMeta4;

        tmpMeta6 = mmc_mk_box2(0, _variables, mmc_mk_boolean(1 /* true */));
        tmpMeta5 = mmc_mk_box1(0, (modelica_fnptr) mmc_mk_box2(0,closure12_NBackendDAE_lowerComponentReferenceExp,tmpMeta6));
        _aux = omc_NFComponentRef_mapSubscripts(threadData, _aux, (modelica_fnptr) mmc_mk_box2(0,closure11_NFSubscript_mapExp,tmpMeta5), 0 /* false */);

        _new_stmt = omc_NFStatement_makeAssignment(threadData, omc_NFExpression_fromCref(threadData, _aux, 0 /* false */), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2))), omc_NFComponentRef_getSubscriptedType(threadData, _aux, 0 /* false */), _OMC_LIT178);

        tmpMeta7 = mmc_mk_cons(_new_stmt, _new_stmts);
        _new_stmts = tmpMeta7;
      }
    }

    tmpMeta9 = MMC_TAGPTR(mmc_alloc_words(7));
    memcpy(MMC_UNTAGPTR(tmpMeta9), MMC_UNTAGPTR(_bucket), 7*sizeof(modelica_metatype));
    ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta9))[5] = mmc_mk_none();
    _bucket = tmpMeta9;

    omc_Pointer_update(threadData, _bucket_ptr, _bucket);
  }
  _return: OMC_LABEL_UNUSED
  return _new_stmts;
}

static modelica_metatype closure14_NBackendDAE_lowerComponentReferenceExp(threadData_t *thData, modelica_metatype closure, modelica_metatype $in_exp)
{
  modelica_metatype variables = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_metatype complete = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_NBackendDAE_lowerComponentReferenceExp(thData, $in_exp, variables, complete);
}static modelica_metatype closure13_NFSubscript_mapExp(threadData_t *thData, modelica_metatype closure, modelica_metatype subscript)
{
  modelica_fnptr func = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NFSubscript_mapExp(thData, subscript, func);
}
DLLDirection
modelica_metatype omc_NBEvents_EventInfo_createAux(threadData_t *threadData, modelica_metatype _cond, modelica_metatype _aux_var, modelica_metatype _variables, modelica_metatype _idx, modelica_metatype __omcQ_24in_5Fauxiliary_5Fvars, modelica_metatype __omcQ_24in_5Fauxiliary_5Feqns, modelica_metatype *out_auxiliary_eqns)
{
  modelica_metatype _auxiliary_vars = NULL;
  modelica_metatype _auxiliary_eqns = NULL;
  modelica_metatype _lhs_cref = NULL;
  modelica_metatype _aux_eqn = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _auxiliary_vars = __omcQ_24in_5Fauxiliary_5Fvars;
  _auxiliary_eqns = __omcQ_24in_5Fauxiliary_5Feqns;
  // _lhs_cref has no default value.
  // _aux_eqn has no default value.
  if((mmc_unbox_integer((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 4)))) == ((modelica_integer) 0)))
  {
    tmpMeta2 = mmc_mk_box2(0, _variables, mmc_mk_boolean(1 /* true */));
    tmpMeta1 = mmc_mk_box1(0, (modelica_fnptr) mmc_mk_box2(0,closure14_NBackendDAE_lowerComponentReferenceExp,tmpMeta2));
    _lhs_cref = omc_NFComponentRef_mapSubscripts(threadData, omc_NBVariable_getVarName(threadData, _aux_var), (modelica_fnptr) mmc_mk_box2(0,closure13_NFSubscript_mapExp,tmpMeta1), 0 /* false */);

    _aux_eqn = omc_NBEquation_Equation_makeAssignment(threadData, omc_NFExpression_fromCref(threadData, _lhs_cref, 0 /* false */), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 2))), _idx, _OMC_LIT179, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cond), 3))), omc_NBEquation_default(threadData, 2, 0 /* false */, mmc_mk_none(), mmc_mk_none()));

    tmpMeta3 = mmc_mk_cons(_aux_eqn, _auxiliary_eqns);
    _auxiliary_eqns = tmpMeta3;
  }

  omc_NBVariable_setVarName(threadData, _aux_var, omc_NFComponentRef_stripSubscriptsAll(threadData, omc_NBVariable_getVarName(threadData, _aux_var)));

  tmpMeta4 = mmc_mk_cons(_aux_var, _auxiliary_vars);
  _auxiliary_vars = tmpMeta4;
  _return: OMC_LABEL_UNUSED
  if (out_auxiliary_eqns) { *out_auxiliary_eqns = _auxiliary_eqns; }
  return _auxiliary_vars;
}

static modelica_metatype closure15_NBEquation_Equation_pointerToString(threadData_t *thData, modelica_metatype closure, modelica_metatype eqn_ptr)
{
  modelica_string $in_str = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NBEquation_Equation_pointerToString(thData, eqn_ptr, $in_str);
}
DLLDirection
modelica_metatype omc_NBEvents_EventInfo_create(threadData_t *threadData, modelica_metatype _bucket, modelica_metatype _variables, modelica_metatype _idx, modelica_metatype *out_auxiliary_vars, modelica_metatype *out_auxiliary_eqns)
{
  modelica_metatype _eventInfo = NULL;
  modelica_metatype _auxiliary_vars = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype _auxiliary_eqns = NULL;
  modelica_metatype tmpMeta2;
  modelica_metatype _cond = NULL;
  modelica_metatype _cev = NULL;
  modelica_metatype _sev = NULL;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  modelica_metatype tmpMeta14;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _eventInfo has no default value.
  tmpMeta1 = MMC_REFSTRUCTLIT(mmc_nil);
  _auxiliary_vars = tmpMeta1;
  tmpMeta2 = MMC_REFSTRUCTLIT(mmc_nil);
  _auxiliary_eqns = tmpMeta2;
  // _cond has no default value.
  // _cev has no default value.
  // _sev has no default value.
  {
    modelica_metatype _tpl;
    for (tmpMeta3 = omc_UnorderedMap_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3)))); !listEmpty(tmpMeta3); tmpMeta3=MMC_CDR(tmpMeta3))
    {
      _tpl = MMC_CAR(tmpMeta3);
      /* Pattern-matching assignment */
      tmpMeta4 = _tpl;
      tmpMeta5 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 1));
      tmpMeta6 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta4), 2));
      _cond = tmpMeta5;
      _cev = tmpMeta6;

      _auxiliary_vars = omc_NBEvents_EventInfo_createAux(threadData, _cond, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_cev), 3))), _variables, _idx, _auxiliary_vars, _auxiliary_eqns ,&_auxiliary_eqns);
    }
  }

  {
    modelica_metatype _tpl;
    for (tmpMeta8 = omc_UnorderedMap_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4)))); !listEmpty(tmpMeta8); tmpMeta8=MMC_CDR(tmpMeta8))
    {
      _tpl = MMC_CAR(tmpMeta8);
      /* Pattern-matching assignment */
      tmpMeta9 = _tpl;
      tmpMeta10 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 1));
      tmpMeta11 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta9), 2));
      _cond = tmpMeta10;
      _sev = tmpMeta11;

      _auxiliary_vars = omc_NBEvents_EventInfo_createAux(threadData, _cond, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_sev), 3))), _variables, _idx, _auxiliary_vars, _auxiliary_eqns ,&_auxiliary_eqns);
    }
  }

  tmpMeta13 = mmc_mk_box5(3, &NBEvents_EventInfo_EVENT__INFO__desc, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 3))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bucket), 4))), mmc_mk_integer(((modelica_integer) 0)));
  _eventInfo = tmpMeta13;

  if(omc_Flags_isSet(threadData, _OMC_LIT185))
  {
    fputs(MMC_STRINGDATA(omc_NBEvents_EventInfo_toString(threadData, _eventInfo)),stdout);

    tmpMeta14 = mmc_mk_box1(0, _OMC_LIT180);
    fputs(MMC_STRINGDATA(omc_List_toString(threadData, _auxiliary_eqns, (modelica_fnptr) mmc_mk_box2(0,closure15_NBEquation_Equation_pointerToString,tmpMeta14), omc_StringUtil_headline__4(threadData, _OMC_LIT181), _OMC_LIT24, _OMC_LIT22, _OMC_LIT182, 1 /* true */, ((modelica_integer) 0))),stdout);
  }
  _return: OMC_LABEL_UNUSED
  if (out_auxiliary_vars) { *out_auxiliary_vars = _auxiliary_vars; }
  if (out_auxiliary_eqns) { *out_auxiliary_eqns = _auxiliary_eqns; }
  return _eventInfo;
}

DLLDirection
modelica_metatype omc_NBEvents_EventInfo_toLists(threadData_t *threadData, modelica_metatype _eventInfo, modelica_metatype *out_cev_lst, modelica_metatype *out_sev_lst)
{
  modelica_metatype _tev_lst = NULL;
  modelica_metatype _cev_lst = NULL;
  modelica_metatype _sev_lst = NULL;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _tev_lst has no default value.
  // _cev_lst has no default value.
  // _sev_lst has no default value.
  _tev_lst = omc_List_sort(threadData, omc_UnorderedSet_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 2)))), boxvar_NBEvents_TimeEvent_indexGt);

  _cev_lst = omc_List_sort(threadData, omc_UnorderedMap_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 3)))), boxvar_NBEvents_CompositeEvent_indexGt);

  _sev_lst = omc_List_sort(threadData, omc_UnorderedMap_toList(threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_eventInfo), 4)))), boxvar_NBEvents_StateEvent_indexGt);
  _return: OMC_LABEL_UNUSED
  if (out_cev_lst) { *out_cev_lst = _cev_lst; }
  if (out_sev_lst) { *out_sev_lst = _sev_lst; }
  return _tev_lst;
}

PROTECTED_FUNCTION_STATIC modelica_string omc_NBEvents_EventInfo_toString_tplString(threadData_t *threadData, modelica_metatype _tpl, modelica_fnptr _f1, modelica_fnptr _f2)
{
  modelica_string _str = NULL;
  modelica_metatype _t1 = NULL;
  modelica_metatype _t2 = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  // _str has no default value.
  // _t1 has no default value.
  // _t2 has no default value.
  /* Pattern-matching assignment */
  tmpMeta1 = _tpl;
  tmpMeta2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 1));
  tmpMeta3 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta1), 2));
  _t1 = tmpMeta2;
  _t2 = tmpMeta3;

  tmpMeta4 = stringAppend((MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f2), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f2), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f2), 2))), _t2) : ((modelica_metatype(*)(threadData_t*, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f2), 1)))) (threadData, _t2),_OMC_LIT186);
  tmpMeta5 = stringAppend(tmpMeta4,(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f1), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f1), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f1), 2))), _t1) : ((modelica_metatype(*)(threadData_t*, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_f1), 1)))) (threadData, _t1));
  _str = tmpMeta5;
  _return: OMC_LABEL_UNUSED
  return _str;
}

static modelica_metatype closure16_NBEvents_TimeEvent_toString(threadData_t *thData, modelica_metatype closure, modelica_metatype timeEvent)
{
  modelica_metatype printIndex = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  return boxptr_NBEvents_TimeEvent_toString(thData, timeEvent, printIndex);
}static modelica_metatype closure17_NBEvents_EventInfo_toString_tplString(threadData_t *thData, modelica_metatype closure, modelica_metatype tpl)
{
  modelica_fnptr f1 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_fnptr f2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_NBEvents_EventInfo_toString_tplString(thData, tpl, f1, f2);
}static modelica_metatype closure18_NBEvents_EventInfo_toString_tplString(threadData_t *thData, modelica_metatype closure, modelica_metatype tpl)
{
  modelica_fnptr f1 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),1));
  modelica_fnptr f2 = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(closure),2));
  return boxptr_NBEvents_EventInfo_toString_tplString(thData, tpl, f1, f2);
}
DLLDirection
modelica_string omc_NBEvents_EventInfo_toString(threadData_t *threadData, modelica_metatype _eventInfo)
{
  modelica_string _str = NULL;
  modelica_metatype _tev_lst = NULL;
  modelica_metatype _cev_lst = NULL;
  modelica_metatype _sev_lst = NULL;
  modelica_metatype tmpMeta1;
  modelica_metatype tmpMeta2;
  modelica_metatype tmpMeta3;
  modelica_metatype tmpMeta4;
  modelica_metatype tmpMeta5;
  modelica_metatype tmpMeta6;
  modelica_metatype tmpMeta7;
  modelica_metatype tmpMeta8;
  modelica_metatype tmpMeta9;
  modelica_metatype tmpMeta10;
  modelica_metatype tmpMeta11;
  modelica_metatype tmpMeta12;
  modelica_metatype tmpMeta13;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _str = _OMC_LIT24;
  // _tev_lst has no default value.
  // _cev_lst has no default value.
  // _sev_lst has no default value.
  if((!omc_NBEvents_EventInfo_isEmpty(threadData, _eventInfo)))
  {
    _tev_lst = omc_NBEvents_EventInfo_toLists(threadData, _eventInfo ,&_cev_lst ,&_sev_lst);

    tmpMeta1 = stringAppend(omc_StringUtil_headline__2(threadData, _OMC_LIT187),_OMC_LIT22);
    _str = tmpMeta1;

    tmpMeta2 = stringAppend(_str,omc_StringUtil_headline__4(threadData, _OMC_LIT170));
    tmpMeta3 = mmc_mk_box1(0, mmc_mk_boolean(1 /* true */));
    tmpMeta4 = stringAppend(tmpMeta2,omc_List_toString(threadData, _tev_lst, (modelica_fnptr) mmc_mk_box2(0,closure16_NBEvents_TimeEvent_toString,tmpMeta3), _OMC_LIT24, _OMC_LIT24, _OMC_LIT22, _OMC_LIT24, 1 /* true */, ((modelica_integer) 0)));
    tmpMeta5 = stringAppend(tmpMeta4,_OMC_LIT182);
    _str = tmpMeta5;

    tmpMeta6 = stringAppend(_str,omc_StringUtil_headline__4(threadData, _OMC_LIT188));
    tmpMeta7 = mmc_mk_box2(0, boxvar_NBEvents_Condition_toString, boxvar_NBEvents_CompositeEvent_toString);
    tmpMeta8 = stringAppend(tmpMeta6,omc_List_toString(threadData, _cev_lst, (modelica_fnptr) mmc_mk_box2(0,closure17_NBEvents_EventInfo_toString_tplString,tmpMeta7), _OMC_LIT24, _OMC_LIT24, _OMC_LIT22, _OMC_LIT24, 1 /* true */, ((modelica_integer) 0)));
    tmpMeta9 = stringAppend(tmpMeta8,_OMC_LIT182);
    _str = tmpMeta9;

    tmpMeta10 = stringAppend(_str,omc_StringUtil_headline__4(threadData, _OMC_LIT21));
    tmpMeta11 = mmc_mk_box2(0, boxvar_NBEvents_Condition_toString, boxvar_NBEvents_StateEvent_toString);
    tmpMeta12 = stringAppend(tmpMeta10,omc_List_toString(threadData, _sev_lst, (modelica_fnptr) mmc_mk_box2(0,closure18_NBEvents_EventInfo_toString_tplString,tmpMeta11), _OMC_LIT24, _OMC_LIT24, _OMC_LIT22, _OMC_LIT24, 1 /* true */, ((modelica_integer) 0)));
    tmpMeta13 = stringAppend(tmpMeta12,_OMC_LIT182);
    _str = tmpMeta13;
  }
  _return: OMC_LABEL_UNUSED
  return _str;
}

DLLDirection
modelica_fnptr omc_NBEvents_getModule(threadData_t *threadData)
{
  modelica_fnptr _func;
  modelica_string _flag = NULL;
  modelica_fnptr tmp1 = 0;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _flag = _OMC_LIT105;
  { /* match expression */
    modelica_string tmp4_1;
    tmp4_1 = _flag;
    {
      volatile mmc_switch_type tmp4;
      int tmp5;
      tmp4 = 0;
      for (; tmp4 < 1; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          if (7 != MMC_STRLEN(tmp4_1) || strcmp(MMC_STRINGDATA(_OMC_LIT105), MMC_STRINGDATA(tmp4_1)) != 0) goto tmp3_end;
          /* Pattern matching succeeded */
          tmp1 = boxvar_NBEvents_eventsDefault;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _func = (modelica_fnptr) tmp1;
  _return: OMC_LABEL_UNUSED
  return _func;
}

DLLDirection
modelica_metatype omc_NBEvents_main(threadData_t *threadData, modelica_metatype __omcQ_24in_5Fbdae)
{
  modelica_metatype _bdae = NULL;
  modelica_fnptr _func;
  modelica_metatype tmpMeta1;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _bdae = __omcQ_24in_5Fbdae;
  _func = (modelica_fnptr) omc_NBEvents_getModule(threadData);

  { /* match expression */
    modelica_metatype tmp4_1;
    tmp4_1 = _bdae;
    {
      modelica_metatype _varData = NULL;
      modelica_metatype _eqData = NULL;
      modelica_metatype _eventInfo = NULL;
      volatile mmc_switch_type tmp4;
      int tmp5;
      // _varData has no default value.
      // _eqData has no default value.
      // _eventInfo has no default value.
      tmp4 = 0;
      for (; tmp4 < 2; tmp4++) {
        switch (MMC_SWITCH_CAST(tmp4)) {
        case 0: {
          modelica_metatype tmpMeta6;
          modelica_metatype tmpMeta7;
          modelica_metatype tmpMeta8;
          if (mmc__uniontype__metarecord__typedef__equal(tmp4_1,0,13) == 0) goto tmp3_end;
          
          /* Pattern matching succeeded */
          _varData = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))) ? ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 2))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 14))) ,&_eqData ,&_eventInfo) : ((modelica_metatype(*)(threadData_t*, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_func), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 10))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 11))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 12))), (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_bdae), 14))) ,&_eqData ,&_eventInfo);

          tmpMeta6 = MMC_TAGPTR(mmc_alloc_words(15));
          memcpy(MMC_UNTAGPTR(tmpMeta6), MMC_UNTAGPTR(_bdae), 15*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta6))[10] = _varData;
          _bdae = tmpMeta6;

          tmpMeta7 = MMC_TAGPTR(mmc_alloc_words(15));
          memcpy(MMC_UNTAGPTR(tmpMeta7), MMC_UNTAGPTR(_bdae), 15*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta7))[11] = _eqData;
          _bdae = tmpMeta7;

          tmpMeta8 = MMC_TAGPTR(mmc_alloc_words(15));
          memcpy(MMC_UNTAGPTR(tmpMeta8), MMC_UNTAGPTR(_bdae), 15*sizeof(modelica_metatype));
          ((modelica_metatype*)MMC_UNTAGPTR(tmpMeta8))[12] = _eventInfo;
          _bdae = tmpMeta8;
          tmpMeta1 = _bdae;
          goto tmp3_done;
        }
        case 1: {
          
          /* Pattern matching succeeded */
          omc_Error_addMessage(threadData, _OMC_LIT9, _OMC_LIT190);
          goto goto_2;
          goto tmp3_done;
        }
        }
        goto tmp3_end;
        tmp3_end: ;
      }
      goto goto_2;
      goto_2:;
      MMC_THROW_INTERNAL();
      goto tmp3_done;
      tmp3_done:;
    }
  }
  _bdae = tmpMeta1;
  _return: OMC_LABEL_UNUSED
  return _bdae;
}

