decompiled_code:
__int64 __fastcall Packet_EncodeBit(__int64 *a1)
{
__int64 v1; // rdx
__int64 result; // rax
__int64 v3; // rdx

v1 = a1[1];
if ( v1 == 1 )
{
v3 = *a1;
switch ( *a1 )
{
case 3LL:
NationalValues_EncodeBit();
result = 1LL;
break;
case 5LL:
Linking_EncodeBit();
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_EncodeBit();
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_EncodeBit();
result = 1LL;
break;
case 16LL:
RepositioningInformation_EncodeBit();
result = 1LL;
break;
case 21LL:
GradientProfile_EncodeBit();
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_EncodeBit();
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_EncodeBit();
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_EncodeBit();
result = 1LL;
break;
case 42LL:
SessionManagement_EncodeBit();
result = 1LL;
break;
case 44LL:
LABEL_10:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit();
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_EncodeBit();
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_EncodeBit();
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_EncodeBit();
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_EncodeBit();
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_EncodeBit();
result = 1LL;
break;
case 58LL:
PositionReportParameters_EncodeBit();
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_EncodeBit();
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_EncodeBit();
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_EncodeBit();
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_EncodeBit();
result = 1LL;
break;
case 68LL:
TrackCondition_EncodeBit();
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_EncodeBit();
result = 1LL;
break;
case 71LL:
AdhesionFactor_EncodeBit();
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_EncodeBit();
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_EncodeBit();
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_EncodeBit();
result = 1LL;
break;
case 80LL:
ModeProfile_EncodeBit();
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_EncodeBit();
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_EncodeBit();
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_EncodeBit();
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_EncodeBit();
result = 1LL;
break;
case 134LL:
EOLMPacket_EncodeBit();
result = 1LL;
break;
case 136LL:
InfillLocationReference_EncodeBit();
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_EncodeBit();
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_EncodeBit();
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_EncodeBit();
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_EncodeBit();
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_EncodeBit();
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_EncodeBit();
result = 1LL;
break;
default:
LABEL_9:
fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", v3);
result = 0LL;
break;
}
}
else if ( v1 == 2 )
{
if ( *a1 != 255 )
_assert_fail("header->NID_PACKET == 255", "Packet_EncodeBit.c", 0x153u, "Packet_EncodeBit");
EndOfInformation_EncodeBit();
result = 1LL;
}
else if ( v1 )
{
fprintf(stderr, "Packet_EncodeBit: unexpected value for header->list = %lu\n", v1);
result = 0LL;
}
else
{
v3 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_EncodeBit();
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_EncodeBit();
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_EncodeBit();
result = 1LL;
break;
case 4LL:
ErrorReporting_EncodeBit();
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_EncodeBit();
result = 1LL;
break;
case 11LL:
ValidatedTrainData_EncodeBit();
result = 1LL;
break;
case 44LL:
goto LABEL_10;
default:
goto LABEL_9;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v1; // rdx
__int64 result; // rax
__int64 v3; // rdx

v1 = a1[1];
if ( v1 == 1 )
{
v3 = *a1;
switch ( *a1 )
{
case 3LL:
NationalValues_EncodeBit();
result = 1LL;
break;
case 5LL:
Linking_EncodeBit();
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_EncodeBit();
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_EncodeBit();
result = 1LL;
break;
case 16LL:
RepositioningInformation_EncodeBit();
result = 1LL;
break;
case 21LL:
GradientProfile_EncodeBit();
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_EncodeBit();
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_EncodeBit();
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_EncodeBit();
result = 1LL;
break;
case 42LL:
SessionManagement_EncodeBit();
result = 1LL;
break;
case 44LL:
LABEL_10:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit();
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_EncodeBit();
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_EncodeBit();
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_EncodeBit();
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_EncodeBit();
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_EncodeBit();
result = 1LL;
break;
case 58LL:
PositionReportParameters_EncodeBit();
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_EncodeBit();
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_EncodeBit();
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_EncodeBit();
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_EncodeBit();
result = 1LL;
break;
case 68LL:
TrackCondition_EncodeBit();
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_EncodeBit();
result = 1LL;
break;
case 71LL:
AdhesionFactor_EncodeBit();
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_EncodeBit();
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_EncodeBit();
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_EncodeBit();
result = 1LL;
break;
case 80LL:
ModeProfile_EncodeBit();
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_EncodeBit();
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_EncodeBit();
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_EncodeBit();
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_EncodeBit();
result = 1LL;
break;
case 134LL:
EOLMPacket_EncodeBit();
result = 1LL;
break;
case 136LL:
InfillLocationReference_EncodeBit();
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_EncodeBit();
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_EncodeBit();
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_EncodeBit();
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_EncodeBit();
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_EncodeBit();
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_EncodeBit();
result = 1LL;
break;
default:
LABEL_9:
fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", v3);
result = 0LL;
break;
}
}
else if ( v1 == 2 )
{
if ( *a1 != 255 )
_assert_fail("header->NID_PACKET == 255", "Packet_EncodeBit.c", 0x153u, "Packet_EncodeBit");
EndOfInformation_EncodeBit();
result = 1LL;
}
else if ( v1 )
{
fprintf(stderr, "Packet_EncodeBit: unexpected value for header->list = %lu\n", v1);
result = 0LL;
}
else
{
v3 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_EncodeBit();
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_EncodeBit();
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_EncodeBit();
result = 1LL;
break;
case 4LL:
ErrorReporting_EncodeBit();
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_EncodeBit();
result = 1LL;
break;
case 11LL:
ValidatedTrainData_EncodeBit();
result = 1LL;
break;
case 44LL:
goto LABEL_10;
default:
goto LABEL_9;
}
}
return result;
}

