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

v1 = a1[1];
if ( v1 == 1 )
{
v3 = *a1;
switch ( *a1 )
{
case 3LL:
NationalValues_DecodeBit();
result = 1LL;
break;
case 5LL:
Linking_DecodeBit();
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_DecodeBit();
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_DecodeBit();
result = 1LL;
break;
case 16LL:
RepositioningInformation_DecodeBit();
result = 1LL;
break;
case 21LL:
GradientProfile_DecodeBit();
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_DecodeBit();
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_DecodeBit();
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_DecodeBit();
result = 1LL;
break;
case 42LL:
SessionManagement_DecodeBit();
result = 1LL;
break;
case 44LL:
LABEL_12:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit();
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_DecodeBit();
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_DecodeBit();
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_DecodeBit();
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_DecodeBit();
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_DecodeBit();
result = 1LL;
break;
case 58LL:
PositionReportParameters_DecodeBit();
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_DecodeBit();
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_DecodeBit();
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_DecodeBit();
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_DecodeBit();
result = 1LL;
break;
case 68LL:
TrackCondition_DecodeBit();
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_DecodeBit();
result = 1LL;
break;
case 71LL:
AdhesionFactor_DecodeBit();
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_DecodeBit();
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_DecodeBit();
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_DecodeBit();
result = 1LL;
break;
case 80LL:
ModeProfile_DecodeBit();
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_DecodeBit();
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_DecodeBit();
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_DecodeBit();
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_DecodeBit();
result = 1LL;
break;
case 134LL:
EOLMPacket_DecodeBit();
result = 1LL;
break;
case 136LL:
InfillLocationReference_DecodeBit();
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_DecodeBit();
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_DecodeBit();
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_DecodeBit();
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_DecodeBit();
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_DecodeBit();
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_DecodeBit();
result = 1LL;
break;
default:
LABEL_13:
fprintf(stderr, "Packet_DecodeBit: 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_DecodeBit.c", 0x153u, "Packet_DecodeBit");
EndOfInformation_DecodeBit();
result = 1LL;
}
else if ( v1 )
{
fprintf(stderr, "Packet_DecodeBit: unexpected value for header->list = %lu\n", v1);
result = 0LL;
}
else
{
v3 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_DecodeBit();
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_DecodeBit();
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_DecodeBit();
result = 1LL;
break;
case 4LL:
ErrorReporting_DecodeBit();
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_DecodeBit();
result = 1LL;
break;
case 11LL:
ValidatedTrainData_DecodeBit();
result = 1LL;
break;
case 44LL:
goto LABEL_12;
default:
goto LABEL_13;
}
}
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_DecodeBit();
result = 1LL;
break;
case 5LL:
Linking_DecodeBit();
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_DecodeBit();
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_DecodeBit();
result = 1LL;
break;
case 16LL:
RepositioningInformation_DecodeBit();
result = 1LL;
break;
case 21LL:
GradientProfile_DecodeBit();
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_DecodeBit();
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_DecodeBit();
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_DecodeBit();
result = 1LL;
break;
case 42LL:
SessionManagement_DecodeBit();
result = 1LL;
break;
case 44LL:
LABEL_12:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit();
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_DecodeBit();
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_DecodeBit();
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_DecodeBit();
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_DecodeBit();
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_DecodeBit();
result = 1LL;
break;
case 58LL:
PositionReportParameters_DecodeBit();
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_DecodeBit();
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_DecodeBit();
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_DecodeBit();
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_DecodeBit();
result = 1LL;
break;
case 68LL:
TrackCondition_DecodeBit();
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_DecodeBit();
result = 1LL;
break;
case 71LL:
AdhesionFactor_DecodeBit();
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_DecodeBit();
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_DecodeBit();
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_DecodeBit();
result = 1LL;
break;
case 80LL:
ModeProfile_DecodeBit();
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_DecodeBit();
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_DecodeBit();
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_DecodeBit();
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_DecodeBit();
result = 1LL;
break;
case 134LL:
EOLMPacket_DecodeBit();
result = 1LL;
break;
case 136LL:
InfillLocationReference_DecodeBit();
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_DecodeBit();
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_DecodeBit();
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_DecodeBit();
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_DecodeBit();
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_DecodeBit();
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_DecodeBit();
result = 1LL;
break;
default:
LABEL_13:
fprintf(stderr, "Packet_DecodeBit: 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_DecodeBit.c", 0x153u, "Packet_DecodeBit");
EndOfInformation_DecodeBit();
result = 1LL;
}
else if ( v1 )
{
fprintf(stderr, "Packet_DecodeBit: unexpected value for header->list = %lu\n", v1);
result = 0LL;
}
else
{
v3 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_DecodeBit();
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_DecodeBit();
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_DecodeBit();
result = 1LL;
break;
case 4LL:
ErrorReporting_DecodeBit();
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_DecodeBit();
result = 1LL;
break;
case 11LL:
ValidatedTrainData_DecodeBit();
result = 1LL;
break;
case 44LL:
goto LABEL_12;
default:
goto LABEL_13;
}
}
return result;
}

