decompiled_code:
__int64 __fastcall Packet_EncodeInt(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdx
__int64 result; // rax
__int64 v6; // rdx

v4 = a1[1];
if ( v4 == 1 )
{
v6 = *a1;
switch ( *a1 )
{
case 3LL:
NationalValues_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 5LL:
Linking_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 16LL:
RepositioningInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 21LL:
GradientProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 42LL:
SessionManagement_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 44LL:
LABEL_10:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 58LL:
PositionReportParameters_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 68LL:
TrackCondition_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 71LL:
AdhesionFactor_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 80LL:
ModeProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 134LL:
EOLMPacket_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 136LL:
InfillLocationReference_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
default:
LABEL_9:
fprintf(stderr, "Packet_EncodeInt: unexpected value for header->NID_PACKET = %lu\n", v6);
result = 0LL;
break;
}
}
else if ( v4 == 2 )
{
if ( *a1 != 255 )
_assert_fail("header->NID_PACKET == 255", "Packet_EncodeInt.c", 0x153u, "Packet_EncodeInt");
EndOfInformation_EncodeInt(a1, a2, a3);
result = 1LL;
}
else if ( v4 )
{
fprintf(stderr, "Packet_EncodeInt: unexpected value for header->list = %lu\n", v4);
result = 0LL;
}
else
{
v6 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 4LL:
ErrorReporting_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 11LL:
ValidatedTrainData_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 44LL:
goto LABEL_10;
default:
goto LABEL_9;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdx
__int64 result; // rax
__int64 v6; // rdx

v4 = a1[1];
if ( v4 == 1 )
{
v6 = *a1;
switch ( *a1 )
{
case 3LL:
NationalValues_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 5LL:
Linking_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 12LL:
Level1MovementAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 15LL:
Level23MovementAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 16LL:
RepositioningInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 21LL:
GradientProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 27LL:
InternationalStaticSpeedProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 39LL:
TrackConditionChangeOfTractionPower_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 41LL:
LevelTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 42LL:
SessionManagement_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 44LL:
LABEL_10:
DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 45LL:
RadioNetworkRegistration_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 46LL:
ConditionalLevelTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 49LL:
ListOfBalisesForSHArea_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 51LL:
AxleLoadSpeedProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 57LL:
MovementAuthorityRequestParameters_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 58LL:
PositionReportParameters_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 63LL:
ListOfBalisesInSRAuthority_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 65LL:
TemporarySpeedRestriction_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 66LL:
TemporarySpeedRestrictionRevocation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 67LL:
TrackConditionBigMetalMasses_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 68LL:
TrackCondition_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 70LL:
RouteSuitabilityData_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 71LL:
AdhesionFactor_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 72LL:
PacketForSendingPlainTextMessages_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 76LL:
PacketForSendingFixedTextMessages_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 79LL:
GeographicalPositionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 80LL:
ModeProfile_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 90LL:
TrackAheadFreeUpToLevel23TransitionLocation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 131LL:
RBCTransitionOrder_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 132LL:
DangerForShuntingInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 133LL:
RadioInfillAreaInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 134LL:
EOLMPacket_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 136LL:
InfillLocationReference_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 137LL:
StopIfInStaffResponsible_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 138LL:
ReversingAreaInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 139LL:
ReversingSupervisionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 140LL:
TrainRunningNumberFromRBC_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 141LL:
DefaultGradientForTemporarySpeedRestriction_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 254LL:
DefaultBaliseLoopOrRIUInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
default:
LABEL_9:
fprintf(stderr, "Packet_EncodeInt: unexpected value for header->NID_PACKET = %lu\n", v6);
result = 0LL;
break;
}
}
else if ( v4 == 2 )
{
if ( *a1 != 255 )
_assert_fail("header->NID_PACKET == 255", "Packet_EncodeInt.c", 0x153u, "Packet_EncodeInt");
EndOfInformation_EncodeInt(a1, a2, a3);
result = 1LL;
}
else if ( v4 )
{
fprintf(stderr, "Packet_EncodeInt: unexpected value for header->list = %lu\n", v4);
result = 0LL;
}
else
{
v6 = *a1;
switch ( *a1 )
{
case 0LL:
PositionReport_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 1LL:
PositionReportBasedOnTwoBaliseGroups_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 3LL:
OnboardTelephoneNumbers_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 4LL:
ErrorReporting_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 9LL:
Level23TransitionInformation_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 11LL:
ValidatedTrainData_EncodeInt(a1, a2, a3);
result = 1LL;
break;
case 44LL:
goto LABEL_10;
default:
goto LABEL_9;
}
}
return result;
}

original_code:
int Packet_EncodeInt(const PacketHeader* header, Metadata* data, kcg_int* stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_EncodeInt((const PositionReport*)(header), data, stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_EncodeInt((const PositionReportBasedOnTwoBaliseGroups*)(header), data, stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_EncodeInt((const OnboardTelephoneNumbers*)(header), data, stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_EncodeInt((const ErrorReporting*)(header), data, stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_EncodeInt((const Level23TransitionInformation*)(header), data, stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_EncodeInt((const ValidatedTrainData*)(header), data, stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt((const DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), data, stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeInt: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_EncodeInt((const NationalValues*)(header), data, stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_EncodeInt((const Linking*)(header), data, stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_EncodeInt((const Level1MovementAuthority*)(header), data, stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_EncodeInt((const Level23MovementAuthority*)(header), data, stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_EncodeInt((const RepositioningInformation*)(header), data, stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_EncodeInt((const GradientProfile*)(header), data, stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_EncodeInt((const InternationalStaticSpeedProfile*)(header), data, stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_EncodeInt((const TrackConditionChangeOfTractionPower*)(header), data, stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_EncodeInt((const LevelTransitionOrder*)(header), data, stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_EncodeInt((const SessionManagement*)(header), data, stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt((const DataUsedByApplicationsOutsideTheERTMSETCSSystem*)(header), data, stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_EncodeInt((const RadioNetworkRegistration*)(header), data, stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_EncodeInt((const ConditionalLevelTransitionOrder*)(header), data, stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_EncodeInt((const ListOfBalisesForSHArea*)(header), data, stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_EncodeInt((const AxleLoadSpeedProfile*)(header), data, stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_EncodeInt((const MovementAuthorityRequestParameters*)(header), data, stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_EncodeInt((const PositionReportParameters*)(header), data, stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_EncodeInt((const ListOfBalisesInSRAuthority*)(header), data, stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_EncodeInt((const TemporarySpeedRestriction*)(header), data, stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_EncodeInt((const TemporarySpeedRestrictionRevocation*)(header), data, stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_EncodeInt((const TrackConditionBigMetalMasses*)(header), data, stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_EncodeInt((const TrackCondition*)(header), data, stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_EncodeInt((const RouteSuitabilityData*)(header), data, stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_EncodeInt((const AdhesionFactor*)(header), data, stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_EncodeInt((const PacketForSendingPlainTextMessages*)(header), data, stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_EncodeInt((const PacketForSendingFixedTextMessages*)(header), data, stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_EncodeInt((const GeographicalPositionInformation*)(header), data, stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_EncodeInt((const ModeProfile*)(header), data, stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_EncodeInt((const TrackAheadFreeUpToLevel23TransitionLocation*)(header), data, stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_EncodeInt((const RBCTransitionOrder*)(header), data, stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_EncodeInt((const DangerForShuntingInformation*)(header), data, stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_EncodeInt((const RadioInfillAreaInformation*)(header), data, stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_EncodeInt((const EOLMPacket*)(header), data, stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_EncodeInt((const InfillLocationReference*)(header), data, stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_EncodeInt((const StopIfInStaffResponsible*)(header), data, stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_EncodeInt((const ReversingAreaInformation*)(header), data, stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_EncodeInt((const ReversingSupervisionInformation*)(header), data, stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_EncodeInt((const TrainRunningNumberFromRBC*)(header), data, stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_EncodeInt((const DefaultGradientForTemporarySpeedRestriction*)(header), data, stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_EncodeInt((const DefaultBaliseLoopOrRIUInformation*)(header), data, stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeInt: 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_EncodeInt.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_EncodeInt((const EndOfInformation*)header, data, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_EncodeInt: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

canonical_original_code:
int Packet_EncodeInt(struct PacketHeader *header, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    switch (header->list)
    {
        case 0 :
        {
            switch (header->NID_PACKET)
            {
                case 0 :
                {
                    PositionReport_EncodeInt((struct PositionReport *)(header), data, stream);
                    return 1;
                }
                case 1 :
                {
                    PositionReportBasedOnTwoBaliseGroups_EncodeInt((struct PositionReportBasedOnTwoBaliseGroups *)(header), data, stream);
                    return 1;
                }
                case 3 :
                {
                    OnboardTelephoneNumbers_EncodeInt((struct OnboardTelephoneNumbers *)(header), data, stream);
                    return 1;
                }
                case 4 :
                {
                    ErrorReporting_EncodeInt((struct ErrorReporting *)(header), data, stream);
                    return 1;
                }
                case 9 :
                {
                    Level23TransitionInformation_EncodeInt((struct Level23TransitionInformation *)(header), data, stream);
                    return 1;
                }
                case 11 :
                {
                    ValidatedTrainData_EncodeInt((struct ValidatedTrainData *)(header), data, stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), data, stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeInt: unexpected value for header->NID_PACKET = %lu\n", header->NID_PACKET);
                    return 0;
                }
            };
        }
        case 1 :
        {
            switch (header->NID_PACKET)
            {
                case 3 :
                {
                    NationalValues_EncodeInt((struct NationalValues *)(header), data, stream);
                    return 1;
                }
                case 5 :
                {
                    Linking_EncodeInt((struct Linking *)(header), data, stream);
                    return 1;
                }
                case 12 :
                {
                    Level1MovementAuthority_EncodeInt((struct Level1MovementAuthority *)(header), data, stream);
                    return 1;
                }
                case 15 :
                {
                    Level23MovementAuthority_EncodeInt((struct Level23MovementAuthority *)(header), data, stream);
                    return 1;
                }
                case 16 :
                {
                    RepositioningInformation_EncodeInt((struct RepositioningInformation *)(header), data, stream);
                    return 1;
                }
                case 21 :
                {
                    GradientProfile_EncodeInt((struct GradientProfile *)(header), data, stream);
                    return 1;
                }
                case 27 :
                {
                    InternationalStaticSpeedProfile_EncodeInt((struct InternationalStaticSpeedProfile *)(header), data, stream);
                    return 1;
                }
                case 39 :
                {
                    TrackConditionChangeOfTractionPower_EncodeInt((struct TrackConditionChangeOfTractionPower *)(header), data, stream);
                    return 1;
                }
                case 41 :
                {
                    LevelTransitionOrder_EncodeInt((struct LevelTransitionOrder *)(header), data, stream);
                    return 1;
                }
                case 42 :
                {
                    SessionManagement_EncodeInt((struct SessionManagement *)(header), data, stream);
                    return 1;
                }
                case 44 :
                {
                    DataUsedByApplicationsOutsideTheERTMSETCSSystem_EncodeInt((struct DataUsedByApplicationsOutsideTheERTMSETCSSystem *)(header), data, stream);
                    return 1;
                }
                case 45 :
                {
                    RadioNetworkRegistration_EncodeInt((struct RadioNetworkRegistration *)(header), data, stream);
                    return 1;
                }
                case 46 :
                {
                    ConditionalLevelTransitionOrder_EncodeInt((struct ConditionalLevelTransitionOrder *)(header), data, stream);
                    return 1;
                }
                case 49 :
                {
                    ListOfBalisesForSHArea_EncodeInt((struct ListOfBalisesForSHArea *)(header), data, stream);
                    return 1;
                }
                case 51 :
                {
                    AxleLoadSpeedProfile_EncodeInt((struct AxleLoadSpeedProfile *)(header), data, stream);
                    return 1;
                }
                case 57 :
                {
                    MovementAuthorityRequestParameters_EncodeInt((struct MovementAuthorityRequestParameters *)(header), data, stream);
                    return 1;
                }
                case 58 :
                {
                    PositionReportParameters_EncodeInt((struct PositionReportParameters *)(header), data, stream);
                    return 1;
                }
                case 63 :
                {
                    ListOfBalisesInSRAuthority_EncodeInt((struct ListOfBalisesInSRAuthority *)(header), data, stream);
                    return 1;
                }
                case 65 :
                {
                    TemporarySpeedRestriction_EncodeInt((struct TemporarySpeedRestriction *)(header), data, stream);
                    return 1;
                }
                case 66 :
                {
                    TemporarySpeedRestrictionRevocation_EncodeInt((struct TemporarySpeedRestrictionRevocation *)(header), data, stream);
                    return 1;
                }
                case 67 :
                {
                    TrackConditionBigMetalMasses_EncodeInt((struct TrackConditionBigMetalMasses *)(header), data, stream);
                    return 1;
                }
                case 68 :
                {
                    TrackCondition_EncodeInt((struct TrackCondition *)(header), data, stream);
                    return 1;
                }
                case 70 :
                {
                    RouteSuitabilityData_EncodeInt((struct RouteSuitabilityData *)(header), data, stream);
                    return 1;
                }
                case 71 :
                {
                    AdhesionFactor_EncodeInt((struct AdhesionFactor *)(header), data, stream);
                    return 1;
                }
                case 72 :
                {
                    PacketForSendingPlainTextMessages_EncodeInt((struct PacketForSendingPlainTextMessages *)(header), data, stream);
                    return 1;
                }
                case 76 :
                {
                    PacketForSendingFixedTextMessages_EncodeInt((struct PacketForSendingFixedTextMessages *)(header), data, stream);
                    return 1;
                }
                case 79 :
                {
                    GeographicalPositionInformation_EncodeInt((struct GeographicalPositionInformation *)(header), data, stream);
                    return 1;
                }
                case 80 :
                {
                    ModeProfile_EncodeInt((struct ModeProfile *)(header), data, stream);
                    return 1;
                }
                case 90 :
                {
                    TrackAheadFreeUpToLevel23TransitionLocation_EncodeInt((struct TrackAheadFreeUpToLevel23TransitionLocation *)(header), data, stream);
                    return 1;
                }
                case 131 :
                {
                    RBCTransitionOrder_EncodeInt((struct RBCTransitionOrder *)(header), data, stream);
                    return 1;
                }
                case 132 :
                {
                    DangerForShuntingInformation_EncodeInt((struct DangerForShuntingInformation *)(header), data, stream);
                    return 1;
                }
                case 133 :
                {
                    RadioInfillAreaInformation_EncodeInt((struct RadioInfillAreaInformation *)(header), data, stream);
                    return 1;
                }
                case 134 :
                {
                    EOLMPacket_EncodeInt((struct EOLMPacket *)(header), data, stream);
                    return 1;
                }
                case 136 :
                {
                    InfillLocationReference_EncodeInt((struct InfillLocationReference *)(header), data, stream);
                    return 1;
                }
                case 137 :
                {
                    StopIfInStaffResponsible_EncodeInt((struct StopIfInStaffResponsible *)(header), data, stream);
                    return 1;
                }
                case 138 :
                {
                    ReversingAreaInformation_EncodeInt((struct ReversingAreaInformation *)(header), data, stream);
                    return 1;
                }
                case 139 :
                {
                    ReversingSupervisionInformation_EncodeInt((struct ReversingSupervisionInformation *)(header), data, stream);
                    return 1;
                }
                case 140 :
                {
                    TrainRunningNumberFromRBC_EncodeInt((struct TrainRunningNumberFromRBC *)(header), data, stream);
                    return 1;
                }
                case 141 :
                {
                    DefaultGradientForTemporarySpeedRestriction_EncodeInt((struct DefaultGradientForTemporarySpeedRestriction *)(header), data, stream);
                    return 1;
                }
                case 254 :
                {
                    DefaultBaliseLoopOrRIUInformation_EncodeInt((struct DefaultBaliseLoopOrRIUInformation *)(header), data, stream);
                    return 1;
                }
                default :
                {
                    fprintf(stderr, "Packet_EncodeInt: 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_EncodeInt.c", 339, __extension__ __PRETTY_FUNCTION__));
            EndOfInformation_EncodeInt((struct EndOfInformation *)header, data, stream);
            return 1;
        }
        default:
        {
            fprintf(stderr, "Packet_EncodeInt: unexpected value for header->list = %lu\n", header->list);
            return 0;
        }
    };
}

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

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 *

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 PositionReportParameters { struct PacketHeader header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long T_CYCLOC; unsigned long D_CYCLOC; unsigned long M_LOC; unsigned long N_ITER_1; struct PositionReportParameters_1 sub_1[31]; }

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

user_defined_types: struct 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 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 ConditionalLevelTransitionOrder_1 { unsigned long M_LEVELTR; unsigned long NID_STM; }

user_defined_types: struct ListOfBalisesForSHArea_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; }

user_defined_types: struct AxleLoadSpeedProfile_1 { unsigned long M_AXLELOAD; unsigned long V_AXLELOAD; }

user_defined_types: struct AxleLoadSpeedProfile_2 { unsigned long D_AXLELOAD; unsigned long L_AXLELOAD; unsigned long Q_FRONT; unsigned long N_ITER_2_1; struct AxleLoadSpeedProfile_2_1 sub_2_1[31]; }

user_defined_types: struct PositionReportParameters_1 { unsigned long D_LOC; unsigned long Q_LGTLOC; }

user_defined_types: struct ListOfBalisesInSRAuthority_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; }

user_defined_types: struct TrackConditionBigMetalMasses_1 { unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; }

user_defined_types: struct TrackCondition_1 { unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; unsigned long M_TRACKCOND; }

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

user_defined_types: struct GeographicalPositionInformation_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long D_POSOFF; unsigned long Q_MPOSITION; unsigned long M_POSITION; }

user_defined_types: struct ModeProfile_1 { unsigned long D_MAMODE; unsigned long M_MAMODE; unsigned long V_MAMODE; unsigned long L_MAMODE; unsigned long L_ACKMAMODE; }

user_defined_types: struct AxleLoadSpeedProfile_2_1 { unsigned long M_AXLELOAD; unsigned long V_AXLELOAD; }


repo: openETCS/dataDictionary

decompiled_code:
void __fastcall Bitstream_Init(__int64 a1, __int64 a2, int a3, int a4)
{
*(_QWORD *)a1 = a2;
*(_DWORD *)(a1 + 8) = a3;
*(_DWORD *)(a1 + 12) = a4;
}

original_code:
void
Bitstream_Init(Bitstream* stream, uint8_t* addr, uint32_t size, uint32_t bitpos)
{
    stream->addr = addr;
    stream->size = size;
    stream->bitpos = bitpos;
}

canonical_original_code:
void Bitstream_Init(struct Bitstream *stream, unsigned char *addr, unsigned int size, unsigned int bitpos)
{
    stream->addr = addr;
    stream->size = size;
    stream->bitpos = bitpos;
}

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

variable_types:
addr
unsigned char *

variable_types:
size
unsigned int

variable_types:
bitpos
unsigned int

return_type: void


decompiled_code:
_BOOL8 __fastcall Bitstream_Normal(__int64 a1, int a2)
{
return *(_DWORD *)(a1 + 12) + a2 <= (unsigned int)(8 * *(_DWORD *)(a1 + 8));
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, int a2)
{
return *(_DWORD *)(a1 + 12) + a2 <= (unsigned int)(8 * *(_DWORD *)(a1 + 8));
}

original_code:
int
Bitstream_Normal(const Bitstream* stream, uint32_t length)
{
    return stream->bitpos + length <= 8 * stream->size;
}

canonical_original_code:
int Bitstream_Normal(struct Bitstream *stream, unsigned int length)
{
    return stream->bitpos + length <= 8 * stream->size;
}

variable_types:
length
unsigned int

return_type: int

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


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

result = Bitwalker_Read(*(unsigned __int8 **)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 12), a2);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

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

result = Bitwalker_Read(*(unsigned __int8 **)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 12), a2);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

original_code:
uint64_t
Bitstream_Read(Bitstream* s, uint32_t length)
{
    uint64_t value = Bitwalker_Read(s->addr, s->size, s->bitpos, length);
    s->bitpos += length;
    return value;
}

canonical_original_code:
unsigned long Bitstream_Read(struct Bitstream *s, unsigned int length)
{
    unsigned long value = Bitwalker_Read(s->addr, s->size, s->bitpos, length);
    s->bitpos += length;
    return value;
}

variable_types:
value
unsigned long

return_type: unsigned long


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

result = Bitwalker_Write(*(unsigned __int8 **)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 12), a2, a3);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

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

result = Bitwalker_Write(*(unsigned __int8 **)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 12), a2, a3);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

original_code:
void
Bitstream_Write(Bitstream* stream, uint32_t length, uint64_t value)
{
    Bitwalker_Write(stream->addr, stream->size, stream->bitpos, length, value);
    stream->bitpos += length;
}

canonical_original_code:
void Bitstream_Write(struct Bitstream *stream, unsigned int length, unsigned long value)
{
    Bitwalker_Write(stream->addr, stream->size, stream->bitpos, length, value);
    stream->bitpos += length;
}


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

result = Bitwalker_Read(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12), a2);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

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

result = Bitwalker_Read(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12), a2);
*(_DWORD *)(a1 + 12) += a2;
return result;
}


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

result = Bitwalker_Write(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12), a2, a3);
*(_DWORD *)(a1 + 12) += a2;
return result;
}

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

result = Bitwalker_Write(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12), a2, a3);
*(_DWORD *)(a1 + 12) += a2;
return result;
}


original_code:
static inline int TestBit64(uint64_t value, uint32_t pos)
{
    uint64_t mask = ((uint64_t) 1) << (63u - pos);
    uint64_t flag = value & mask;
    return flag != 0u;
}

canonical_original_code:
static inline int TestBit64(unsigned long value, unsigned int pos)
{
    unsigned long mask = ((uint64_t) 1) << (63u - pos);
    unsigned long flag = value & mask;
    return flag != 0u;
}

variable_types:
pos
unsigned int

variable_types:
mask
unsigned long

variable_types:
flag
unsigned long


decompiled_code:
unsigned __int64 __fastcall SetBit64(__int64 a1, char a2, int a3)
{
unsigned __int64 result; // rax

result = a1 | (0x8000000000000000LL >> a2);
if ( !a3 )
result = a1 & ~(0x8000000000000000LL >> a2);
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1, char a2, int a3)
{
unsigned __int64 result; // rax

result = a1 | (0x8000000000000000LL >> a2);
if ( !a3 )
result = a1 & ~(0x8000000000000000LL >> a2);
return result;
}

original_code:
static inline uint64_t SetBit64(uint64_t value, uint32_t pos, int flag)
{
    uint64_t mask = ((uint64_t) 1u) << (63 - pos);
    return (flag == 0) ? (value & ~mask) : (value | mask);
}

canonical_original_code:
static inline unsigned long SetBit64(unsigned long value, unsigned int pos, int flag)
{
    unsigned long mask = ((uint64_t) 1u) << (63 - pos);
    return (flag == 0) ? (value & ~mask) : (value | mask);
}

variable_types: flag int


decompiled_code:
__int64 __fastcall Bitstream_ReadThenWrite(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = Bitstream_Read();
*(_DWORD *)(a1 + 12) -= a2;
return Bitstream_Write(a1, a2, v2);
}

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

v2 = Bitstream_Read();
*(_DWORD *)(a1 + 12) -= a2;
return Bitstream_Write(a1, a2, v2);
}

original_code:
void Bitstream_ReadThenWrite(Bitstream* stream, uint32_t length)
{
    uint64_t value = Bitstream_Read(stream, length);
    stream->bitpos -= length;
    Bitstream_Write(stream, length, value);
}

canonical_original_code:
void Bitstream_ReadThenWrite(struct Bitstream *stream, unsigned int length)
{
    unsigned long value = Bitstream_Read(stream, length);
    stream->bitpos -= length;
    Bitstream_Write(stream, length, value);
}


decompiled_code:
__int64 __fastcall Bitstream_WriteThenRead(__int64 a1, __int64 a2, __int64 a3)
{
Bitstream_Write(a1, a2, a3);
*(_DWORD *)(a1 + 12) -= a2;
return Bitstream_Read(a1, (unsigned int)a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
Bitstream_Write(a1, a2, a3);
*(_DWORD *)(a1 + 12) -= a2;
return Bitstream_Read(a1, (unsigned int)a2);
}

original_code:
uint64_t Bitstream_WriteThenRead(Bitstream* stream, uint32_t length, uint64_t value)
{
    Bitstream_Write(stream, length, value);
    stream->bitpos -= length;
    uint64_t result = Bitstream_Read(stream, length);
    return result;
}

canonical_original_code:
unsigned long Bitstream_WriteThenRead(struct Bitstream *stream, unsigned int length, unsigned long value)
{
    Bitstream_Write(stream, length, value);
    stream->bitpos -= length;
    unsigned long result = Bitstream_Read(stream, length);
    return result;
}

variable_types:
result
unsigned long


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

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

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

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

variable_types:
MaxValue
unsigned long


repo: opencb-hpg/common-libs

decompiled_code:
void __fastcall set_log_verbose(int a1)
{
verbose = a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
verbose = a1;
}

original_code:
void set_log_verbose(int v) {
    verbose = v;
}

variable_types: v int


decompiled_code:
void __fastcall set_log_level(int a1)
{
log_level = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
log_level = a1;
}

original_code:
void set_log_level(int level) {
    log_level = level;
}

variable_types: level int


decompiled_code:
void __fastcall set_log_filename(char *src)
{
size_t v1; // rax
char *v2; // r12
size_t v3; // rax

if ( src )
{
if ( *src )
{
v1 = strlen(src);
v2 = (char *)calloc(v1 + 1, 1uLL);
log_filename = v2;
v3 = strlen(src);
strncat(v2, src, v3);
}
}
}

canonical_decompiled_code:
void __fastcall func2(char *src)
{
size_t v1; // rax
char *v2; // r12
size_t v3; // rax

if ( src )
{
if ( *src )
{
v1 = strlen(src);
v2 = (char *)calloc(v1 + 1, 1uLL);
log_filename = v2;
v3 = strlen(src);
strncat(v2, src, v3);
}
}
}

original_code:
void set_log_filename(char *filename) {
    if (filename != ((void *)0) && strlen(filename) > 0) {
        log_filename = (char*) calloc (strlen(filename) + 1, sizeof(char));
        strncat(log_filename, filename, strlen(filename));
    }
}

canonical_original_code:
void set_log_filename(char *filename) {
    if (filename != ((void *)0) && strlen(filename) > 0) {
        log_filename = (char *) calloc (strlen(filename) + 1, sizeof(char));
        strncat(log_filename, filename, strlen(filename));
    }
}

variable_types:
filename
char *


decompiled_code:
void init_log()
{
set_log_verbose(0);
set_log_level(2);
set_log_filename("output.log");
}

canonical_decompiled_code:
void func3()
{
func0(0);
func1(2);
func2("output.log");
}


decompiled_code:
void __fastcall init_log_custom(int a1, int a2)
{
char *v2; // rdx

set_log_level(a1);
set_log_verbose(a2);
set_log_filename(v2);
}

canonical_decompiled_code:
void __fastcall func4(int a1, int a2)
{
char *v2; // rdx

func1(a1);
func0(a2);
func2(v2);
}

original_code:
void init_log_custom(int level, int verbose, char* log_filename) {
    set_log_level(level);
    set_log_verbose(verbose);
    set_log_filename(log_filename);
}

canonical_original_code:
void init_log_custom(int level, int verbose, char *log_filename) {
    set_log_level(level);
    set_log_verbose(verbose);
    set_log_filename(log_filename);
}

variable_types: verbose int


decompiled_code:
void *__fastcall mmap_file(__off_t *a1, const char *a2)
{
int v3; // eax
__int64 v4; // rcx
int v5; // ebp
__int64 v6; // rdx
__off_t v7; // rsi
void *v8; // r12
struct stat v10; // [rsp+0h] [rbp-A8h] BYREF

v3 = open(a2, 0);
if ( v3 < 0 )
{
print_log_message_with_format(5LL, "FATAL", "file_utils.c", 10LL, "mmap_file", "Error opening file: %s\n", a2, v4);
goto LABEL_8;
}
v5 = v3;
if ( fstat(v3, &v10) )
{
print_log_message_with_format(
5LL,
"FATAL",
"file_utils.c",
15LL,
"mmap_file",
"Error while getting file information: %s\n",
a2,
v6);
goto LABEL_8;
}
v7 = v10.st_size;
*a1 = v10.st_size;
if ( v7 )
{
v8 = mmap(0LL, v7, 1, 2, v5, 0LL);
if ( v8 != (void *)-1LL )
{
close(v5);
return v8;
}
print_log_message_with_format(5LL, "FATAL", "file_utils.c", 26LL, "mmap_file", "mmap failed for %s\n", a2, -1LL);
LABEL_8:
exit(-1);
}
close(v5);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(__off_t *a1, const char *a2)
{
int v3; // eax
__int64 v4; // rcx
int v5; // ebp
__int64 v6; // rdx
__off_t v7; // rsi
void *v8; // r12
struct stat v10; // [rsp+0h] [rbp-A8h] BYREF

v3 = open(a2, 0);
if ( v3 < 0 )
{
print_log_message_with_format(5LL, "FATAL", "file_utils.c", 10LL, "mmap_file", "Error opening file: %s\n", a2, v4);
goto LABEL_8;
}
v5 = v3;
if ( fstat(v3, &v10) )
{
print_log_message_with_format(
5LL,
"FATAL",
"file_utils.c",
15LL,
"mmap_file",
"Error while getting file information: %s\n",
a2,
v6);
goto LABEL_8;
}
v7 = v10.st_size;
*a1 = v10.st_size;
if ( v7 )
{
v8 = mmap(0LL, v7, 1, 2, v5, 0LL);
if ( v8 != (void *)-1LL )
{
close(v5);
return v8;
}
print_log_message_with_format(5LL, "FATAL", "file_utils.c", 26LL, "mmap_file", "mmap failed for %s\n", a2, -1LL);
LABEL_8:
exit(-1);
}
close(v5);
return 0LL;
}

original_code:
void *mmap_file(size_t *len, const char *filename) {
    int fd = open(filename, 00);
    if (fd < 0) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 10, __func__, "Error opening file: %s\n", filename); exit(-1); };
    }
    struct stat st[1];
    if (fstat(fd, st)) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 15, __func__, "Error while getting file information: %s\n", filename); exit(-1); };
    }
    *len = (size_t) st->st_size;
    if (!*len) {
        close(fd);
        return ((void *)0);
    }
    void *map = mmap(((void *)0), *len, 0x1, 0x02, fd, 0);
    if (((void *) -1) == map) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 26, __func__, "mmap failed for %s\n", filename); exit(-1); };
    }
    close(fd);
    return map;
}

canonical_original_code:
void *mmap_file(unsigned long *len, char *filename) {
    int fd = open(filename, 00);
    if (fd < 0) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 10, __func__, "Error opening file: %s\n", filename); exit(-1); };
    }
    struct stat st[1];
    if (fstat(fd, st)) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 15, __func__, "Error while getting file information: %s\n", filename); exit(-1); };
    }
    *len = (unsigned long) st->st_size;
    if (!*len) {
        close(fd);
        return ((void *)0);
    }
    void *map = mmap(((void *)0), *len, 0x1, 0x02, fd, 0);
    if (((void *) -1) == map) {
        { print_log_message_with_format(5, "FATAL", "file_utils.c", 26, __func__, "mmap failed for %s\n", filename); exit(-1); };
    }
    close(fd);
    return map;
}

variable_types:
len
unsigned long *

variable_types: fd int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; } [1]

variable_types:
map
void *

return_type: void *


decompiled_code:
int __fastcall create_directory(const char *a1)
{
return mkdir(a1, 0x1FDu);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
return mkdir(a1, 0x1FDu);
}

variable_types:
path
char *


decompiled_code:
// attributes: thunk
int delete_directory(const char *path)
{
return rmdir(path);
}

canonical_decompiled_code:
int func4(const char *path)
{
return rmdir(path);
}

original_code:
int delete_directory(const char* path) {
    return rmdir(path);
}

canonical_original_code:
int delete_directory(char *path) {
    return rmdir(path);
}


decompiled_code:
char *__fastcall get_filename_from_path(char *src, char *dest)
{
char *v2; // rax
char *v3; // rdx
__int64 v4; // rax
char *result; // rax

v2 = strrchr(src, 47);
if ( v2 )
{
v3 = v2;
v4 = 1LL;
if ( *v3 )
{
do
{
dest[v4 - 1] = v3[v4];
++v4;
}
while ( v3[v4 - 1] );
}
result = dest;
}
else
{
strcpy(dest, src);
result = dest;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func7(char *src, char *dest)
{
char *v2; // rax
char *v3; // rdx
__int64 v4; // rax
char *result; // rax

v2 = strrchr(src, 47);
if ( v2 )
{
v3 = v2;
v4 = 1LL;
if ( *v3 )
{
do
{
dest[v4 - 1] = v3[v4];
++v4;
}
while ( v3[v4 - 1] );
}
result = dest;
}
else
{
strcpy(dest, src);
result = dest;
}
return result;
}

original_code:
char* get_filename_from_path(char* path, char* filename_p) {
    int i = 0;
    char* char_p = strrchr(path, '/');
    if (char_p == ((void *)0)) {
        strcpy(filename_p, path);
    } else {
        while (*char_p != '\0') {
            char_p++;
            filename_p[i++] = *char_p;
        }
    }
    return filename_p;
}

canonical_original_code:
char *get_filename_from_path(char *path, char *filename_p) {
    int i = 0;
    char *char_p = strrchr(path, '/');
    if (char_p == ((void *)0)) {
        strcpy(filename_p, path);
    } else {
        while (*char_p != '\0') {
            char_p++;
            filename_p[i++] = *char_p;
        }
    }
    return filename_p;
}

variable_types: i int

return_type: char *


decompiled_code:
// attributes: thunk
void result_item_free(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func0(void *ptr)
{
free(ptr);
}

original_code:
void result_item_free(result_item_t *result_item_p) {
  free(result_item_p);
}

canonical_original_code:
void result_item_free(struct result_item *result_item_p) {
  free(result_item_p);
}

variable_types: struct result_item { char *name; char *value; char *title; char *data_type; char *tags; char *group; char *context; enum ITEM_TYPE { META_TYPE=0, INPUT_TYPE=1, OUTPUT_TYPE=2 } item_type; struct result_item *next_p; } *

user_defined_types: struct result_item { char *name; char *value; char *title; char *data_type; char *tags; char *group; char *context; enum ITEM_TYPE item_type; struct result_item *next_p; }


decompiled_code:
int __fastcall result_item_print(__int64 a1)
{
return printf(
"%s\t%s\t%s\t%s\t%s\t%s\t%s\t%i\n",
*(const char **)a1,
*(const char **)(a1 + 8),
*(const char **)(a1 + 16),
*(const char **)(a1 + 24),
*(const char **)(a1 + 32),
*(const char **)(a1 + 40),
*(const char **)(a1 + 48),
*(unsigned int *)(a1 + 56));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
return printf(
"%s\t%s\t%s\t%s\t%s\t%s\t%s\t%i\n",
*(const char **)a1,
*(const char **)(a1 + 8),
*(const char **)(a1 + 16),
*(const char **)(a1 + 24),
*(const char **)(a1 + 32),
*(const char **)(a1 + 40),
*(const char **)(a1 + 48),
*(unsigned int *)(a1 + 56));
}

original_code:
void result_item_print(result_item_t *result_item_p) {
  printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%i\n", result_item_p->name, result_item_p->value,
  result_item_p->title, result_item_p->data_type, result_item_p->tags, result_item_p->group, result_item_p->context, result_item_p->item_type);
}

canonical_original_code:
void result_item_print(struct result_item *result_item_p) {
  printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%i\n", result_item_p->name, result_item_p->value,
  result_item_p->title, result_item_p->data_type, result_item_p->tags, result_item_p->group, result_item_p->context, result_item_p->item_type);
}

user_defined_types: enum ITEM_TYPE { META_TYPE=0, INPUT_TYPE=1, OUTPUT_TYPE=2 }


decompiled_code:
void __fastcall result_file_free(void *ptr)
{
_QWORD *i; // rdi

for ( i = (_QWORD *)*((_QWORD *)ptr + 2); i; i = (_QWORD *)*((_QWORD *)ptr + 2) )
{
*((_QWORD *)ptr + 2) = i[8];
result_item_free(i);
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
_QWORD *i; // rdi

for ( i = (_QWORD *)*((_QWORD *)ptr + 2); i; i = (_QWORD *)*((_QWORD *)ptr + 2) )
{
*((_QWORD *)ptr + 2) = i[8];
func0(i);
}
free(ptr);
}

original_code:
void result_file_free(result_file_t *result_file_p) {
  result_item_t *result_item_aux_p = result_file_p->result_item_first_p;
  while(result_item_aux_p != ((void *)0)) {
    result_file_p->result_item_first_p = result_item_aux_p->next_p;
    result_item_free(result_item_aux_p);
    result_item_aux_p = result_file_p->result_item_first_p;
  }
  free(result_file_p);
}

canonical_original_code:
void result_file_free(struct result_file *result_file_p) {
  struct result_item *result_item_aux_p = result_file_p->result_item_first_p;
  while(result_item_aux_p != ((void *)0)) {
    result_file_p->result_item_first_p = result_item_aux_p->next_p;
    result_item_free(result_item_aux_p);
    result_item_aux_p = result_file_p->result_item_first_p;
  }
  free(result_file_p);
}

variable_types: struct result_file { char *version; char *filename; struct result_item { char *name; char *value; char *title; char *data_type; char *tags; char *group; char *context; enum ITEM_TYPE { META_TYPE=0, INPUT_TYPE=1, OUTPUT_TYPE=2 } item_type; struct result_item *next_p; } *result_item_first_p; struct result_item *result_item_last_p; } *

user_defined_types: struct result_file { char *version; char *filename; struct result_item *result_item_first_p; struct result_item *result_item_last_p; }


decompiled_code:
__int64 result_file_read()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 1LL;
}

original_code:
int result_file_read(result_file_t *result_file) {
    return 1;
}

canonical_original_code:
int result_file_read(struct result_file *result_file) {
    return 1;
}


decompiled_code:
int __fastcall result_file_print(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = *(_QWORD *)(a1 + 16); i; i = *(_QWORD *)(i + 64) )
result = result_item_print(i);
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = *(_QWORD *)(a1 + 16); i; i = *(_QWORD *)(i + 64) )
result = func1(i);
return result;
}

original_code:
void result_file_print(result_file_t *result_file) {
    result_item_t *result_item_aux_p = result_file->result_item_first_p;
    while(result_item_aux_p != ((void *)0)) {
      result_item_print(result_item_aux_p);
      result_item_aux_p = result_item_aux_p->next_p;
    }
}

canonical_original_code:
void result_file_print(struct result_file *result_file) {
    struct result_item *result_item_aux_p = result_file->result_item_first_p;
    while(result_item_aux_p != ((void *)0)) {
      result_item_print(result_item_aux_p);
      result_item_aux_p = result_item_aux_p->next_p;
    }
}


original_code:
int result_add_item(result_item_t *item, result_file_t *result_file) {
  item->next_p = ((void *)0);
  if(result_file->result_item_first_p == ((void *)0)) {
    result_file->result_item_first_p = item;
  }else {
    result_file->result_item_last_p->next_p = item;
  }
  result_file->result_item_last_p = item;
  return 1;
}

canonical_original_code:
int result_add_item(struct result_item *item, struct result_file *result_file) {
  item->next_p = ((void *)0);
  if(result_file->result_item_first_p == ((void *)0)) {
    result_file->result_item_first_p = item;
  }else {
    result_file->result_item_last_p->next_p = item;
  }
  result_file->result_item_last_p = item;
  return 1;
}

variable_types: struct result_file { char *version; char *filename; struct result_item *result_item_first_p; struct result_item *result_item_last_p; } *


decompiled_code:
__int64 __fastcall result_add_meta_item(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 56) = 0;
return result_add_item(a1, a2);
}

original_code:
int result_add_meta_item(result_item_t *meta_item, result_file_t *result_file) {
  meta_item->item_type = META_TYPE;
  return result_add_item(meta_item, result_file);
}

canonical_original_code:
int result_add_meta_item(struct result_item *meta_item, struct result_file *result_file) {
  meta_item->item_type = META_TYPE;
  return result_add_item(meta_item, result_file);
}


decompiled_code:
__int64 __fastcall result_add_input_item(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 56) = 1;
return result_add_item(a1, a2);
}

original_code:
int result_add_input_item(result_item_t* input_item, result_file_t *result_file) {
  input_item->item_type = INPUT_TYPE;
  return result_add_item(input_item, result_file);
}

canonical_original_code:
int result_add_input_item(struct result_item *input_item, struct result_file *result_file) {
  input_item->item_type = INPUT_TYPE;
  return result_add_item(input_item, result_file);
}


decompiled_code:
__int64 __fastcall result_add_output_item(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 56) = 2;
return result_add_item(a1, a2);
}

original_code:
int result_add_output_item(result_item_t* output_item, result_file_t *result_file) {
  output_item->item_type = OUTPUT_TYPE;
  return result_add_item(output_item, result_file);
}

canonical_original_code:
int result_add_output_item(struct result_item *output_item, struct result_file *result_file) {
  output_item->item_type = OUTPUT_TYPE;
  return result_add_item(output_item, result_file);
}


decompiled_code:
unsigned __int64 __fastcall get_estimated_memory_needed(int a1, int a2, int a3)
{
__int64 v3; // rdx
unsigned __int64 result; // rax
unsigned __int64 v5; // r12
unsigned __int64 v6; // r12
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

v3 = a2 * a3;
if ( a1 == 1 )
{
v6 = 4 * v3 / 0x3E8uLL;
sprintf(v7, "required memory (KB): %li\n", v6);
print_log_message(1LL, "DEBUG", "system_utils.c", 41LL, "get_estimated_memory_needed", v7);
result = v6;
}
else if ( a1 == 2 )
{
v5 = 6 * v3 / 0x3E8uLL;
sprintf(v7, "required memory (KB): %li\n", v5);
print_log_message(1LL, "DEBUG", "system_utils.c", 46LL, "get_estimated_memory_needed", v7);
result = v5;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(int a1, int a2, int a3)
{
__int64 v3; // rdx
unsigned __int64 result; // rax
unsigned __int64 v5; // r12
unsigned __int64 v6; // r12
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

v3 = a2 * a3;
if ( a1 == 1 )
{
v6 = 4 * v3 / 0x3E8uLL;
sprintf(v7, "required memory (KB): %li\n", v6);
print_log_message(1LL, "DEBUG", "system_utils.c", 41LL, "get_estimated_memory_needed", v7);
result = v6;
}
else if ( a1 == 2 )
{
v5 = 6 * v3 / 0x3E8uLL;
sprintf(v7, "required memory (KB): %li\n", v5);
print_log_message(1LL, "DEBUG", "system_utils.c", 46LL, "get_estimated_memory_needed", v7);
result = v5;
}
else
{
result = 0LL;
}
return result;
}

original_code:
unsigned long int get_estimated_memory_needed(int process, int batch_size, int max_list_length) {
    unsigned long int list_memory = max_list_length * batch_size;
    char log_message[50];
    if (process == 1) {
        sprintf(log_message, "required memory (KB): %li\n", 4 * list_memory / 1000);
        { print_log_message(1, "DEBUG", "system_utils.c", 41, __func__, log_message); };
        return 4 * list_memory / 1000;
    } else if (process == 2) {
        sprintf(log_message, "required memory (KB): %li\n", 6 * list_memory / 1000);
        { print_log_message(1, "DEBUG", "system_utils.c", 46, __func__, log_message); };
        return 6 * list_memory / 1000;
    } else { return 0; }
}

canonical_original_code:
unsigned long get_estimated_memory_needed(int process, int batch_size, int max_list_length) {
    unsigned long list_memory = max_list_length * batch_size;
    char log_message[50];
    if (process == 1) {
        sprintf(log_message, "required memory (KB): %li\n", 4 * list_memory / 1000);
        { print_log_message(1, "DEBUG", "system_utils.c", 41, __func__, log_message); };
        return 4 * list_memory / 1000;
    } else if (process == 2) {
        sprintf(log_message, "required memory (KB): %li\n", 6 * list_memory / 1000);
        { print_log_message(1, "DEBUG", "system_utils.c", 46, __func__, log_message); };
        return 6 * list_memory / 1000;
    } else { return 0; }
}

variable_types: process int


decompiled_code:
__int64 __fastcall get_max_estimated_alignments_by_chromosome(const char *a1)
{
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

stat(a1, &v2);
return (unsigned int)(int)((double)(int)(v2.st_size / 100) * 1.4 / 12.0);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

stat(a1, &v2);
return (unsigned int)(int)((double)(int)(v2.st_size / 100) * 1.4 / 12.0);
}

original_code:
int get_max_estimated_alignments_by_chromosome(char* input_filename) {
    int max_estimated_alignments;
    struct stat st;
    stat(input_filename, &st);
    max_estimated_alignments = (int)(1.4 * (st.st_size / 100) / 12);
    return max_estimated_alignments;
}

canonical_original_code:
int get_max_estimated_alignments_by_chromosome(char *input_filename) {
    int max_estimated_alignments;
    struct stat st;
    stat(input_filename, &st);
    max_estimated_alignments = (int)(1.4 * (st.st_size / 100) / 12);
    return max_estimated_alignments;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }


decompiled_code:
__int64 get_optimal_gpu_num_threads()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
int get_optimal_gpu_num_threads() {
    int optimal_gpu_num_threads = 0;
    return optimal_gpu_num_threads;
}


decompiled_code:
__int64 __fastcall get_optimal_batch_size(int a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // er8
__int64 result; // rax
unsigned __int64 v5; // rax
unsigned int v6; // er8
unsigned __int64 v7; // rax

v2 = get_free_memory();
if ( a1 == 1 )
{
v6 = -1;
v7 = 1000 * v2 / (unsigned __int64)(4 * a2);
if ( v7 <= 0x7FFFFFFFFFFFFFFFLL )
v6 = v7;
result = v6;
}
else
{
if ( a1 == 2 )
{
v3 = -1;
v5 = 1000 * v2 / (unsigned __int64)(6 * a2);
if ( v5 <= 0x7FFFFFFFFFFFFFFFLL )
v3 = v5;
}
else
{
v3 = 0;
if ( a1 == 3 )
return (unsigned int)(1000 * v2 / 0x14uLL);
}
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // er8
__int64 result; // rax
unsigned __int64 v5; // rax
unsigned int v6; // er8
unsigned __int64 v7; // rax

v2 = func0();
if ( a1 == 1 )
{
v6 = -1;
v7 = 1000 * v2 / (unsigned __int64)(4 * a2);
if ( v7 <= 0x7FFFFFFFFFFFFFFFLL )
v6 = v7;
result = v6;
}
else
{
if ( a1 == 2 )
{
v3 = -1;
v5 = 1000 * v2 / (unsigned __int64)(6 * a2);
if ( v5 <= 0x7FFFFFFFFFFFFFFFLL )
v3 = v5;
}
else
{
v3 = 0;
if ( a1 == 3 )
return (unsigned int)(1000 * v2 / 0x14uLL);
}
result = v3;
}
return result;
}

original_code:
int get_optimal_batch_size(int process, int max_list_length) {
    unsigned long int optimal_batch_size = 0;
    unsigned long int gpu_global_memory = (0x7fffffffffffffffLL * 2ULL + 1ULL);
    unsigned long int free_memory = get_free_memory();
    if (process == 1) {
        optimal_batch_size = (1000 * free_memory) / (4 * max_list_length);
    } else if (process == 2) {
        optimal_batch_size = (1000 * free_memory) / (6 * max_list_length);
    } else if (process == 3) {
        optimal_batch_size = 1000 * free_memory / 20;
    }
    unsigned long int size = (((optimal_batch_size) < ((gpu_global_memory / 2))) ? (optimal_batch_size) : ((gpu_global_memory / 2)));
    return (int) size;
}

canonical_original_code:
int get_optimal_batch_size(int process, int max_list_length) {
    unsigned long optimal_batch_size = 0;
    unsigned long gpu_global_memory = (0x7fffffffffffffffLL * 2ULL + 1ULL);
    unsigned long free_memory = get_free_memory();
    if (process == 1) {
        optimal_batch_size = (1000 * free_memory) / (4 * max_list_length);
    } else if (process == 2) {
        optimal_batch_size = (1000 * free_memory) / (6 * max_list_length);
    } else if (process == 3) {
        optimal_batch_size = 1000 * free_memory / 20;
    }
    unsigned long size = (((optimal_batch_size) < ((gpu_global_memory / 2))) ? (optimal_batch_size) : ((gpu_global_memory / 2)));
    return (int) size;
}

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall init_http_environment(int a1)
{
__int64 result; // rax

if ( a1 )
result = curl_global_init(1LL);
else
result = curl_global_init(0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 result; // rax

if ( a1 )
result = curl_global_init(1LL);
else
result = curl_global_init(0LL);
return result;
}

original_code:
int init_http_environment(int ssl) {
    if (ssl) {
        return curl_global_init((1<<0));
    } else {
        return curl_global_init(0);
    }
}

variable_types: ssl int


decompiled_code:
// attributes: thunk
__int64 __fastcall get_last_http_error(__int64 a1)
{
return curl_easy_strerror(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return curl_easy_strerror(a1);
}

original_code:
const char *get_last_http_error(int err_code) {
    return curl_easy_strerror(err_code);
}


cummin

repo: opencb-hpg/math

original_code:
double *cummin(const double *data, size_t n, double *res) {
    double min = (__builtin_inff ());
    size_t i;
    for(i = 0 ; i < n; i++ ) {
        if (__builtin_isnan (data[i]) || __builtin_isnan (min)) {
            min = min + data[i];
        }else {
            min = (min < data[i]) ? min : data[i];
            res[i] = min;
        }
    }
    return res;
}

canonical_original_code:
double *cummin(double *data, unsigned long n, double *res) {
    double min = (__builtin_inff ());
    unsigned long i;
    for(i = 0 ; i < n; i++ ) {
        if (__builtin_isnan (data[i]) || __builtin_isnan (min)) {
            min = min + data[i];
        }else {
            min = (min < data[i]) ? min : data[i];
            res[i] = min;
        }
    }
    return res;
}

variable_types:
data
double *

variable_types:
n
unsigned long

variable_types:
res
double *

variable_types: min double

variable_types:
i
unsigned long

return_type: double *


cummax

original_code:
double *cummax(const double *data, size_t n, double *res) {
    double max = (__builtin_inff ());
    size_t i;
    for(i = 0 ; i < n; i++ ) {
        if(__builtin_isnan (data[i]) || __builtin_isnan (max)) {
            max = max + data[i];
        }else{
            max = (max > data[i]) ? max : data[i];
            res[i] = max;
        }
    }
    return res;
}

canonical_original_code:
double *cummax(double *data, unsigned long n, double *res) {
    double max = (__builtin_inff ());
    unsigned long i;
    for(i = 0 ; i < n; i++ ) {
        if(__builtin_isnan (data[i]) || __builtin_isnan (max)) {
            max = max + data[i];
        }else{
            max = (max > data[i]) ? max : data[i];
            res[i] = max;
        }
    }
    return res;
}

variable_types: max double


cumsum

original_code:
double *cumsum(const double *data, size_t n, double *res) {
    double sum = 0;
    size_t i;
    for(i=0; i < n; i++) {
        sum += data[i];
        res[i] = sum;
    }
    return res;
}

canonical_original_code:
double *cumsum(double *data, unsigned long n, double *res) {
    double sum = 0;
    unsigned long i;
    for(i=0; i < n; i++) {
        sum += data[i];
        res[i] = sum;
    }
    return res;
}

variable_types: sum double


pmin

decompiled_code:
__int64 __fastcall pmin(__int64 a1, __int64 a2, __int64 a3, double a4)
{
__int64 i; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
*(double *)(a3 + 8 * i) = fmin(a4, *(double *)(a1 + 8 * i));
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, double a4)
{
__int64 i; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
*(double *)(a3 + 8 * i) = fmin(a4, *(double *)(a1 + 8 * i));
}
return a3;
}

original_code:
double *pmin(const double *data, size_t n, double min, double *res) {
    size_t i;
    for(i = 0; i < n; i++) {
        res[i] = (min < data[i]) ? min : data[i];
    }
    return res;
}

canonical_original_code:
double *pmin(double *data, unsigned long n, double min, double *res) {
    unsigned long i;
    for(i = 0; i < n; i++) {
        res[i] = (min < data[i]) ? min : data[i];
    }
    return res;
}


pmax

decompiled_code:
__int64 __fastcall pmax(__int64 a1, __int64 a2, __int64 a3, double a4)
{
__int64 i; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
*(double *)(a3 + 8 * i) = fmax(a4, *(double *)(a1 + 8 * i));
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, double a4)
{
__int64 i; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
*(double *)(a3 + 8 * i) = fmax(a4, *(double *)(a1 + 8 * i));
}
return a3;
}

original_code:
double *pmax(const double *data, size_t n, double max, double *res) {
    size_t i;
    for(i = 0; i < n; i++) {
        res[i] = (max > data[i]) ? max : data[i];
    }
    return res;
}

canonical_original_code:
double *pmax(double *data, unsigned long n, double max, double *res) {
    unsigned long i;
    for(i = 0; i < n; i++) {
        res[i] = (max > data[i]) ? max : data[i];
    }
    return res;
}


decompiled_code:
__int64 __fastcall pearson_correlation(__int64 a1, __int64 a2, double a3)
{
__int64 result; // rax

if ( a3 >= 9.223372036854776e18 )
result = gsl_stats_correlation(
a1,
1LL,
a2,
1LL,
(unsigned int)(int)(a3 - 9.223372036854776e18) ^ 0x8000000000000000LL);
else
result = gsl_stats_correlation(a1, 1LL, a2, 1LL, (unsigned int)(int)a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, double a3)
{
__int64 result; // rax

if ( a3 >= 9.223372036854776e18 )
result = gsl_stats_correlation(
a1,
1LL,
a2,
1LL,
(unsigned int)(int)(a3 - 9.223372036854776e18) ^ 0x8000000000000000LL);
else
result = gsl_stats_correlation(a1, 1LL, a2, 1LL, (unsigned int)(int)a3);
return result;
}

original_code:
double pearson_correlation(double* values1, double* values2, double size) {
    return gsl_stats_correlation(values1, 1, values2, 1, size);
}

canonical_original_code:
double pearson_correlation(double *values1, double *values2, double size) {
    return gsl_stats_correlation(values1, 1, values2, 1, size);
}

variable_types: size double

return_type: double


decompiled_code:
double *__fastcall ttest_two_sided_one_sample(double *a1, __m128 a2, double a3, double a4, double a5)
{
double v5; // xmm0_8
double v6; // xmm0_8
double *result; // rax

v5 = COERCE_DOUBLE(ttest_one_sample(a2, a3, a4, a5));
*a1 = v5;
a1[1] = a5 - 1.0;
v6 = gsl_cdf_tdist_P(COERCE_DOUBLE(*(_QWORD *)&v5 | LC3));
result = a1;
a1[2] = v6 + v6;
return result;
}

canonical_decompiled_code:
double *__fastcall func0(double *a1, __m128 a2, double a3, double a4, double a5)
{
double v5; // xmm0_8
double v6; // xmm0_8
double *result; // rax

v5 = COERCE_DOUBLE(ttest_one_sample(a2, a3, a4, a5));
*a1 = v5;
a1[1] = a5 - 1.0;
v6 = gsl_cdf_tdist_P(COERCE_DOUBLE(*(_QWORD *)&v5 | LC3));
result = a1;
a1[2] = v6 + v6;
return result;
}

original_code:
ttest_result_t* ttest_two_sided_one_sample(double mean, double mu, double var, double n, ttest_result_t* ttest_result) {
    ttest_result->statistic = ttest_one_sample(mean, mu, var, n);
    ttest_result->degrees_of_freedom = n - 1;
    ttest_result->p_value = 2.0 * gsl_cdf_tdist_P((-1) * fabs(ttest_result->statistic), ttest_result->degrees_of_freedom);
    return ttest_result;
}

canonical_original_code:
struct ttest_result *ttest_two_sided_one_sample(double mean, double mu, double var, double n, struct ttest_result *ttest_result) {
    ttest_result->statistic = ttest_one_sample(mean, mu, var, n);
    ttest_result->degrees_of_freedom = n - 1;
    ttest_result->p_value = 2.0 * gsl_cdf_tdist_P((-1) * fabs(ttest_result->statistic), ttest_result->degrees_of_freedom);
    return ttest_result;
}

variable_types: mean double

variable_types: mu double

variable_types: var double

variable_types: n double

return_type: struct ttest_result { double statistic; double degrees_of_freedom; double p_value; } *


decompiled_code:
__int64 __fastcall ttest_two_sided_two_samples(__int64 a1, __m128 a2, double a3, double a4, double a5, double a6, double a7)
{
__int64 v7; // xmm0_8
__int64 v8; // xmm7_8
double v9; // xmm0_8
__int64 result; // rax

v7 = ttest_two_samples(a2, a3, a4, a5, a6, a7);
*(_QWORD *)a1 = v7;
v8 = v7;
*(_QWORD *)(a1 + 8) = degrees_of_freedom((__m128)*(unsigned __int64 *)&a4, a5, a6, a7);
v9 = gsl_cdf_tdist_P(COERCE_DOUBLE(v8 | LC3));
result = a1;
*(double *)(a1 + 16) = v9 + v9;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __m128 a2, double a3, double a4, double a5, double a6, double a7)
{
__int64 v7; // xmm0_8
__int64 v8; // xmm7_8
double v9; // xmm0_8
__int64 result; // rax

v7 = ttest_two_samples(a2, a3, a4, a5, a6, a7);
*(_QWORD *)a1 = v7;
v8 = v7;
*(_QWORD *)(a1 + 8) = degrees_of_freedom((__m128)*(unsigned __int64 *)&a4, a5, a6, a7);
v9 = gsl_cdf_tdist_P(COERCE_DOUBLE(v8 | LC3));
result = a1;
*(double *)(a1 + 16) = v9 + v9;
return result;
}

original_code:
ttest_result_t* ttest_two_sided_two_samples(double mean1, double mean2, double var1, double var2, double n1, double n2, ttest_result_t* ttest_result) {
    ttest_result->statistic = ttest_two_samples(mean1, mean2, var1, var2, n1, n2);
    ttest_result->degrees_of_freedom = degrees_of_freedom(var1, var2, n1, n2);
    ttest_result->p_value = 2.0 * gsl_cdf_tdist_P((-1) * fabs(ttest_result->statistic), ttest_result->degrees_of_freedom);
    return ttest_result;
}

canonical_original_code:
struct ttest_result *ttest_two_sided_two_samples(double mean1, double mean2, double var1, double var2, double n1, double n2, struct ttest_result *ttest_result) {
    ttest_result->statistic = ttest_two_samples(mean1, mean2, var1, var2, n1, n2);
    ttest_result->degrees_of_freedom = degrees_of_freedom(var1, var2, n1, n2);
    ttest_result->p_value = 2.0 * gsl_cdf_tdist_P((-1) * fabs(ttest_result->statistic), ttest_result->degrees_of_freedom);
    return ttest_result;
}

user_defined_types: struct ttest_result { double statistic; double degrees_of_freedom; double p_value; }


decompiled_code:
void __fastcall anova_results_free(int a1, void **a2)
{
void **v2; // rbx
__int64 v3; // rbp
void *v4; // rdi

if ( a2 )
{
if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
v4 = *v2++;
free(v4);
}
while ( v2 != (void **)v3 );
}
free(a2);
}
}

canonical_decompiled_code:
void __fastcall func1(int a1, void **a2)
{
void **v2; // rbx
__int64 v3; // rbp
void *v4; // rdi

if ( a2 )
{
if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
v4 = *v2++;
free(v4);
}
while ( v2 != (void **)v3 );
}
free(a2);
}
}

original_code:
void anova_results_free(int num_rows, anova_result_t** anova_results) {
    if (anova_results == ((void *)0)) {
        return;
    }
    for (int i = 0; i < num_rows; i++) {
        free(anova_results[i]);
    }
    free(anova_results);
}

canonical_original_code:
void anova_results_free(int num_rows, struct anova_result **anova_results) {
    if (anova_results == ((void *)0)) {
        return;
    }
    for (int i = 0; i < num_rows; i++) {
        free(anova_results[i]);
    }
    free(anova_results);
}

variable_types: struct anova_result { double statistic; int dfbg; int dfwg; double p_value; } **

variable_types: i int


decompiled_code:
__int64 __fastcall anova_results_get_statistics(int a1, __int64 a2, __int64 a3)
{
__int64 i; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
*(_QWORD *)(a3 + 8 * i) = **(_QWORD **)(a2 + 8 * i);
}
return a3;
}

original_code:
double* anova_results_get_statistics(int num_rows, anova_result_t** anova_results, double* statistics) {
    for (int i = 0; i < num_rows; i++) {
        statistics[i] = anova_results[i]->statistic;
    }
    return statistics;
}

canonical_original_code:
double *anova_results_get_statistics(int num_rows, struct anova_result **anova_results, double *statistics) {
    for (int i = 0; i < num_rows; i++) {
        statistics[i] = anova_results[i]->statistic;
    }
    return statistics;
}

variable_types:
statistics
double *

user_defined_types: struct anova_result { double statistic; int dfbg; int dfwg; double p_value; }


decompiled_code:
__int64 __fastcall anova_results_get_p_values(int a1, __int64 a2, __int64 a3)
{
__int64 i; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
*(_QWORD *)(a3 + 8 * i) = *(_QWORD *)(*(_QWORD *)(a2 + 8 * i) + 16LL);
}
return a3;
}

original_code:
double* anova_results_get_p_values(int num_rows, anova_result_t** anova_results, double* p_values) {
    for (int i = 0; i < num_rows; i++) {
        p_values[i] = anova_results[i]->p_value;
    }
    return p_values;
}

canonical_original_code:
double *anova_results_get_p_values(int num_rows, struct anova_result **anova_results, double *p_values) {
    for (int i = 0; i < num_rows; i++) {
        p_values[i] = anova_results[i]->p_value;
    }
    return p_values;
}


decompiled_code:
void __fastcall correlation_matrix_free(__int64 a1, void **a2)
{
_QWORD *v2; // r8
__int64 i; // rbx
void *v5; // rdi

if ( a2 )
{
v2 = *a2;
if ( *a2 )
{
if ( a1 )
{
for ( i = 0LL; i != a1; ++i )
{
v5 = (void *)v2[i];
if ( v5 )
{
free(v5);
v2 = *a2;
*((_QWORD *)*a2 + i) = 0LL;
}
}
}
free(v2);
free(a2);
}
}
}

original_code:
void correlation_matrix_free(size_t num_rows, correlation_matrix_t* correlation_matrix_p) {
    if ((correlation_matrix_p == ((void *)0)) || (correlation_matrix_p->values == ((void *)0))) {
        return;
    }
    for (size_t i = 0; i < num_rows; i++) {
        if (correlation_matrix_p->values[i] != ((void *)0)) {
            free(correlation_matrix_p->values[i]);
            correlation_matrix_p->values[i] = ((void *)0);
        }
    }
    free(correlation_matrix_p->values);
    correlation_matrix_p->values = ((void *)0);
    free(correlation_matrix_p);
    correlation_matrix_p = ((void *)0);
    return;
}

canonical_original_code:
void correlation_matrix_free(unsigned long num_rows, struct correlation_matrix *correlation_matrix_p) {
    if ((correlation_matrix_p == ((void *)0)) || (correlation_matrix_p->values == ((void *)0))) {
        return;
    }
    for (unsigned long i = 0; i < num_rows; i++) {
        if (correlation_matrix_p->values[i] != ((void *)0)) {
            free(correlation_matrix_p->values[i]);
            correlation_matrix_p->values[i] = ((void *)0);
        }
    }
    free(correlation_matrix_p->values);
    correlation_matrix_p->values = ((void *)0);
    free(correlation_matrix_p);
    correlation_matrix_p = ((void *)0);
    return;
}

variable_types: struct correlation_matrix { float **values; } *


decompiled_code:
__int64 __fastcall stats_mean(__int64 a1, __int64 a2)
{
return gsl_stats_mean(a1, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return gsl_stats_mean(a1, 1LL, a2);
}

original_code:
double stats_mean(const double* values, size_t length) {
    return gsl_stats_mean(values, 1, length);
}

canonical_original_code:
double stats_mean(double *values, unsigned long length) {
    return gsl_stats_mean(values, 1, length);
}

variable_types:
values
double *

variable_types:
length
unsigned long


decompiled_code:
__int64 __fastcall stats_variance(__int64 a1, __int64 a2)
{
return gsl_stats_variance(a1, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return gsl_stats_variance(a1, 1LL, a2);
}

original_code:
double stats_variance(const double* values, size_t length) {
    return gsl_stats_variance(values, 1, length);
}

canonical_original_code:
double stats_variance(double *values, unsigned long length) {
    return gsl_stats_variance(values, 1, length);
}


decompiled_code:
__int64 __fastcall stats_median_sorted_values(__int64 a1, __int64 a2)
{
return gsl_stats_median_from_sorted_data(a1, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return gsl_stats_median_from_sorted_data(a1, 1LL, a2);
}

original_code:
double stats_median_sorted_values(const double* values, size_t length) {
    return gsl_stats_median_from_sorted_data(values, 1, length);
}

canonical_original_code:
double stats_median_sorted_values(double *values, unsigned long length) {
    return gsl_stats_median_from_sorted_data(values, 1, length);
}


decompiled_code:
__int64 __fastcall stats_median(__int64 a1, __int64 a2)
{
gsl_sort(a1, 1LL, a2);
return stats_median_sorted_values(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
gsl_sort(a1, 1LL, a2);
return func2(a1, a2);
}

original_code:
double stats_median(double* values, size_t length) {
    gsl_sort(values, 1, length);
    return stats_median_sorted_values(values, length);
}

canonical_original_code:
double stats_median(double *values, unsigned long length) {
    gsl_sort(values, 1, length);
    return stats_median_sorted_values(values, length);
}


decompiled_code:
__int64 __fastcall stats_percentile_sorted_values(__int64 a1, __int64 a2, double a3)
{
if ( a3 <= 100.0 && a3 >= 0.0 )
_assert_fail(
"(percentile > 100) || (percentile < 0)",
"stats/statistics.c",
0x23u,
"stats_percentile_sorted_values");
return gsl_stats_quantile_from_sorted_data(a1, 1LL, a2, a3 / 100.0);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, double a3)
{
if ( a3 <= 100.0 && a3 >= 0.0 )
_assert_fail(
"(percentile > 100) || (percentile < 0)",
"stats/statistics.c",
0x23u,
"stats_percentile_sorted_values");
return gsl_stats_quantile_from_sorted_data(a1, 1LL, a2, a3 / 100.0);
}

original_code:
double stats_percentile_sorted_values(const double* values, size_t length, double percentile) {
    (((percentile > 100) || (percentile < 0)) ? (void) (0) : __assert_fail ("(percentile > 100) || (percentile < 0)", "stats/statistics.c", 35, __extension__ __PRETTY_FUNCTION__));
    return gsl_stats_quantile_from_sorted_data(values, 1, length, (percentile / 100));
}

canonical_original_code:
double stats_percentile_sorted_values(double *values, unsigned long length, double percentile) {
    (((percentile > 100) || (percentile < 0)) ? (void) (0) : __assert_fail ("(percentile > 100) || (percentile < 0)", "stats/statistics.c", 35, __extension__ __PRETTY_FUNCTION__));
    return gsl_stats_quantile_from_sorted_data(values, 1, length, (percentile / 100));
}

variable_types: percentile double


decompiled_code:
__int64 __fastcall stats_percentile(__int64 a1, __int64 a2, double a3)
{
gsl_sort(a1, 1LL, a2);
return stats_percentile_sorted_values(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, double a3)
{
gsl_sort(a1, 1LL, a2);
return func4(a1, a2, a3);
}

original_code:
double stats_percentile(double* values, size_t length, double percentile) {
    gsl_sort(values, 1, length);
    return stats_percentile_sorted_values(values, length, percentile);
}

canonical_original_code:
double stats_percentile(double *values, unsigned long length, double percentile) {
    gsl_sort(values, 1, length);
    return stats_percentile_sorted_values(values, length, percentile);
}


decompiled_code:
void __fastcall vector_free(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}
}

original_code:
void vector_free(vector_t* v) {
    if (v == ((void *)0)) {
        return;
    }
    if (v->values != ((void *)0)) {
        free(v->values);
    }
    free(v);
    return;
}

canonical_original_code:
void vector_free(struct vector *v) {
    if (v == ((void *)0)) {
        return;
    }
    if (v->values != ((void *)0)) {
        free(v->values);
    }
    free(v);
    return;
}

variable_types: struct vector { unsigned long length; double *values; } *


decompiled_code:
void __fastcall ttest_results_free(int a1, void **a2)
{
void **v2; // rbx
__int64 v3; // rbp
void *v4; // rdi

if ( a2 )
{
if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
v4 = *v2++;
free(v4);
}
while ( v2 != (void **)v3 );
}
free(a2);
}
}

original_code:
void ttest_results_free(int num_rows, ttest_result_t** ttest_results) {
    if (ttest_results == ((void *)0)) {
        return;
    }
    for (int i = 0; i < num_rows; i++) {
        free(ttest_results[i]);
    }
    free(ttest_results);
}

canonical_original_code:
void ttest_results_free(int num_rows, struct ttest_result **ttest_results) {
    if (ttest_results == ((void *)0)) {
        return;
    }
    for (int i = 0; i < num_rows; i++) {
        free(ttest_results[i]);
    }
    free(ttest_results);
}

variable_types: struct ttest_result { double statistic; double degrees_of_freedom; double p_value; } **