original_code:
int Packet_EncodeBit(const PacketHeader* header, Bitstream* stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_EncodeBit((const PositionReport*)(header), stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_EncodeBit((const PositionReportBasedOnTwoBaliseGroups*)(header), stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_EncodeBit((const OnboardTelephoneNumbers*)(header), stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_EncodeBit((const ErrorReporting*)(header), stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_EncodeBit((const Level23TransitionInformation*)(header), stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_EncodeBit((const ValidatedTrainData*)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit((const DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_EncodeBit((const NationalValues*)(header), stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_EncodeBit((const Linking*)(header), stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_EncodeBit((const Level1MovementAuthority*)(header), stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_EncodeBit((const Level23MovementAuthority*)(header), stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_EncodeBit((const RepositioningInformation*)(header), stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_EncodeBit((const GradientProfile*)(header), stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_EncodeBit((const InternationalStaticSpeedProfile*)(header), stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_EncodeBit((const TrackConditionChangeOfTractionPower*)(header), stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_EncodeBit((const LevelTransitionOrder*)(header), stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_EncodeBit((const SessionManagement*)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit((const DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_EncodeBit((const RadioNetworkRegistration*)(header), stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_EncodeBit((const ConditionalLevelTransitionOrder*)(header), stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_EncodeBit((const ListOfBalisesForSHArea*)(header), stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_EncodeBit((const AxleLoadSpeedProfile*)(header), stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_EncodeBit((const MovementAuthorityRequestParameters*)(header), stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_EncodeBit((const PositionReportParameters*)(header), stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_EncodeBit((const ListOfBalisesInSRAuthority*)(header), stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_EncodeBit((const TemporarySpeedRestriction*)(header), stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_EncodeBit((const TemporarySpeedRestrictionRevocation*)(header), stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_EncodeBit((const TrackConditionBigMetalMasses*)(header), stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_EncodeBit((const TrackCondition*)(header), stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_EncodeBit((const RouteSuitabilityData*)(header), stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_EncodeBit((const AdhesionFactor*)(header), stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_EncodeBit((const PacketForSendingPlainTextMessages*)(header), stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_EncodeBit((const PacketForSendingFixedTextMessages*)(header), stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_EncodeBit((const GeographicalPositionInformation*)(header), stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_EncodeBit((const ModeProfile*)(header), stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_EncodeBit((const TrackAheadFreeUpToLevel23TransitionLocation*)(header), stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_EncodeBit((const RBCTransitionOrder*)(header), stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_EncodeBit((const DangerForShuntingInformation*)(header), stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_EncodeBit((const RadioInfillAreaInformation*)(header), stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_EncodeBit((const EOLMPacket*)(header), stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_EncodeBit((const InfillLocationReference*)(header), stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_EncodeBit((const StopIfInStaffResponsible*)(header), stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_EncodeBit((const ReversingAreaInformation*)(header), stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_EncodeBit((const ReversingSupervisionInformation*)(header), stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_EncodeBit((const TrainRunningNumberFromRBC*)(header), stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_EncodeBit((const DefaultGradientForTemporarySpeedRestriction*)(header), stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_EncodeBit((const DefaultBaliseLoopOrRIUInformation*)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 2 :
        {
            ((header->NID_PACKET == 255) ? (void) (0) : __assert_fail ("header->NID_PACKET == 255", "Packet_EncodeBit.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_EncodeBit((const EndOfInformation*)header, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_EncodeBit: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

canonical_original_code:
int Packet_EncodeBit(struct PacketHeader *header, struct Bitstream *stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_EncodeBit((struct PositionReport *)(header), stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_EncodeBit((struct PositionReportBasedOnTwoBaliseGroups *)(header), stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_EncodeBit((struct OnboardTelephoneNumbers *)(header), stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_EncodeBit((struct ErrorReporting *)(header), stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_EncodeBit((struct Level23TransitionInformation *)(header), stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_EncodeBit((struct ValidatedTrainData *)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_EncodeBit((struct NationalValues *)(header), stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_EncodeBit((struct Linking *)(header), stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_EncodeBit((struct Level1MovementAuthority *)(header), stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_EncodeBit((struct Level23MovementAuthority *)(header), stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_EncodeBit((struct RepositioningInformation *)(header), stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_EncodeBit((struct GradientProfile *)(header), stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_EncodeBit((struct InternationalStaticSpeedProfile *)(header), stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_EncodeBit((struct TrackConditionChangeOfTractionPower *)(header), stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_EncodeBit((struct LevelTransitionOrder *)(header), stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_EncodeBit((struct SessionManagement *)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeBit((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_EncodeBit((struct RadioNetworkRegistration *)(header), stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_EncodeBit((struct ConditionalLevelTransitionOrder *)(header), stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_EncodeBit((struct ListOfBalisesForSHArea *)(header), stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_EncodeBit((struct AxleLoadSpeedProfile *)(header), stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_EncodeBit((struct MovementAuthorityRequestParameters *)(header), stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_EncodeBit((struct PositionReportParameters *)(header), stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_EncodeBit((struct ListOfBalisesInSRAuthority *)(header), stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_EncodeBit((struct TemporarySpeedRestriction *)(header), stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_EncodeBit((struct TemporarySpeedRestrictionRevocation *)(header), stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_EncodeBit((struct TrackConditionBigMetalMasses *)(header), stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_EncodeBit((struct TrackCondition *)(header), stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_EncodeBit((struct RouteSuitabilityData *)(header), stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_EncodeBit((struct AdhesionFactor *)(header), stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_EncodeBit((struct PacketForSendingPlainTextMessages *)(header), stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_EncodeBit((struct PacketForSendingFixedTextMessages *)(header), stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_EncodeBit((struct GeographicalPositionInformation *)(header), stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_EncodeBit((struct ModeProfile *)(header), stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_EncodeBit((struct TrackAheadFreeUpToLevel23TransitionLocation *)(header), stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_EncodeBit((struct RBCTransitionOrder *)(header), stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_EncodeBit((struct DangerForShuntingInformation *)(header), stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_EncodeBit((struct RadioInfillAreaInformation *)(header), stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_EncodeBit((struct EOLMPacket *)(header), stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_EncodeBit((struct InfillLocationReference *)(header), stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_EncodeBit((struct StopIfInStaffResponsible *)(header), stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_EncodeBit((struct ReversingAreaInformation *)(header), stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_EncodeBit((struct ReversingSupervisionInformation *)(header), stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_EncodeBit((struct TrainRunningNumberFromRBC *)(header), stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_EncodeBit((struct DefaultGradientForTemporarySpeedRestriction *)(header), stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_EncodeBit((struct DefaultBaliseLoopOrRIUInformation *)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 2 :
        {
            ((header->NID_PACKET == 255) ? (void) (0) : __assert_fail ("header->NID_PACKET == 255", "Packet_EncodeBit.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_EncodeBit((struct EndOfInformation *)header, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_EncodeBit: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

variable_types: struct Bitstream { unsigned char *addr; unsigned int size; unsigned int bitpos; } *

user_defined_types: struct PositionReport { struct PacketHeader header; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_LRBG; unsigned long D_LRBG; unsigned long Q_DIRLRBG; unsigned long Q_DLRBG; unsigned long L_DOUBTOVER; unsigned long L_DOUBTUNDER; unsigned long Q_LENGTH; unsigned long L_TRAININT; unsigned long V_TRAIN; unsigned long Q_DIRTRAIN; unsigned long M_MODE; unsigned long M_LEVEL; unsigned long NID_STM; }

user_defined_types: struct PositionReportBasedOnTwoBaliseGroups { struct PacketHeader header; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_LRBG; unsigned long NID_PRVLRBG; unsigned long D_LRBG; unsigned long Q_DIRLRBG; unsigned long Q_DLRBG; unsigned long L_DOUBTOVER; unsigned long L_DOUBTUNDER; unsigned long Q_LENGTH; unsigned long L_TRAININT; unsigned long V_TRAIN; unsigned long Q_DIRTRAIN; unsigned long M_MODE; unsigned long M_LEVEL; unsigned long NID_STM; }

user_defined_types: struct OnboardTelephoneNumbers { struct PacketHeader header; unsigned long L_PACKET; unsigned long N_ITER_1; struct OnboardTelephoneNumbers_1 sub_1[31]; }

user_defined_types: struct Level23TransitionInformation { struct PacketHeader header; unsigned long L_PACKET; unsigned long NID_LTRBG; }

user_defined_types: struct ValidatedTrainData { struct PacketHeader header; unsigned long L_PACKET; unsigned long NID_OPERATIONAL; unsigned long NC_TRAIN; unsigned long L_TRAIN; unsigned long V_MAXTRAIN; unsigned long M_LOADINGGAUGE; unsigned long M_AXLELOAD; unsigned long M_AIRTIGHT; unsigned long N_ITER_1; struct ValidatedTrainData_1 sub_1[31]; unsigned long N_ITER_2; struct ValidatedTrainData_2 sub_2[31]; }

user_defined_types: struct DataUsedByApplicationsOutsideTheERTMSETCSSystem { struct PacketHeader header; unsigned long L_PACKET; unsigned long NID_XUSER; unsigned long Other_data_depending_on__NID_XUSER; }

user_defined_types: struct NationalValues { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_VALIDNV; unsigned long N_ITER_1; struct NationalValues_1 sub_1[31]; unsigned long V_NVSHUNT; unsigned long V_NVSTFF; unsigned long V_NVONSIGHT; unsigned long V_NVUNFIT; unsigned long V_NVREL; unsigned long D_NVROLL; unsigned long Q_NVSRBKTRG; unsigned long Q_NVEMRRLS; unsigned long V_NVALLOWOVTRP; unsigned long V_NVSUPOVTRP; unsigned long D_NVOVTRP; unsigned long T_NVOVTRP; unsigned long D_NVPOTRP; unsigned long M_NVCONTACT; unsigned long T_NVCONTACT; unsigned long M_NVDERUN; unsigned long D_NVSTFF; unsigned long Q_NVDRIVER_ADHES; }

user_defined_types: struct Linking { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; unsigned long N_ITER_1; struct Linking_1 sub_1[31]; }

user_defined_types: struct Level1MovementAuthority { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long V_MAIN; unsigned long V_LOA; unsigned long T_LOA; unsigned long N_ITER_1; struct Level1MovementAuthority_1 sub_1[31]; unsigned long L_ENDSECTION; unsigned long Q_SECTIONTIMER; unsigned long T_SECTIONTIMER; unsigned long D_SECTIONTIMERSTOPLOC; unsigned long Q_ENDTIMER; unsigned long T_ENDTIMER; unsigned long D_ENDTIMERSTARTLOC; unsigned long Q_DANGERPOINT; unsigned long D_DP; unsigned long V_RELEASEDP; unsigned long Q_OVERLAP; unsigned long D_STARTOL; unsigned long T_OL; unsigned long D_OL; unsigned long V_RELEASEOL; }

user_defined_types: struct Level23MovementAuthority { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long V_LOA; unsigned long T_LOA; unsigned long N_ITER_1; struct Level23MovementAuthority_1 sub_1[31]; unsigned long L_ENDSECTION; unsigned long Q_SECTIONTIMER; unsigned long T_SECTIONTIMER; unsigned long D_SECTIONTIMERSTOPLOC; unsigned long Q_ENDTIMER; unsigned long T_ENDTIMER; unsigned long D_ENDTIMERSTARTLOC; unsigned long Q_DANGERPOINT; unsigned long D_DP; unsigned long V_RELEASEDP; unsigned long Q_OVERLAP; unsigned long D_STARTOL; unsigned long T_OL; unsigned long D_OL; unsigned long V_RELEASEOL; }

user_defined_types: struct RepositioningInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long L_SECTION; }

user_defined_types: struct GradientProfile { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_GRADIENT; unsigned long Q_GDIR; unsigned long G_A; unsigned long N_ITER_1; struct GradientProfile_1 sub_1[31]; }

user_defined_types: struct InternationalStaticSpeedProfile { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_STATIC; unsigned long V_STATIC; unsigned long Q_FRONT; unsigned long N_ITER_1; struct InternationalStaticSpeedProfile_1 sub_1[31]; unsigned long N_ITER_2; struct InternationalStaticSpeedProfile_2 sub_2[31]; }

user_defined_types: struct TrackConditionChangeOfTractionPower { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_TRACTION; unsigned long M_TRACTION; }

user_defined_types: struct LevelTransitionOrder { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_LEVELTR; unsigned long M_LEVELTR; unsigned long NID_STM; unsigned long L_ACKLEVELTR; unsigned long N_ITER_1; struct LevelTransitionOrder_1 sub_1[31]; }

user_defined_types: struct SessionManagement { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_RBC; unsigned long NID_C; unsigned long NID_RBC; unsigned long NID_RADIO; unsigned long Q_SLEEPSESSION; }

user_defined_types: struct RadioNetworkRegistration { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_MN; }

user_defined_types: struct ConditionalLevelTransitionOrder { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long M_LEVELTR; unsigned long NID_STM; unsigned long N_ITER_1; struct ConditionalLevelTransitionOrder_1 sub_1[31]; }

user_defined_types: struct ListOfBalisesForSHArea { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long N_ITER_1; struct ListOfBalisesForSHArea_1 sub_1[31]; }

user_defined_types: struct AxleLoadSpeedProfile { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_TRACKINIT; unsigned long D_AXLELOAD; unsigned long L_AXLELOAD; unsigned long Q_FRONT; unsigned long N_ITER_1; struct AxleLoadSpeedProfile_1 sub_1[31]; unsigned long N_ITER_2; struct AxleLoadSpeedProfile_2 sub_2[31]; }

user_defined_types: struct MovementAuthorityRequestParameters { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long T_MAR; unsigned long T_TIMEOUTRQST; unsigned long T_CYCRQST; }

user_defined_types: struct PositionReportParameters { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long T_CYCLOC; unsigned long D_CYCLOC; unsigned long M_LOC; unsigned long N_ITER_1; struct PositionReportParameters_1 sub_1[31]; }

user_defined_types: struct ListOfBalisesInSRAuthority { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long N_ITER_1; struct ListOfBalisesInSRAuthority_1 sub_1[31]; }

user_defined_types: struct TemporarySpeedRestriction { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_TSR; unsigned long D_TSR; unsigned long L_TSR; unsigned long Q_FRONT; unsigned long V_TSR; }

user_defined_types: struct TemporarySpeedRestrictionRevocation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_TSR; }

user_defined_types: struct TrackConditionBigMetalMasses { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; unsigned long N_ITER_1; struct TrackConditionBigMetalMasses_1 sub_1[31]; }

user_defined_types: struct TrackCondition { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_TRACKINIT; unsigned long D_TRACKINIT; unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; unsigned long M_TRACKCOND; unsigned long N_ITER_1; struct TrackCondition_1 sub_1[31]; }

user_defined_types: struct RouteSuitabilityData { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_TRACKINIT; unsigned long D_TRACKINIT; unsigned long D_SUITABILITY; unsigned long Q_SUITABILITY; unsigned long M_LOADINGGAUGE; unsigned long M_AXLELOAD; unsigned long M_TRACTION; unsigned long N_ITER_1; struct RouteSuitabilityData_1 sub_1[31]; }

user_defined_types: struct AdhesionFactor { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_ADHESION; unsigned long L_ADHESION; unsigned long M_ADHESION; }

user_defined_types: struct PacketForSendingPlainTextMessages { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_TEXTCLASS; unsigned long Q_TEXTDISPLAY; unsigned long D_TEXTDISPLAY; unsigned long M_MODETEXTDISPLAY_0; unsigned long M_LEVELTEXTDISPLAY_0; unsigned long NID_STM_0; unsigned long L_TEXTDISPLAY; unsigned long T_TEXTDISPLAY; unsigned long M_MODETEXTDISPLAY_1; unsigned long M_LEVELTEXTDISPLAY_1; unsigned long NID_STM_1; unsigned long Q_TEXTCONFIRM; unsigned long L_TEXT; unsigned long X_TEXT; }

user_defined_types: struct PacketForSendingFixedTextMessages { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_TEXTCLASS; unsigned long Q_TEXTDISPLAY; unsigned long D_TEXTDISPLAY; unsigned long M_MODETEXTDISPLAY_0; unsigned long M_LEVELTEXTDISPLAY_0; unsigned long NID_STM_0; unsigned long L_TEXTDISPLAY; unsigned long T_TEXTDISPLAY; unsigned long M_MODETEXTDISPLAY_1; unsigned long M_LEVELTEXTDISPLAY_1; unsigned long NID_STM_1; unsigned long Q_TEXTCONFIRM; unsigned long Q_TEXT; }

user_defined_types: struct GeographicalPositionInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long D_POSOFF; unsigned long Q_MPOSITION; unsigned long M_POSITION; unsigned long N_ITER_1; struct GeographicalPositionInformation_1 sub_1[31]; }

user_defined_types: struct ModeProfile { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_MAMODE; unsigned long M_MAMODE; unsigned long V_MAMODE; unsigned long L_MAMODE; unsigned long L_ACKMAMODE; unsigned long N_ITER_1; struct ModeProfile_1 sub_1[31]; }

user_defined_types: struct TrackAheadFreeUpToLevel23TransitionLocation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; }

user_defined_types: struct RBCTransitionOrder { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_RBCTR; unsigned long NID_C; unsigned long NID_RBC; unsigned long NID_RADIO; unsigned long Q_SLEEPSESSION; }

user_defined_types: struct DangerForShuntingInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_ASPECT; }

user_defined_types: struct RadioInfillAreaInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long Q_RIU; unsigned long NID_C_0; unsigned long NID_RIU; unsigned long NID_RADIO; unsigned long D_INFILL; unsigned long NID_C_1; unsigned long NID_BG; }

user_defined_types: struct EOLMPacket { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_LOOP; unsigned long D_LOOP; unsigned long L_LOOP; unsigned long Q_LOOPDIR; unsigned long Q_SSCODE; }

user_defined_types: struct InfillLocationReference { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; }

user_defined_types: struct StopIfInStaffResponsible { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SRSTOP; }

user_defined_types: struct ReversingAreaInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_STARTREVERSE; unsigned long L_REVERSEAREA; }

user_defined_types: struct ReversingSupervisionInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_REVERSE; unsigned long V_REVERSE; }

user_defined_types: struct TrainRunningNumberFromRBC { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_OPERATIONAL; }

user_defined_types: struct DefaultGradientForTemporarySpeedRestriction { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_GDIR; unsigned long G_TSR; }

user_defined_types: struct DefaultBaliseLoopOrRIUInformation { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; }

user_defined_types: struct EndOfInformation { struct PacketHeader header; }

user_defined_types: struct OnboardTelephoneNumbers_1 { unsigned long NID_RADIO; }

user_defined_types: struct ValidatedTrainData_1 { unsigned long M_TRACTION; }

user_defined_types: struct ValidatedTrainData_2 { unsigned long NID_STM; }

user_defined_types: struct NationalValues_1 { unsigned long NID_C; }

user_defined_types: struct Linking_1 { unsigned long D_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; }

user_defined_types: struct Level1MovementAuthority_1 { unsigned long L_SECTION; unsigned long Q_SECTIONTIMER; unsigned long T_SECTIONTIMER; unsigned long D_SECTIONTIMERSTOPLOC; }

user_defined_types: struct Level23MovementAuthority_1 { unsigned long L_SECTION; unsigned long Q_SECTIONTIMER; unsigned long T_SECTIONTIMER; unsigned long D_SECTIONTIMERSTOPLOC; }

user_defined_types: struct GradientProfile_1 { unsigned long D_GRADIENT; unsigned long Q_GDIR; unsigned long G_A; }

user_defined_types: struct InternationalStaticSpeedProfile_1 { unsigned long NC_DIFF; unsigned long V_DIFF; }

user_defined_types: struct InternationalStaticSpeedProfile_2_1 { unsigned long NC_DIFF; unsigned long V_DIFF; }


repo: openETCS/dataDictionary

decompiled_code:
_BOOL8 __fastcall PacketHeader_Equal(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

original_code:
static inline int PacketHeader_Equal(const PacketHeader* a, const PacketHeader* b)
{
    return (a->NID_PACKET == b->NID_PACKET) && (a->list == b->list);
}

canonical_original_code:
static inline int PacketHeader_Equal(struct PacketHeader *a, struct PacketHeader *b)
{
    return (a->NID_PACKET == b->NID_PACKET) && (a->list == b->list);
}

variable_types: struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } *

variable_types:
b
struct PacketHeader *

return_type: int


decompiled_code:
_BOOL8 __fastcall TemporarySpeedRestriction_Equal(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax

result = PacketHeader_Equal(a1, a2);
if ( result )
{
result = 0LL;
if ( a1[2] == a2[2]
&& a1[3] == a2[3]
&& a1[4] == a2[4]
&& a1[5] == a2[5]
&& a1[6] == a2[6]
&& a1[7] == a2[7]
&& a1[8] == a2[8] )
{
result = a1[9] == a2[9];
}
}
return result;
}

original_code:
static inline int TemporarySpeedRestriction_Equal(const TemporarySpeedRestriction* a, const TemporarySpeedRestriction* b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->Q_DIR == b->Q_DIR);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->Q_SCALE == b->Q_SCALE);
    status = status && (a->NID_TSR == b->NID_TSR);
    status = status && (a->D_TSR == b->D_TSR);
    status = status && (a->L_TSR == b->L_TSR);
    status = status && (a->Q_FRONT == b->Q_FRONT);
    status = status && (a->V_TSR == b->V_TSR);
    return status;
}

canonical_original_code:
static inline int TemporarySpeedRestriction_Equal(struct TemporarySpeedRestriction *a, struct TemporarySpeedRestriction *b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->Q_DIR == b->Q_DIR);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->Q_SCALE == b->Q_SCALE);
    status = status && (a->NID_TSR == b->NID_TSR);
    status = status && (a->D_TSR == b->D_TSR);
    status = status && (a->L_TSR == b->L_TSR);
    status = status && (a->Q_FRONT == b->Q_FRONT);
    status = status && (a->V_TSR == b->V_TSR);
    return status;
}

variable_types: struct TemporarySpeedRestriction { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_TSR; unsigned long D_TSR; unsigned long L_TSR; unsigned long Q_FRONT; unsigned long V_TSR; } *

variable_types:
b
struct TemporarySpeedRestriction *

variable_types: status int

user_defined_types: struct TemporarySpeedRestriction { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_TSR; unsigned long D_TSR; unsigned long L_TSR; unsigned long Q_FRONT; unsigned long V_TSR; }


decompiled_code:
int TemporarySpeedRestriction_Tests()
{
__int64 *v0; // rbp
__int64 v2[10]; // [rsp+0h] [rbp-A8h] BYREF
_QWORD v3[11]; // [rsp+50h] [rbp-58h] BYREF

puts("\nstart TemporarySpeedRestriction_Tests");
TemporarySpeedRestriction_Init(v2);
TemporarySpeedRestriction_Print(v2, stdout);
putchar(10);
TemporarySpeedRestriction_Init(v3);
if ( !TemporarySpeedRestriction_Equal(v2, v3) )
_assert_fail(
"TemporarySpeedRestriction_Equal(&a, &b)",
"TemporarySpeedRestriction_Tests.c",
0x25u,
"TemporarySpeedRestriction_Tests");
v3[6] = 2LL;
if ( TemporarySpeedRestriction_Equal(v2, v3) )
_assert_fail(
"!TemporarySpeedRestriction_Equal(&a, &b)",
"TemporarySpeedRestriction_Tests.c",
0x28u,
"TemporarySpeedRestriction_Tests");
v0 = (__int64 *)PacketFactory_TrackToTrain(65LL, 1LL);
TemporarySpeedRestriction_Print(v0, stdout);
putchar(10);
if ( !TemporarySpeedRestriction_Equal(v2, v0) )
_assert_fail(
"TemporarySpeedRestriction_Equal(&a, p)",
"TemporarySpeedRestriction_Tests.c",
0x2Fu,
"TemporarySpeedRestriction_Tests");
TemporarySpeedRestriction_Delete(v0);
return puts("end TemporarySpeedRestriction_Test");
}

canonical_decompiled_code:
int func5()
{
__int64 *v0; // rbp
__int64 v2[10]; // [rsp+0h] [rbp-A8h] BYREF
_QWORD v3[11]; // [rsp+50h] [rbp-58h] BYREF

puts("\nstart TemporarySpeedRestriction_Tests");
func1(v2);
func4(v2, stdout);
putchar(10);
func1(v3);
if ( !func2(v2, v3) )
_assert_fail(
"TemporarySpeedRestriction_Equal(&a, &b)",
"TemporarySpeedRestriction_Tests.c",
0x25u,
"TemporarySpeedRestriction_Tests");
v3[6] = 2LL;
if ( func2(v2, v3) )
_assert_fail(
"!TemporarySpeedRestriction_Equal(&a, &b)",
"TemporarySpeedRestriction_Tests.c",
0x28u,
"TemporarySpeedRestriction_Tests");
v0 = (__int64 *)PacketFactory_TrackToTrain(65LL, 1LL);
func4(v0, stdout);
putchar(10);
if ( !func2(v2, v0) )
_assert_fail(
"TemporarySpeedRestriction_Equal(&a, p)",
"TemporarySpeedRestriction_Tests.c",
0x2Fu,
"TemporarySpeedRestriction_Tests");
TemporarySpeedRestriction_Delete(v0);
return puts("end TemporarySpeedRestriction_Test");
}

original_code:
void TemporarySpeedRestriction_Tests(void)
{
    printf("\nstart TemporarySpeedRestriction_Tests\n");
    TemporarySpeedRestriction a;
    TemporarySpeedRestriction_Init(&a);
    TemporarySpeedRestriction_Print(&a, stdout);
    printf("\n");
    TemporarySpeedRestriction b;
    TemporarySpeedRestriction_Init(&b);
    ((TemporarySpeedRestriction_Equal(&a, &b)) ? (void) (0) : __assert_fail ("TemporarySpeedRestriction_Equal(&a, &b)", "TemporarySpeedRestriction_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    b.D_TSR = 2;
    ((!TemporarySpeedRestriction_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!TemporarySpeedRestriction_Equal(&a, &b)", "TemporarySpeedRestriction_Tests.c", 40, __extension__ __PRETTY_FUNCTION__));
    PacketHeader header = {65, 1};
    PacketHeader* base = PacketFactory_TrackToTrain(header);
    TemporarySpeedRestriction* p = (TemporarySpeedRestriction*)(base);
    TemporarySpeedRestriction_Print(p, stdout);
    printf("\n");
    ((TemporarySpeedRestriction_Equal(&a, p)) ? (void) (0) : __assert_fail ("TemporarySpeedRestriction_Equal(&a, p)", "TemporarySpeedRestriction_Tests.c", 47, __extension__ __PRETTY_FUNCTION__));
    TemporarySpeedRestriction_Delete(p);
    printf("end TemporarySpeedRestriction_Test\n");
}

canonical_original_code:
void TemporarySpeedRestriction_Tests()
{
    printf("\nstart TemporarySpeedRestriction_Tests\n");
    struct TemporarySpeedRestriction a;
    TemporarySpeedRestriction_Init(&a);
    TemporarySpeedRestriction_Print(&a, stdout);
    printf("\n");
    struct TemporarySpeedRestriction b;
    TemporarySpeedRestriction_Init(&b);
    ((TemporarySpeedRestriction_Equal(&a, &b)) ? (void) (0) : __assert_fail ("TemporarySpeedRestriction_Equal(&a, &b)", "TemporarySpeedRestriction_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    b.D_TSR = 2;
    ((!TemporarySpeedRestriction_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!TemporarySpeedRestriction_Equal(&a, &b)", "TemporarySpeedRestriction_Tests.c", 40, __extension__ __PRETTY_FUNCTION__));
    struct PacketHeader header = {65, 1};
    struct PacketHeader *base = PacketFactory_TrackToTrain(header);
    struct TemporarySpeedRestriction *p = (TemporarySpeedRestriction*)(base);
    TemporarySpeedRestriction_Print(p, stdout);
    printf("\n");
    ((TemporarySpeedRestriction_Equal(&a, p)) ? (void) (0) : __assert_fail ("TemporarySpeedRestriction_Equal(&a, p)", "TemporarySpeedRestriction_Tests.c", 47, __extension__ __PRETTY_FUNCTION__));
    TemporarySpeedRestriction_Delete(p);
    printf("end TemporarySpeedRestriction_Test\n");
}

variable_types: struct TemporarySpeedRestriction { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long NID_TSR; unsigned long D_TSR; unsigned long L_TSR; unsigned long Q_FRONT; unsigned long V_TSR; }

return_type: void


decompiled_code:
_BOOL8 __fastcall UpperBitsNotSet64(unsigned __int64 a1, char a2)
{
return 1LL << a2 > a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int64 a1, char a2)
{
return 1LL << a2 > a1;
}

original_code:
static inline int UpperBitsNotSet64(uint64_t value, uint32_t length)
{
    if (length == 64)
    {
        return 1;
    }
    else
    {
        const uint64_t MaxValue = ((uint64_t) 1) << length;
        return value < MaxValue;
    }
}

canonical_original_code:
static inline int UpperBitsNotSet64(unsigned long value, unsigned int length)
{
    if (length == 64)
    {
        return 1;
    }
    else
    {
        unsigned long MaxValue = ((uint64_t) 1) << length;
        return value < MaxValue;
    }
}

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long


decompiled_code:
_BOOL8 __fastcall TelegramHeader_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx

result = UpperBitsNotSet64(*a1, 1);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 8), 7);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 16), 1);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v4 + 24), 3);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v5 + 32), 3);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v6 + 40), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v7 + 48), 8);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v8 + 56), 10);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v9 + 64), 14);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v10 + 72), 1);
}
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(unsigned __int64 *a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx

result = func0(*a1, 1);
if ( result )
{
result = func0(*(_QWORD *)(v2 + 8), 7);
if ( result )
{
result = func0(*(_QWORD *)(v3 + 16), 1);
if ( result )
{
result = func0(*(_QWORD *)(v4 + 24), 3);
if ( result )
{
result = func0(*(_QWORD *)(v5 + 32), 3);
if ( result )
{
result = func0(*(_QWORD *)(v6 + 40), 2);
if ( result )
{
result = func0(*(_QWORD *)(v7 + 48), 8);
if ( result )
{
result = func0(*(_QWORD *)(v8 + 56), 10);
if ( result )
{
result = func0(*(_QWORD *)(v9 + 64), 14);
if ( result )
result = func0(*(_QWORD *)(v10 + 72), 1);
}
}
}
}
}
}
}
}
return result;
}

original_code:
static inline
int TelegramHeader_UpperBitsNotSet(const TelegramHeader* p)
{
    if (UpperBitsNotSet64(p->Q_UPDOWN, 1) &&
        UpperBitsNotSet64(p->M_VERSION, 7) &&
        UpperBitsNotSet64(p->Q_MEDIA, 1) &&
        UpperBitsNotSet64(p->N_PIG, 3) &&
        UpperBitsNotSet64(p->N_TOTAL, 3) &&
        UpperBitsNotSet64(p->M_DUP, 2) &&
        UpperBitsNotSet64(p->M_MCOUNT, 8) &&
        UpperBitsNotSet64(p->NID_C, 10) &&
        UpperBitsNotSet64(p->NID_BG, 14) &&
        UpperBitsNotSet64(p->Q_LINK, 1))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
static inline int TelegramHeader_UpperBitsNotSet(struct TelegramHeader *p)
{
    if (UpperBitsNotSet64(p->Q_UPDOWN, 1) &&
        UpperBitsNotSet64(p->M_VERSION, 7) &&
        UpperBitsNotSet64(p->Q_MEDIA, 1) &&
        UpperBitsNotSet64(p->N_PIG, 3) &&
        UpperBitsNotSet64(p->N_TOTAL, 3) &&
        UpperBitsNotSet64(p->M_DUP, 2) &&
        UpperBitsNotSet64(p->M_MCOUNT, 8) &&
        UpperBitsNotSet64(p->NID_C, 10) &&
        UpperBitsNotSet64(p->NID_BG, 14) &&
        UpperBitsNotSet64(p->Q_LINK, 1))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct TelegramHeader { unsigned long Q_UPDOWN; unsigned long M_VERSION; unsigned long Q_MEDIA; unsigned long N_PIG; unsigned long N_TOTAL; unsigned long M_DUP; unsigned long M_MCOUNT; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINK; } *


decompiled_code:
__int64 __fastcall PacketSequence_Add(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = *(unsigned int *)(a1 + 400);
if ( (unsigned int)result > 0x31 )
_assert_fail("s->size < 50", "..//Telegram/PacketSequence.h", 0x2Au, "PacketSequence_Add");
*(_DWORD *)(a1 + 400) = result + 1;
*(_QWORD *)(a1 + 8 * result) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = *(unsigned int *)(a1 + 400);
if ( (unsigned int)result > 0x31 )
_assert_fail("s->size < 50", "..//Telegram/PacketSequence.h", 0x2Au, "PacketSequence_Add");
*(_DWORD *)(a1 + 400) = result + 1;
*(_QWORD *)(a1 + 8 * result) = a2;
return result;
}

original_code:
static inline void PacketSequence_Add(PacketSequence* s, PacketHeader* h)
{
    ((s->size < 50) ? (void) (0) : __assert_fail ("s->size < 50", "..//Telegram/PacketSequence.h", 42, __extension__ __PRETTY_FUNCTION__));
    s->header[s->size++] = h;
}

canonical_original_code:
static inline void PacketSequence_Add(struct PacketSequence *s, struct PacketHeader *h)
{
    ((s->size < 50) ? (void) (0) : __assert_fail ("s->size < 50", "..//Telegram/PacketSequence.h", 42, __extension__ __PRETTY_FUNCTION__));
    s->header[s->size++] = h;
}

variable_types: struct PacketSequence { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } *header[50]; unsigned int size; } *

variable_types:
h
struct PacketHeader *

user_defined_types: struct PacketSequence { struct PacketHeader *header[50]; unsigned int size; }


decompiled_code:
__int64 __fastcall EurobaliseTelegram_Add(__int64 a1, __int64 a2)
{
return PacketSequence_Add(a1 + 80, a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
return func5(a1 + 80, a2);
}

original_code:
static inline void EurobaliseTelegram_Add(EurobaliseTelegram* t, PacketHeader* p)
{
    PacketSequence_Add(&t->packets, p);
}

canonical_original_code:
static inline void EurobaliseTelegram_Add(struct EurobaliseTelegram *t, struct PacketHeader *p)
{
    PacketSequence_Add(&t->packets, p);
}

variable_types: struct EurobaliseTelegram { struct TelegramHeader { unsigned long Q_UPDOWN; unsigned long M_VERSION; unsigned long Q_MEDIA; unsigned long N_PIG; unsigned long N_TOTAL; unsigned long M_DUP; unsigned long M_MCOUNT; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINK; } header; struct PacketSequence { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } *header[50]; unsigned int size; } packets; } *

variable_types:
p
struct PacketHeader *

user_defined_types: struct EurobaliseTelegram { struct TelegramHeader header; struct PacketSequence packets; }


decompiled_code:
__int64 __fastcall PacketSequence_Get(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 400);
if ( v2 > 0x31 )
_assert_fail("s->size < 50", "..//Telegram/PacketSequence.h", 0x30u, "PacketSequence_Get");
if ( v2 <= a2 )
_assert_fail("i < s->size", "..//Telegram/PacketSequence.h", 0x31u, "PacketSequence_Get");
return *(_QWORD *)(a1 + 8LL * a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 400);
if ( v2 > 0x31 )
_assert_fail("s->size < 50", "..//Telegram/PacketSequence.h", 0x30u, "PacketSequence_Get");
if ( v2 <= a2 )
_assert_fail("i < s->size", "..//Telegram/PacketSequence.h", 0x31u, "PacketSequence_Get");
return *(_QWORD *)(a1 + 8LL * a2);
}

original_code:
static inline const PacketHeader* PacketSequence_Get(const PacketSequence* s, uint32_t i)
{
    ((s->size < 50) ? (void) (0) : __assert_fail ("s->size < 50", "..//Telegram/PacketSequence.h", 48, __extension__ __PRETTY_FUNCTION__));
    ((i < s->size) ? (void) (0) : __assert_fail ("i < s->size", "..//Telegram/PacketSequence.h", 49, __extension__ __PRETTY_FUNCTION__));
    return s->header[i];
}

canonical_original_code:
static inline struct PacketHeader *PacketSequence_Get(struct PacketSequence *s, unsigned int i)
{
    ((s->size < 50) ? (void) (0) : __assert_fail ("s->size < 50", "..//Telegram/PacketSequence.h", 48, __extension__ __PRETTY_FUNCTION__));
    ((i < s->size) ? (void) (0) : __assert_fail ("i < s->size", "..//Telegram/PacketSequence.h", 49, __extension__ __PRETTY_FUNCTION__));
    return s->header[i];
}

variable_types: struct PacketSequence { struct PacketHeader *header[50]; unsigned int size; } *

variable_types:
i
unsigned int

return_type: struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } *


decompiled_code:
__int64 __fastcall EurobaliseTelegram_Get(__int64 a1, unsigned int a2)
{
return PacketSequence_Get(a1 + 80, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2)
{
return func7(a1 + 80, a2);
}

original_code:
static inline const PacketHeader* EurobaliseTelegram_Get(const EurobaliseTelegram* t, uint32_t i)
{
    return PacketSequence_Get(&t->packets, i);
}

canonical_original_code:
static inline struct PacketHeader *EurobaliseTelegram_Get(struct EurobaliseTelegram *t, unsigned int i)
{
    return PacketSequence_Get(&t->packets, i);
}

variable_types: struct EurobaliseTelegram { struct TelegramHeader { unsigned long Q_UPDOWN; unsigned long M_VERSION; unsigned long Q_MEDIA; unsigned long N_PIG; unsigned long N_TOTAL; unsigned long M_DUP; unsigned long M_MCOUNT; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINK; } header; struct PacketSequence { struct PacketHeader *header[50]; unsigned int size; } packets; } *

user_defined_types: struct PacketHeader { unsigned long NID_PACKET; unsigned long list; }


decompiled_code:
__int64 __fastcall EurobaliseTelegram_Init(_QWORD *a1)
{
TelegramHeader_Init(a1);
return PacketSequence_Init(a1 + 10);
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD *a1)
{
func3(a1);
return PacketSequence_Init(a1 + 10);
}

original_code:
static inline void EurobaliseTelegram_Init(EurobaliseTelegram* t)
{
    TelegramHeader_Init(&t->header);
    PacketSequence_Init(&t->packets);
}

canonical_original_code:
static inline void EurobaliseTelegram_Init(struct EurobaliseTelegram *t)
{
    TelegramHeader_Init(&t->header);
    PacketSequence_Init(&t->packets);
}

user_defined_types: struct TelegramHeader { unsigned long Q_UPDOWN; unsigned long M_VERSION; unsigned long Q_MEDIA; unsigned long N_PIG; unsigned long N_TOTAL; unsigned long M_DUP; unsigned long M_MCOUNT; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINK; }