original_code:
int Packet_DecodeBit(PacketHeader* header, Bitstream* stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_DecodeBit((PositionReport*)(header), stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_DecodeBit((PositionReportBasedOnTwoBaliseGroups*)(header), stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_DecodeBit((OnboardTelephoneNumbers*)(header), stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_DecodeBit((ErrorReporting*)(header), stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_DecodeBit((Level23TransitionInformation*)(header), stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_DecodeBit((ValidatedTrainData*)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit((DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_DecodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_DecodeBit((NationalValues*)(header), stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_DecodeBit((Linking*)(header), stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_DecodeBit((Level1MovementAuthority*)(header), stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_DecodeBit((Level23MovementAuthority*)(header), stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_DecodeBit((RepositioningInformation*)(header), stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_DecodeBit((GradientProfile*)(header), stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_DecodeBit((InternationalStaticSpeedProfile*)(header), stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_DecodeBit((TrackConditionChangeOfTractionPower*)(header), stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_DecodeBit((LevelTransitionOrder*)(header), stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_DecodeBit((SessionManagement*)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit((DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_DecodeBit((RadioNetworkRegistration*)(header), stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_DecodeBit((ConditionalLevelTransitionOrder*)(header), stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_DecodeBit((ListOfBalisesForSHArea*)(header), stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_DecodeBit((AxleLoadSpeedProfile*)(header), stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_DecodeBit((MovementAuthorityRequestParameters*)(header), stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_DecodeBit((PositionReportParameters*)(header), stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_DecodeBit((ListOfBalisesInSRAuthority*)(header), stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_DecodeBit((TemporarySpeedRestriction*)(header), stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_DecodeBit((TemporarySpeedRestrictionRevocation*)(header), stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_DecodeBit((TrackConditionBigMetalMasses*)(header), stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_DecodeBit((TrackCondition*)(header), stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_DecodeBit((RouteSuitabilityData*)(header), stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_DecodeBit((AdhesionFactor*)(header), stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_DecodeBit((PacketForSendingPlainTextMessages*)(header), stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_DecodeBit((PacketForSendingFixedTextMessages*)(header), stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_DecodeBit((GeographicalPositionInformation*)(header), stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_DecodeBit((ModeProfile*)(header), stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_DecodeBit((TrackAheadFreeUpToLevel23TransitionLocation*)(header), stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_DecodeBit((RBCTransitionOrder*)(header), stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_DecodeBit((DangerForShuntingInformation*)(header), stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_DecodeBit((RadioInfillAreaInformation*)(header), stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_DecodeBit((EOLMPacket*)(header), stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_DecodeBit((InfillLocationReference*)(header), stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_DecodeBit((StopIfInStaffResponsible*)(header), stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_DecodeBit((ReversingAreaInformation*)(header), stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_DecodeBit((ReversingSupervisionInformation*)(header), stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_DecodeBit((TrainRunningNumberFromRBC*)(header), stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_DecodeBit((DefaultGradientForTemporarySpeedRestriction*)(header), stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_DecodeBit((DefaultBaliseLoopOrRIUInformation*)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_DecodeBit: 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_DecodeBit.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_DecodeBit((EndOfInformation*)header, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_DecodeBit: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

canonical_original_code:
int Packet_DecodeBit(struct PacketHeader *header, struct Bitstream *stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_DecodeBit((struct PositionReport *)(header), stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_DecodeBit((struct PositionReportBasedOnTwoBaliseGroups *)(header), stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_DecodeBit((struct OnboardTelephoneNumbers *)(header), stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_DecodeBit((struct ErrorReporting *)(header), stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_DecodeBit((struct Level23TransitionInformation *)(header), stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_DecodeBit((struct ValidatedTrainData *)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_DecodeBit: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_DecodeBit((struct NationalValues *)(header), stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_DecodeBit((struct Linking *)(header), stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_DecodeBit((struct Level1MovementAuthority *)(header), stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_DecodeBit((struct Level23MovementAuthority *)(header), stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_DecodeBit((struct RepositioningInformation *)(header), stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_DecodeBit((struct GradientProfile *)(header), stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_DecodeBit((struct InternationalStaticSpeedProfile *)(header), stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_DecodeBit((struct TrackConditionChangeOfTractionPower *)(header), stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_DecodeBit((struct LevelTransitionOrder *)(header), stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_DecodeBit((struct SessionManagement *)(header), stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_DecodeBit((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_DecodeBit((struct RadioNetworkRegistration *)(header), stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_DecodeBit((struct ConditionalLevelTransitionOrder *)(header), stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_DecodeBit((struct ListOfBalisesForSHArea *)(header), stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_DecodeBit((struct AxleLoadSpeedProfile *)(header), stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_DecodeBit((struct MovementAuthorityRequestParameters *)(header), stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_DecodeBit((struct PositionReportParameters *)(header), stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_DecodeBit((struct ListOfBalisesInSRAuthority *)(header), stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_DecodeBit((struct TemporarySpeedRestriction *)(header), stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_DecodeBit((struct TemporarySpeedRestrictionRevocation *)(header), stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_DecodeBit((struct TrackConditionBigMetalMasses *)(header), stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_DecodeBit((struct TrackCondition *)(header), stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_DecodeBit((struct RouteSuitabilityData *)(header), stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_DecodeBit((struct AdhesionFactor *)(header), stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_DecodeBit((struct PacketForSendingPlainTextMessages *)(header), stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_DecodeBit((struct PacketForSendingFixedTextMessages *)(header), stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_DecodeBit((struct GeographicalPositionInformation *)(header), stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_DecodeBit((struct ModeProfile *)(header), stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_DecodeBit((struct TrackAheadFreeUpToLevel23TransitionLocation *)(header), stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_DecodeBit((struct RBCTransitionOrder *)(header), stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_DecodeBit((struct DangerForShuntingInformation *)(header), stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_DecodeBit((struct RadioInfillAreaInformation *)(header), stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_DecodeBit((struct EOLMPacket *)(header), stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_DecodeBit((struct InfillLocationReference *)(header), stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_DecodeBit((struct StopIfInStaffResponsible *)(header), stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_DecodeBit((struct ReversingAreaInformation *)(header), stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_DecodeBit((struct ReversingSupervisionInformation *)(header), stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_DecodeBit((struct TrainRunningNumberFromRBC *)(header), stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_DecodeBit((struct DefaultGradientForTemporarySpeedRestriction *)(header), stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_DecodeBit((struct DefaultBaliseLoopOrRIUInformation *)(header), stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_DecodeBit: 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_DecodeBit.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_DecodeBit((struct EndOfInformation *)header, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_DecodeBit: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

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

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 ErrorReporting { struct PacketHeader header; unsigned long L_PACKET; unsigned long M_ERROR; }

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 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 { unsigned long D_STATIC; unsigned long V_STATIC; unsigned long Q_FRONT; unsigned long N_ITER_2_1; struct InternationalStaticSpeedProfile_2_1 sub_2_1[31]; }

user_defined_types: struct LevelTransitionOrder_1 { unsigned long M_LEVELTR; unsigned long NID_STM; unsigned long L_ACKLEVELTR; }

user_defined_types: struct RouteSuitabilityData_1 { unsigned long D_SUITABILITY; unsigned long Q_SUITABILITY; unsigned long M_LOADINGGAUGE; unsigned long M_AXLELOAD; unsigned long M_TRACTION; }


repo: openETCS/dataDictionary

decompiled_code:
_BOOL8 __fastcall UpperBitsNotSet64(unsigned __int64 a1, int a2)
{
_BOOL8 result; // rax

result = 1LL;
if ( a2 != 64 )
result = 1LL << a2 > a1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int64 a1, int a2)
{
_BOOL8 result; // rax

result = 1LL;
if ( a2 != 64 )
result = 1LL << a2 > a1;
return result;
}

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

return_type: int


decompiled_code:
_BOOL8 __fastcall PacketForSendingFixedTextMessages_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL8 result; // rax
unsigned __int64 v2; // rbp

result = UpperBitsNotSet64(a1[2], 2);
if ( !result )
{
if ( a1[9] != 1 )
return result;
LABEL_15:
if ( !result )
return result;
result = UpperBitsNotSet64(a1[10], 8);
if ( !result )
return result;
goto LABEL_20;
}
if ( UpperBitsNotSet64(a1[3], 13)
&& UpperBitsNotSet64(a1[4], 2)
&& UpperBitsNotSet64(a1[5], 2)
&& UpperBitsNotSet64(a1[6], 1) )
{
result = UpperBitsNotSet64(a1[7], 15);
if ( result )
{
result = UpperBitsNotSet64(a1[8], 4);
if ( result )
result = UpperBitsNotSet64(a1[9], 3);
}
if ( a1[9] == 1 )
goto LABEL_15;
}
else
{
result = 0LL;
if ( a1[9] == 1 )
return result;
}
if ( !result )
return result;
LABEL_20:
result = UpperBitsNotSet64(a1[11], 15);
if ( result )
{
result = UpperBitsNotSet64(a1[12], 10);
if ( result )
{
result = UpperBitsNotSet64(a1[13], 4);
if ( result )
{
v2 = a1[14];
result = UpperBitsNotSet64(v2, 3);
if ( v2 == 1 )
{
if ( !result )
return result;
result = UpperBitsNotSet64(a1[15], 8);
if ( !result )
return result;
}
else if ( !result )
{
return result;
}
result = UpperBitsNotSet64(a1[16], 2);
if ( result )
result = UpperBitsNotSet64(a1[17], 8);
return result;
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(unsigned __int64 *a1)
{
_BOOL8 result; // rax
unsigned __int64 v2; // rbp

result = func0(a1[2], 2);
if ( !result )
{
if ( a1[9] != 1 )
return result;
LABEL_15:
if ( !result )
return result;
result = func0(a1[10], 8);
if ( !result )
return result;
goto LABEL_20;
}
if ( func0(a1[3], 13)
&& func0(a1[4], 2)
&& func0(a1[5], 2)
&& func0(a1[6], 1) )
{
result = func0(a1[7], 15);
if ( result )
{
result = func0(a1[8], 4);
if ( result )
result = func0(a1[9], 3);
}
if ( a1[9] == 1 )
goto LABEL_15;
}
else
{
result = 0LL;
if ( a1[9] == 1 )
return result;
}
if ( !result )
return result;
LABEL_20:
result = func0(a1[11], 15);
if ( result )
{
result = func0(a1[12], 10);
if ( result )
{
result = func0(a1[13], 4);
if ( result )
{
v2 = a1[14];
result = func0(v2, 3);
if ( v2 == 1 )
{
if ( !result )
return result;
result = func0(a1[15], 8);
if ( !result )
return result;
}
else if ( !result )
{
return result;
}
result = func0(a1[16], 2);
if ( result )
result = func0(a1[17], 8);
return result;
}
}
}
return result;
}

original_code:
int PacketForSendingFixedTextMessages_UpperBitsNotSet(const PacketForSendingFixedTextMessages* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXTCLASS, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXTDISPLAY, 1) ;
    status = status && UpperBitsNotSet64(p->D_TEXTDISPLAY, 15);
    status = status && UpperBitsNotSet64(p->M_MODETEXTDISPLAY_0, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVELTEXTDISPLAY_0, 3) ;
    if (p->M_LEVELTEXTDISPLAY_0 == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM_0, 8) ;
    }
    status = status && UpperBitsNotSet64(p->L_TEXTDISPLAY, 15);
    status = status && UpperBitsNotSet64(p->T_TEXTDISPLAY, 10);
    status = status && UpperBitsNotSet64(p->M_MODETEXTDISPLAY_1, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVELTEXTDISPLAY_1, 3) ;
    if (p->M_LEVELTEXTDISPLAY_1 == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM_1, 8) ;
    }
    status = status && UpperBitsNotSet64(p->Q_TEXTCONFIRM, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXT, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int PacketForSendingFixedTextMessages_UpperBitsNotSet(struct PacketForSendingFixedTextMessages *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXTCLASS, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXTDISPLAY, 1) ;
    status = status && UpperBitsNotSet64(p->D_TEXTDISPLAY, 15);
    status = status && UpperBitsNotSet64(p->M_MODETEXTDISPLAY_0, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVELTEXTDISPLAY_0, 3) ;
    if (p->M_LEVELTEXTDISPLAY_0 == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM_0, 8) ;
    }
    status = status && UpperBitsNotSet64(p->L_TEXTDISPLAY, 15);
    status = status && UpperBitsNotSet64(p->T_TEXTDISPLAY, 10);
    status = status && UpperBitsNotSet64(p->M_MODETEXTDISPLAY_1, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVELTEXTDISPLAY_1, 3) ;
    if (p->M_LEVELTEXTDISPLAY_1 == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM_1, 8) ;
    }
    status = status && UpperBitsNotSet64(p->Q_TEXTCONFIRM, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TEXT, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct PacketForSendingFixedTextMessages { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } 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; } *

variable_types: status int

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; }


decompiled_code:
__int64 __fastcall PacketForSendingFixedTextMessages_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 84LL) )
return 0xFFFFFFFFLL;
if ( !PacketForSendingFixedTextMessages_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 2LL, a1[4]);
Bitstream_Write(a2, 2LL, a1[5]);
Bitstream_Write(a2, 1LL, a1[6]);
Bitstream_Write(a2, 15LL, a1[7]);
Bitstream_Write(a2, 4LL, a1[8]);
Bitstream_Write(a2, 3LL, a1[9]);
if ( a1[9] == 1 )
Bitstream_Write(a2, 8LL, a1[10]);
Bitstream_Write(a2, 15LL, a1[11]);
Bitstream_Write(a2, 10LL, a1[12]);
Bitstream_Write(a2, 4LL, a1[13]);
Bitstream_Write(a2, 3LL, a1[14]);
if ( a1[14] == 1 )
Bitstream_Write(a2, 8LL, a1[15]);
Bitstream_Write(a2, 2LL, a1[16]);
Bitstream_Write(a2, 8LL, a1[17]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 84LL) )
return 0xFFFFFFFFLL;
if ( !func2(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 2LL, a1[4]);
Bitstream_Write(a2, 2LL, a1[5]);
Bitstream_Write(a2, 1LL, a1[6]);
Bitstream_Write(a2, 15LL, a1[7]);
Bitstream_Write(a2, 4LL, a1[8]);
Bitstream_Write(a2, 3LL, a1[9]);
if ( a1[9] == 1 )
Bitstream_Write(a2, 8LL, a1[10]);
Bitstream_Write(a2, 15LL, a1[11]);
Bitstream_Write(a2, 10LL, a1[12]);
Bitstream_Write(a2, 4LL, a1[13]);
Bitstream_Write(a2, 3LL, a1[14]);
if ( a1[14] == 1 )
Bitstream_Write(a2, 8LL, a1[15]);
Bitstream_Write(a2, 2LL, a1[16]);
Bitstream_Write(a2, 8LL, a1[17]);
return 1LL;
}

original_code:
int PacketForSendingFixedTextMessages_EncodeBit(const PacketForSendingFixedTextMessages* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 84))
    {
        if (PacketForSendingFixedTextMessages_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 2, p->Q_TEXTCLASS);
            Bitstream_Write(stream, 1, p->Q_TEXTDISPLAY);
            Bitstream_Write(stream, 15, p->D_TEXTDISPLAY);
            Bitstream_Write(stream, 4, p->M_MODETEXTDISPLAY_0);
            Bitstream_Write(stream, 3, p->M_LEVELTEXTDISPLAY_0);
            if (p->M_LEVELTEXTDISPLAY_0 == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM_0);
            }
            Bitstream_Write(stream, 15, p->L_TEXTDISPLAY);
            Bitstream_Write(stream, 10, p->T_TEXTDISPLAY);
            Bitstream_Write(stream, 4, p->M_MODETEXTDISPLAY_1);
            Bitstream_Write(stream, 3, p->M_LEVELTEXTDISPLAY_1);
            if (p->M_LEVELTEXTDISPLAY_1 == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM_1);
            }
            Bitstream_Write(stream, 2, p->Q_TEXTCONFIRM);
            Bitstream_Write(stream, 8, p->Q_TEXT);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int PacketForSendingFixedTextMessages_EncodeBit(struct PacketForSendingFixedTextMessages *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 84))
    {
        if (PacketForSendingFixedTextMessages_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 2, p->Q_TEXTCLASS);
            Bitstream_Write(stream, 1, p->Q_TEXTDISPLAY);
            Bitstream_Write(stream, 15, p->D_TEXTDISPLAY);
            Bitstream_Write(stream, 4, p->M_MODETEXTDISPLAY_0);
            Bitstream_Write(stream, 3, p->M_LEVELTEXTDISPLAY_0);
            if (p->M_LEVELTEXTDISPLAY_0 == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM_0);
            }
            Bitstream_Write(stream, 15, p->L_TEXTDISPLAY);
            Bitstream_Write(stream, 10, p->T_TEXTDISPLAY);
            Bitstream_Write(stream, 4, p->M_MODETEXTDISPLAY_1);
            Bitstream_Write(stream, 3, p->M_LEVELTEXTDISPLAY_1);
            if (p->M_LEVELTEXTDISPLAY_1 == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM_1);
            }
            Bitstream_Write(stream, 2, p->Q_TEXTCONFIRM);
            Bitstream_Write(stream, 8, p->Q_TEXT);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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

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


decompiled_code:
__int64 __fastcall PacketForSendingFixedTextMessages_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax

result = Bitstream_Normal(a2, 84LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 2LL);
a1[6] = Bitstream_Read(a2, 1LL);
a1[7] = Bitstream_Read(a2, 15LL);
a1[8] = Bitstream_Read(a2, 4LL);
v3 = Bitstream_Read(a2, 3LL);
a1[9] = v3;
if ( v3 == 1 )
a1[10] = Bitstream_Read(a2, 8LL);
a1[11] = Bitstream_Read(a2, 15LL);
a1[12] = Bitstream_Read(a2, 10LL);
a1[13] = Bitstream_Read(a2, 4LL);
v4 = Bitstream_Read(a2, 3LL);
a1[14] = v4;
if ( v4 == 1 )
a1[15] = Bitstream_Read(a2, 8LL);
a1[16] = Bitstream_Read(a2, 2LL);
a1[17] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax

result = Bitstream_Normal(a2, 84LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 2LL);
a1[6] = Bitstream_Read(a2, 1LL);
a1[7] = Bitstream_Read(a2, 15LL);
a1[8] = Bitstream_Read(a2, 4LL);
v3 = Bitstream_Read(a2, 3LL);
a1[9] = v3;
if ( v3 == 1 )
a1[10] = Bitstream_Read(a2, 8LL);
a1[11] = Bitstream_Read(a2, 15LL);
a1[12] = Bitstream_Read(a2, 10LL);
a1[13] = Bitstream_Read(a2, 4LL);
v4 = Bitstream_Read(a2, 3LL);
a1[14] = v4;
if ( v4 == 1 )
a1[15] = Bitstream_Read(a2, 8LL);
a1[16] = Bitstream_Read(a2, 2LL);
a1[17] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

original_code:
int PacketForSendingFixedTextMessages_DecodeBit(PacketForSendingFixedTextMessages* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 84))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXTCLASS = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXTDISPLAY = Bitstream_Read(stream, 1);
        }
        {
            p->D_TEXTDISPLAY = Bitstream_Read(stream, 15);
        }
        {
            p->M_MODETEXTDISPLAY_0 = Bitstream_Read(stream, 4);
        }
        {
            p->M_LEVELTEXTDISPLAY_0 = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTEXTDISPLAY_0 == 1)
        {
            {
                p->NID_STM_0 = Bitstream_Read(stream, 8);
            }
        }
        {
            p->L_TEXTDISPLAY = Bitstream_Read(stream, 15);
        }
        {
            p->T_TEXTDISPLAY = Bitstream_Read(stream, 10);
        }
        {
            p->M_MODETEXTDISPLAY_1 = Bitstream_Read(stream, 4);
        }
        {
            p->M_LEVELTEXTDISPLAY_1 = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTEXTDISPLAY_1 == 1)
        {
            {
                p->NID_STM_1 = Bitstream_Read(stream, 8);
            }
        }
        {
            p->Q_TEXTCONFIRM = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXT = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int PacketForSendingFixedTextMessages_DecodeBit(struct PacketForSendingFixedTextMessages *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 84))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXTCLASS = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXTDISPLAY = Bitstream_Read(stream, 1);
        }
        {
            p->D_TEXTDISPLAY = Bitstream_Read(stream, 15);
        }
        {
            p->M_MODETEXTDISPLAY_0 = Bitstream_Read(stream, 4);
        }
        {
            p->M_LEVELTEXTDISPLAY_0 = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTEXTDISPLAY_0 == 1)
        {
            {
                p->NID_STM_0 = Bitstream_Read(stream, 8);
            }
        }
        {
            p->L_TEXTDISPLAY = Bitstream_Read(stream, 15);
        }
        {
            p->T_TEXTDISPLAY = Bitstream_Read(stream, 10);
        }
        {
            p->M_MODETEXTDISPLAY_1 = Bitstream_Read(stream, 4);
        }
        {
            p->M_LEVELTEXTDISPLAY_1 = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTEXTDISPLAY_1 == 1)
        {
            {
                p->NID_STM_1 = Bitstream_Read(stream, 8);
            }
        }
        {
            p->Q_TEXTCONFIRM = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TEXT = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

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


original_code:
int PacketForSendingFixedTextMessages_EncodeInt(const PacketForSendingFixedTextMessages* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 76;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->Q_TEXTCLASS;
    stream[startAddress++] = p->Q_TEXTDISPLAY;
    stream[startAddress++] = p->D_TEXTDISPLAY;
    stream[startAddress++] = p->M_MODETEXTDISPLAY_0;
    stream[startAddress++] = p->M_LEVELTEXTDISPLAY_0;
    stream[startAddress++] = p->NID_STM_0;
    stream[startAddress++] = p->L_TEXTDISPLAY;
    stream[startAddress++] = p->T_TEXTDISPLAY;
    stream[startAddress++] = p->M_MODETEXTDISPLAY_1;
    stream[startAddress++] = p->M_LEVELTEXTDISPLAY_1;
    stream[startAddress++] = p->NID_STM_1;
    stream[startAddress++] = p->Q_TEXTCONFIRM;
    stream[startAddress++] = p->Q_TEXT;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int PacketForSendingFixedTextMessages_EncodeInt(struct PacketForSendingFixedTextMessages *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 76;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->Q_TEXTCLASS;
    stream[startAddress++] = p->Q_TEXTDISPLAY;
    stream[startAddress++] = p->D_TEXTDISPLAY;
    stream[startAddress++] = p->M_MODETEXTDISPLAY_0;
    stream[startAddress++] = p->M_LEVELTEXTDISPLAY_0;
    stream[startAddress++] = p->NID_STM_0;
    stream[startAddress++] = p->L_TEXTDISPLAY;
    stream[startAddress++] = p->T_TEXTDISPLAY;
    stream[startAddress++] = p->M_MODETEXTDISPLAY_1;
    stream[startAddress++] = p->M_LEVELTEXTDISPLAY_1;
    stream[startAddress++] = p->NID_STM_1;
    stream[startAddress++] = p->Q_TEXTCONFIRM;
    stream[startAddress++] = p->Q_TEXT;
    data->endAddress = startAddress-1;
    return 1;
}

variable_types: struct MetadataElement_T_Common_Types_Pkg { int nid_packet; int q_dir; unsigned char valid; int startAddress; int endAddress; } *

variable_types:
stream
int *

variable_types: startAddress int


original_code:
int PacketForSendingFixedTextMessages_DecodeInt(PacketForSendingFixedTextMessages* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 76)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->Q_TEXTCLASS = stream[startAddress++];
    p->Q_TEXTDISPLAY = stream[startAddress++];
    p->D_TEXTDISPLAY = stream[startAddress++];
    p->M_MODETEXTDISPLAY_0 = stream[startAddress++];
    p->M_LEVELTEXTDISPLAY_0 = stream[startAddress++];
    p->NID_STM_0 = stream[startAddress++];
    p->L_TEXTDISPLAY = stream[startAddress++];
    p->T_TEXTDISPLAY = stream[startAddress++];
    p->M_MODETEXTDISPLAY_1 = stream[startAddress++];
    p->M_LEVELTEXTDISPLAY_1 = stream[startAddress++];
    p->NID_STM_1 = stream[startAddress++];
    p->Q_TEXTCONFIRM = stream[startAddress++];
    p->Q_TEXT = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int PacketForSendingFixedTextMessages_DecodeInt(struct PacketForSendingFixedTextMessages *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 76)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->Q_TEXTCLASS = stream[startAddress++];
    p->Q_TEXTDISPLAY = stream[startAddress++];
    p->D_TEXTDISPLAY = stream[startAddress++];
    p->M_MODETEXTDISPLAY_0 = stream[startAddress++];
    p->M_LEVELTEXTDISPLAY_0 = stream[startAddress++];
    p->NID_STM_0 = stream[startAddress++];
    p->L_TEXTDISPLAY = stream[startAddress++];
    p->T_TEXTDISPLAY = stream[startAddress++];
    p->M_MODETEXTDISPLAY_1 = stream[startAddress++];
    p->M_LEVELTEXTDISPLAY_1 = stream[startAddress++];
    p->NID_STM_1 = stream[startAddress++];
    p->Q_TEXTCONFIRM = stream[startAddress++];
    p->Q_TEXT = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

user_defined_types: struct MetadataElement_T_Common_Types_Pkg { int nid_packet; int q_dir; unsigned char valid; int startAddress; int endAddress; }


decompiled_code:
__int64 *PacketForSendingFixedTextMessages_New()
{
__int64 *v0; // rbx

if ( PacketForSendingFixedTextMessagesMemoryFreeList == -1 )
{
if ( (unsigned __int64)PacketForSendingFixedTextMessagesMemoryTop > 7 )
return 0LL;
v0 = &PacketForSendingFixedTextMessagesMemory[18 * PacketForSendingFixedTextMessagesMemoryTop++];
}
else
{
v0 = &PacketForSendingFixedTextMessagesMemory[18 * PacketForSendingFixedTextMessagesMemoryFreeList];
PacketForSendingFixedTextMessagesMemoryFreeList = *v0;
}
PacketForSendingFixedTextMessages_Init(v0);
return v0;
}

canonical_decompiled_code:
__int64 *func7()
{
__int64 *v0; // rbx

if ( PacketForSendingFixedTextMessagesMemoryFreeList == -1 )
{
if ( (unsigned __int64)PacketForSendingFixedTextMessagesMemoryTop > 7 )
return 0LL;
v0 = &PacketForSendingFixedTextMessagesMemory[18 * PacketForSendingFixedTextMessagesMemoryTop++];
}
else
{
v0 = &PacketForSendingFixedTextMessagesMemory[18 * PacketForSendingFixedTextMessagesMemoryFreeList];
PacketForSendingFixedTextMessagesMemoryFreeList = *v0;
}
func1(v0);
return v0;
}

original_code:
PacketForSendingFixedTextMessages* PacketForSendingFixedTextMessages_New(void)
{
    PacketForSendingFixedTextMessages* ptr;
    if (PacketForSendingFixedTextMessagesMemoryFreeList != (-1))
    {
        ptr = &PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryFreeList];
        PacketForSendingFixedTextMessagesMemoryFreeList = PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryFreeList].header.NID_PACKET;
    }
    else if (PacketForSendingFixedTextMessagesMemoryTop < 8)
    {
        ptr = &PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryTop];
        PacketForSendingFixedTextMessagesMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PacketForSendingFixedTextMessages_Init(ptr);
    return ptr;
}

canonical_original_code:
struct PacketForSendingFixedTextMessages *PacketForSendingFixedTextMessages_New()
{
    struct PacketForSendingFixedTextMessages *ptr;
    if (PacketForSendingFixedTextMessagesMemoryFreeList != (-1))
    {
        ptr = &PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryFreeList];
        PacketForSendingFixedTextMessagesMemoryFreeList = PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryFreeList].header.NID_PACKET;
    }
    else if (PacketForSendingFixedTextMessagesMemoryTop < 8)
    {
        ptr = &PacketForSendingFixedTextMessagesMemory[PacketForSendingFixedTextMessagesMemoryTop];
        PacketForSendingFixedTextMessagesMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PacketForSendingFixedTextMessages_Init(ptr);
    return ptr;
}

return_type: struct PacketForSendingFixedTextMessages { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } 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; } *


decompiled_code:
unsigned __int64 __fastcall PacketForSendingFixedTextMessages_Delete(char *a1)
{
unsigned __int64 result; // rax

*(_QWORD *)a1 = PacketForSendingFixedTextMessagesMemoryFreeList;
result = 0x8E38E38E38E38E39LL;
PacketForSendingFixedTextMessagesMemoryFreeList = 0x8E38E38E38E38E39LL
* ((a1 - (char *)PacketForSendingFixedTextMessagesMemory) >> 4);
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(char *a1)
{
unsigned __int64 result; // rax

*(_QWORD *)a1 = PacketForSendingFixedTextMessagesMemoryFreeList;
result = 0x8E38E38E38E38E39LL;
PacketForSendingFixedTextMessagesMemoryFreeList = 0x8E38E38E38E38E39LL
* ((a1 - (char *)PacketForSendingFixedTextMessagesMemory) >> 4);
return result;
}

original_code:
void PacketForSendingFixedTextMessages_Delete(PacketForSendingFixedTextMessages* ptr)
{
    ptr->header.NID_PACKET = PacketForSendingFixedTextMessagesMemoryFreeList;
    PacketForSendingFixedTextMessagesMemoryFreeList = ptr - PacketForSendingFixedTextMessagesMemory;
}

canonical_original_code:
void PacketForSendingFixedTextMessages_Delete(struct PacketForSendingFixedTextMessages *ptr)
{
    ptr->header.NID_PACKET = PacketForSendingFixedTextMessagesMemoryFreeList;
    PacketForSendingFixedTextMessagesMemoryFreeList = ptr - PacketForSendingFixedTextMessagesMemory;
}

return_type: void


decompiled_code:
__int64 __fastcall Validated_train_data_Core_2_Encode_Bit(__int64 a1, unsigned __int64 *a2)
{
if ( !(unsigned int)Bitstream_Normal(a1, 8LL) )
return 0xFFFFFFFFLL;
if ( !Validated_train_data_Core_2_UpperBitsNotSet(a2) )
return 4294967294LL;
Bitstream_Write(a1, 8LL, *a2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int64 *a2)
{
if ( !(unsigned int)Bitstream_Normal(a1, 8LL) )
return 0xFFFFFFFFLL;
if ( !func2(a2) )
return 4294967294LL;
Bitstream_Write(a1, 8LL, *a2);
return 1LL;
}

original_code:
int Validated_train_data_Core_2_Encode_Bit(Bitstream* stream, const Validated_train_data_Core_2* p)
{
    if (Bitstream_Normal(stream, 8))
    {
        if (Validated_train_data_Core_2_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 8, p->NID_STM);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int Validated_train_data_Core_2_Encode_Bit(struct Bitstream *stream, struct Validated_train_data_Core_2 *p)
{
    if (Bitstream_Normal(stream, 8))
    {
        if (Validated_train_data_Core_2_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 8, p->NID_STM);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

variable_types: struct Validated_train_data_Core_2 { unsigned long NID_STM; } *


decompiled_code:
__int64 __fastcall Validated_train_data_Core_2_Decode_Bit(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

result = Bitstream_Normal(a1, 8LL);
if ( (_DWORD)result )
{
*a2 = Bitstream_Read(a1, 8LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

result = Bitstream_Normal(a1, 8LL);
if ( (_DWORD)result )
{
*a2 = Bitstream_Read(a1, 8LL);
result = 1LL;
}
return result;
}

original_code:
int Validated_train_data_Core_2_Decode_Bit(Bitstream* stream, Validated_train_data_Core_2* p)
{
    if (Bitstream_Normal(stream, 8))
    {
        {
            p->NID_STM = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int Validated_train_data_Core_2_Decode_Bit(struct Bitstream *stream, struct Validated_train_data_Core_2 *p)
{
    if (Bitstream_Normal(stream, 8))
    {
        {
            p->NID_STM = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

user_defined_types: struct Validated_train_data_Core_2 { unsigned long NID_STM; }


decompiled_code:
__int64 __fastcall Validated_train_data_Core_2_Encode_Int(__int64 a1, __int64 a2, __int64 *a3)
{
__int64 v3; // rdx
int v4; // eax

v3 = *a3;
v4 = *(_DWORD *)(a1 + 12);
*(_DWORD *)(a1 + 12) = v4 + 1;
*(_DWORD *)(a2 + 4LL * v4) = v3;
return 1LL;
}

original_code:
int Validated_train_data_Core_2_Encode_Int(PacketInfo* data, kcg_int* stream, const Validated_train_data_Core_2* p)
{
    return 0;
}

canonical_original_code:
int Validated_train_data_Core_2_Encode_Int(struct MetadataElement_T_Common_Types_Pkg *data, int *stream, struct Validated_train_data_Core_2 *p)
{
    return 0;
}


decompiled_code:
__int64 __fastcall Validated_train_data_Core_2_Decode_Int(__int64 a1, __int64 a2, _QWORD *a3)
{
int v3; // eax

v3 = *(_DWORD *)(a1 + 12);
*(_DWORD *)(a1 + 12) = v3 + 1;
*a3 = *(int *)(a2 + 4LL * v3);
return 1LL;
}

original_code:
int Validated_train_data_Core_2_Decode_Int(PacketInfo* data, const kcg_int* stream, Validated_train_data_Core_2* p)
{
    return 0;
}

canonical_original_code:
int Validated_train_data_Core_2_Decode_Int(struct MetadataElement_T_Common_Types_Pkg *data, int *stream, struct Validated_train_data_Core_2 *p)
{
    return 0;
}


decompiled_code:
_BOOL8 __fastcall TrackConditionChangeOfTractionPower_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL8 result; // rax

result = UpperBitsNotSet64(a1[2], 2);
if ( result )
{
result = UpperBitsNotSet64(a1[3], 13);
if ( result )
{
result = UpperBitsNotSet64(a1[4], 2);
if ( result )
{
result = UpperBitsNotSet64(a1[5], 15);
if ( result )
result = UpperBitsNotSet64(a1[6], 8);
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(unsigned __int64 *a1)
{
_BOOL8 result; // rax

result = func0(a1[2], 2);
if ( result )
{
result = func0(a1[3], 13);
if ( result )
{
result = func0(a1[4], 2);
if ( result )
{
result = func0(a1[5], 15);
if ( result )
result = func0(a1[6], 8);
}
}
}
return result;
}

original_code:
int TrackConditionChangeOfTractionPower_UpperBitsNotSet(const TrackConditionChangeOfTractionPower* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->D_TRACTION, 15);
    status = status && UpperBitsNotSet64(p->M_TRACTION, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackConditionChangeOfTractionPower_UpperBitsNotSet(struct TrackConditionChangeOfTractionPower *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->D_TRACTION, 15);
    status = status && UpperBitsNotSet64(p->M_TRACTION, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct TrackConditionChangeOfTractionPower { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } 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 TrackConditionChangeOfTractionPower { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_TRACTION; unsigned long M_TRACTION; }


decompiled_code:
__int64 __fastcall TrackConditionChangeOfTractionPower_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 40LL) )
return 0xFFFFFFFFLL;
if ( !TrackConditionChangeOfTractionPower_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 2LL, a1[4]);
Bitstream_Write(a2, 15LL, a1[5]);
Bitstream_Write(a2, 8LL, a1[6]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 40LL) )
return 0xFFFFFFFFLL;
if ( !func2(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 2LL, a1[4]);
Bitstream_Write(a2, 15LL, a1[5]);
Bitstream_Write(a2, 8LL, a1[6]);
return 1LL;
}

original_code:
int TrackConditionChangeOfTractionPower_EncodeBit(const TrackConditionChangeOfTractionPower* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 40))
    {
        if (TrackConditionChangeOfTractionPower_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 15, p->D_TRACTION);
            Bitstream_Write(stream, 8, p->M_TRACTION);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int TrackConditionChangeOfTractionPower_EncodeBit(struct TrackConditionChangeOfTractionPower *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 40))
    {
        if (TrackConditionChangeOfTractionPower_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 15, p->D_TRACTION);
            Bitstream_Write(stream, 8, p->M_TRACTION);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}


decompiled_code:
__int64 __fastcall TrackConditionChangeOfTractionPower_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

result = Bitstream_Normal(a2, 40LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 15LL);
a1[6] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

result = Bitstream_Normal(a2, 40LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 15LL);
a1[6] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

original_code:
int TrackConditionChangeOfTractionPower_DecodeBit(TrackConditionChangeOfTractionPower* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 40))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->D_TRACTION = Bitstream_Read(stream, 15);
        }
        {
            p->M_TRACTION = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackConditionChangeOfTractionPower_DecodeBit(struct TrackConditionChangeOfTractionPower *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 40))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->D_TRACTION = Bitstream_Read(stream, 15);
        }
        {
            p->M_TRACTION = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int TrackConditionChangeOfTractionPower_EncodeInt(const TrackConditionChangeOfTractionPower* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 39;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->D_TRACTION;
    stream[startAddress++] = p->M_TRACTION;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int TrackConditionChangeOfTractionPower_EncodeInt(struct TrackConditionChangeOfTractionPower *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 39;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->D_TRACTION;
    stream[startAddress++] = p->M_TRACTION;
    data->endAddress = startAddress-1;
    return 1;
}


original_code:
int TrackConditionChangeOfTractionPower_DecodeInt(TrackConditionChangeOfTractionPower* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 39)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->D_TRACTION = stream[startAddress++];
    p->M_TRACTION = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int TrackConditionChangeOfTractionPower_DecodeInt(struct TrackConditionChangeOfTractionPower *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 39)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->D_TRACTION = stream[startAddress++];
    p->M_TRACTION = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


decompiled_code:
__int64 *TrackConditionChangeOfTractionPower_New()
{
__int64 *v0; // rbx

if ( TrackConditionChangeOfTractionPowerMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrackConditionChangeOfTractionPowerMemoryTop > 7 )
return 0LL;
v0 = &TrackConditionChangeOfTractionPowerMemory[7 * TrackConditionChangeOfTractionPowerMemoryTop++];
}
else
{
v0 = &TrackConditionChangeOfTractionPowerMemory[7 * TrackConditionChangeOfTractionPowerMemoryFreeList];
TrackConditionChangeOfTractionPowerMemoryFreeList = *v0;
}
TrackConditionChangeOfTractionPower_Init(v0);
return v0;
}

canonical_decompiled_code:
__int64 *func7()
{
__int64 *v0; // rbx

if ( TrackConditionChangeOfTractionPowerMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrackConditionChangeOfTractionPowerMemoryTop > 7 )
return 0LL;
v0 = &TrackConditionChangeOfTractionPowerMemory[7 * TrackConditionChangeOfTractionPowerMemoryTop++];
}
else
{
v0 = &TrackConditionChangeOfTractionPowerMemory[7 * TrackConditionChangeOfTractionPowerMemoryFreeList];
TrackConditionChangeOfTractionPowerMemoryFreeList = *v0;
}
func1(v0);
return v0;
}

original_code:
TrackConditionChangeOfTractionPower* TrackConditionChangeOfTractionPower_New(void)
{
    TrackConditionChangeOfTractionPower* ptr;
    if (TrackConditionChangeOfTractionPowerMemoryFreeList != (-1))
    {
        ptr = &TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryFreeList];
        TrackConditionChangeOfTractionPowerMemoryFreeList = TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryFreeList].header.NID_PACKET;
    }
    else if (TrackConditionChangeOfTractionPowerMemoryTop < 8)
    {
        ptr = &TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryTop];
        TrackConditionChangeOfTractionPowerMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrackConditionChangeOfTractionPower_Init(ptr);
    return ptr;
}

canonical_original_code:
struct TrackConditionChangeOfTractionPower *TrackConditionChangeOfTractionPower_New()
{
    struct TrackConditionChangeOfTractionPower *ptr;
    if (TrackConditionChangeOfTractionPowerMemoryFreeList != (-1))
    {
        ptr = &TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryFreeList];
        TrackConditionChangeOfTractionPowerMemoryFreeList = TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryFreeList].header.NID_PACKET;
    }
    else if (TrackConditionChangeOfTractionPowerMemoryTop < 8)
    {
        ptr = &TrackConditionChangeOfTractionPowerMemory[TrackConditionChangeOfTractionPowerMemoryTop];
        TrackConditionChangeOfTractionPowerMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrackConditionChangeOfTractionPower_Init(ptr);
    return ptr;
}

return_type: struct TrackConditionChangeOfTractionPower { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_TRACTION; unsigned long M_TRACTION; } *


decompiled_code:
__int64 __fastcall TrackConditionChangeOfTractionPower_Delete(_QWORD *a1)
{
__int64 result; // rax

*a1 = TrackConditionChangeOfTractionPowerMemoryFreeList;
result = 0x6DB6DB6DB6DB6DB7LL;
TrackConditionChangeOfTractionPowerMemoryFreeList = 0x6DB6DB6DB6DB6DB7LL
* (a1 - TrackConditionChangeOfTractionPowerMemory);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1)
{
__int64 result; // rax

*a1 = TrackConditionChangeOfTractionPowerMemoryFreeList;
result = 0x6DB6DB6DB6DB6DB7LL;
TrackConditionChangeOfTractionPowerMemoryFreeList = 0x6DB6DB6DB6DB6DB7LL
* (a1 - TrackConditionChangeOfTractionPowerMemory);
return result;
}

original_code:
void TrackConditionChangeOfTractionPower_Delete(TrackConditionChangeOfTractionPower* ptr)
{
    ptr->header.NID_PACKET = TrackConditionChangeOfTractionPowerMemoryFreeList;
    TrackConditionChangeOfTractionPowerMemoryFreeList = ptr - TrackConditionChangeOfTractionPowerMemory;
}

canonical_original_code:
void TrackConditionChangeOfTractionPower_Delete(struct TrackConditionChangeOfTractionPower *ptr)
{
    ptr->header.NID_PACKET = TrackConditionChangeOfTractionPowerMemoryFreeList;
    TrackConditionChangeOfTractionPowerMemoryFreeList = ptr - TrackConditionChangeOfTractionPowerMemory;
}


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;
    }
}


decompiled_code:
_BOOL8 __fastcall GradientProfile_1_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL8 result; // rax

result = UpperBitsNotSet64(*a1, 15);
if ( result )
{
result = UpperBitsNotSet64(a1[1], 1);
if ( result )
result = UpperBitsNotSet64(a1[2], 8);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int64 *a1)
{
_BOOL8 result; // rax

result = func0(*a1, 15);
if ( result )
{
result = func0(a1[1], 1);
if ( result )
result = func0(a1[2], 8);
}
return result;
}

original_code:
int GradientProfile_1_UpperBitsNotSet(const GradientProfile_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->D_GRADIENT, 15);
    status = status && UpperBitsNotSet64(p->Q_GDIR, 1) ;
    status = status && UpperBitsNotSet64(p->G_A, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int GradientProfile_1_UpperBitsNotSet(struct GradientProfile_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->D_GRADIENT, 15);
    status = status && UpperBitsNotSet64(p->Q_GDIR, 1) ;
    status = status && UpperBitsNotSet64(p->G_A, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct GradientProfile_1 { unsigned long D_GRADIENT; unsigned long Q_GDIR; unsigned long G_A; } *


decompiled_code:
__int64 __fastcall GradientProfile_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 24LL) )
return 0xFFFFFFFFLL;
if ( !GradientProfile_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 1LL, a1[1]);
Bitstream_Write(a2, 8LL, a1[2]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 24LL) )
return 0xFFFFFFFFLL;
if ( !func1(a1) )
return 4294967294LL;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 1LL, a1[1]);
Bitstream_Write(a2, 8LL, a1[2]);
return 1LL;
}

original_code:
int GradientProfile_1_EncodeBit(const GradientProfile_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 24))
    {
        if (GradientProfile_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_GRADIENT);
            Bitstream_Write(stream, 1, p->Q_GDIR);
            Bitstream_Write(stream, 8, p->G_A);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int GradientProfile_1_EncodeBit(struct GradientProfile_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 24))
    {
        if (GradientProfile_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_GRADIENT);
            Bitstream_Write(stream, 1, p->Q_GDIR);
            Bitstream_Write(stream, 8, p->G_A);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}


decompiled_code:
__int64 __fastcall GradientProfile_1_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

result = Bitstream_Normal(a2, 24LL);
if ( (_DWORD)result )
{
*a1 = Bitstream_Read(a2, 15LL);
a1[1] = Bitstream_Read(a2, 1LL);
a1[2] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

result = Bitstream_Normal(a2, 24LL);
if ( (_DWORD)result )
{
*a1 = Bitstream_Read(a2, 15LL);
a1[1] = Bitstream_Read(a2, 1LL);
a1[2] = Bitstream_Read(a2, 8LL);
result = 1LL;
}
return result;
}

original_code:
int GradientProfile_1_DecodeBit(GradientProfile_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 24))
    {
        {
            p->D_GRADIENT = Bitstream_Read(stream, 15);
        }
        {
            p->Q_GDIR = Bitstream_Read(stream, 1);
        }
        {
            p->G_A = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int GradientProfile_1_DecodeBit(struct GradientProfile_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 24))
    {
        {
            p->D_GRADIENT = Bitstream_Read(stream, 15);
        }
        {
            p->Q_GDIR = Bitstream_Read(stream, 1);
        }
        {
            p->G_A = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int GradientProfile_1_EncodeInt(const GradientProfile_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->D_GRADIENT;
    stream[(*startAddress)++] = p->Q_GDIR;
    stream[(*startAddress)++] = p->G_A;
    return 1;
}

canonical_original_code:
int GradientProfile_1_EncodeInt(struct GradientProfile_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->D_GRADIENT;
    stream[(*startAddress)++] = p->Q_GDIR;
    stream[(*startAddress)++] = p->G_A;
    return 1;
}

variable_types:
startAddress
int *


original_code:
int GradientProfile_1_DecodeInt(GradientProfile_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->D_GRADIENT = stream[(*startAddress)++];
    p->Q_GDIR = stream[(*startAddress)++];
    p->G_A = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int GradientProfile_1_DecodeInt(struct GradientProfile_1 *p, int *startAddress, int *stream)
{
    p->D_GRADIENT = stream[(*startAddress)++];
    p->Q_GDIR = stream[(*startAddress)++];
    p->G_A = stream[(*startAddress)++];
    return 1;
}


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:
b
struct PacketHeader *


decompiled_code:
// attributes: thunk
_BOOL8 __fastcall EndOfInformation_Equal(_QWORD *a1, _QWORD *a2)
{
return PacketHeader_Equal(a1, a2);
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(_QWORD *a1, _QWORD *a2)
{
return func0(a1, a2);
}

original_code:
static inline int EndOfInformation_Equal(const EndOfInformation* a, const EndOfInformation* b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    return status;
}

canonical_original_code:
static inline int EndOfInformation_Equal(struct EndOfInformation *a, struct EndOfInformation *b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    return status;
}

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

variable_types:
b
struct EndOfInformation *

user_defined_types: struct EndOfInformation { struct PacketHeader header; }


decompiled_code:
int EndOfInformation_Tests()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_QWORD v3[2]; // [rsp+0h] [rbp-28h] BYREF
_QWORD v4[3]; // [rsp+10h] [rbp-18h] BYREF

puts("\nstart EndOfInformation_Tests");
EndOfInformation_Init(v4);
EndOfInformation_Print(v4, stdout);
putchar(10);
EndOfInformation_Init(v3);
if ( !EndOfInformation_Equal(v4, v3) )
_assert_fail("EndOfInformation_Equal(&a, &b)", "EndOfInformation_Tests.c", 0x25u, "EndOfInformation_Tests");
v0 = (_QWORD *)PacketFactory_BothWays(255LL, 2LL);
v1 = v0;
if ( !v0 )
_assert_fail("base", "EndOfInformation_Tests.c", 0x29u, "EndOfInformation_Tests");
EndOfInformation_Print(v0, stdout);
putchar(10);
if ( !EndOfInformation_Equal(v4, v1) )
_assert_fail("EndOfInformation_Equal(&a, p)", "EndOfInformation_Tests.c", 0x2Du, "EndOfInformation_Tests");
EndOfInformation_Delete(v1);
return puts("end EndOfInformation_Test");
}

canonical_decompiled_code:
int func5()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_QWORD v3[2]; // [rsp+0h] [rbp-28h] BYREF
_QWORD v4[3]; // [rsp+10h] [rbp-18h] BYREF

puts("\nstart EndOfInformation_Tests");
func1(v4);
func4(v4, stdout);
putchar(10);
func1(v3);
if ( !func2(v4, v3) )
_assert_fail("EndOfInformation_Equal(&a, &b)", "EndOfInformation_Tests.c", 0x25u, "EndOfInformation_Tests");
v0 = (_QWORD *)PacketFactory_BothWays(255LL, 2LL);
v1 = v0;
if ( !v0 )
_assert_fail("base", "EndOfInformation_Tests.c", 0x29u, "EndOfInformation_Tests");
func4(v0, stdout);
putchar(10);
if ( !func2(v4, v1) )
_assert_fail("EndOfInformation_Equal(&a, p)", "EndOfInformation_Tests.c", 0x2Du, "EndOfInformation_Tests");
EndOfInformation_Delete(v1);
return puts("end EndOfInformation_Test");
}

original_code:
void EndOfInformation_Tests(void)
{
    printf("\nstart EndOfInformation_Tests\n");
    EndOfInformation a;
    EndOfInformation_Init(&a);
    EndOfInformation_Print(&a, stdout);
    printf("\n");
    EndOfInformation b;
    EndOfInformation_Init(&b);
    ((EndOfInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("EndOfInformation_Equal(&a, &b)", "EndOfInformation_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    PacketHeader header = {255, 2};
    PacketHeader* base = PacketFactory_BothWays(header);
    ((base) ? (void) (0) : __assert_fail ("base", "EndOfInformation_Tests.c", 41, __extension__ __PRETTY_FUNCTION__));
    EndOfInformation* p = (EndOfInformation*)(base);
    EndOfInformation_Print(p, stdout);
    printf("\n");
    ((EndOfInformation_Equal(&a, p)) ? (void) (0) : __assert_fail ("EndOfInformation_Equal(&a, p)", "EndOfInformation_Tests.c", 45, __extension__ __PRETTY_FUNCTION__));
    EndOfInformation_Delete(p);
    printf("end EndOfInformation_Test\n");
}

canonical_original_code:
void EndOfInformation_Tests()
{
    printf("\nstart EndOfInformation_Tests\n");
    struct EndOfInformation a;
    EndOfInformation_Init(&a);
    EndOfInformation_Print(&a, stdout);
    printf("\n");
    struct EndOfInformation b;
    EndOfInformation_Init(&b);
    ((EndOfInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("EndOfInformation_Equal(&a, &b)", "EndOfInformation_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    struct PacketHeader header = {255, 2};
    struct PacketHeader *base = PacketFactory_BothWays(header);
    ((base) ? (void) (0) : __assert_fail ("base", "EndOfInformation_Tests.c", 41, __extension__ __PRETTY_FUNCTION__));
    struct EndOfInformation *p = (EndOfInformation*)(base);
    EndOfInformation_Print(p, stdout);
    printf("\n");
    ((EndOfInformation_Equal(&a, p)) ? (void) (0) : __assert_fail ("EndOfInformation_Equal(&a, p)", "EndOfInformation_Tests.c", 45, __extension__ __PRETTY_FUNCTION__));
    EndOfInformation_Delete(p);
    printf("end EndOfInformation_Test\n");
}

variable_types: struct EndOfInformation { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; }

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