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

if ( PositionReportMemoryFreeList == -1 )
{
if ( (unsigned __int64)PositionReportMemoryTop > 7 )
return 0LL;
v0 = &PositionReportMemory[17 * PositionReportMemoryTop++];
}
else
{
v0 = &PositionReportMemory[17 * PositionReportMemoryFreeList];
PositionReportMemoryFreeList = *v0;
}
PositionReport_Init(v0);
return v0;
}

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

if ( PositionReportMemoryFreeList == -1 )
{
if ( (unsigned __int64)PositionReportMemoryTop > 7 )
return 0LL;
v0 = &PositionReportMemory[17 * PositionReportMemoryTop++];
}
else
{
v0 = &PositionReportMemory[17 * PositionReportMemoryFreeList];
PositionReportMemoryFreeList = *v0;
}
func1(v0);
return v0;
}

original_code:
PositionReport* PositionReport_New(void)
{
    PositionReport* ptr;
    if (PositionReportMemoryFreeList != (-1))
    {
        ptr = &PositionReportMemory[PositionReportMemoryFreeList];
        PositionReportMemoryFreeList = PositionReportMemory[PositionReportMemoryFreeList].header.NID_PACKET;
    }
    else if (PositionReportMemoryTop < 8)
    {
        ptr = &PositionReportMemory[PositionReportMemoryTop];
        PositionReportMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PositionReport_Init(ptr);
    return ptr;
}

canonical_original_code:
struct PositionReport *PositionReport_New()
{
    struct PositionReport *ptr;
    if (PositionReportMemoryFreeList != (-1))
    {
        ptr = &PositionReportMemory[PositionReportMemoryFreeList];
        PositionReportMemoryFreeList = PositionReportMemory[PositionReportMemoryFreeList].header.NID_PACKET;
    }
    else if (PositionReportMemoryTop < 8)
    {
        ptr = &PositionReportMemory[PositionReportMemoryTop];
        PositionReportMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PositionReport_Init(ptr);
    return ptr;
}

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


repo: openETCS/dataDictionary

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

*a1 = PositionReportMemoryFreeList;
result = 0xF0F0F0F0F0F0F0F1LL;
PositionReportMemoryFreeList = 0xF0F0F0F0F0F0F0F1LL * (a1 - PositionReportMemory);
return result;
}

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

*a1 = PositionReportMemoryFreeList;
result = 0xF0F0F0F0F0F0F0F1LL;
PositionReportMemoryFreeList = 0xF0F0F0F0F0F0F0F1LL * (a1 - PositionReportMemory);
return result;
}

original_code:
void PositionReport_Delete(PositionReport* ptr)
{
    ptr->header.NID_PACKET = PositionReportMemoryFreeList;
    PositionReportMemoryFreeList = ptr - PositionReportMemory;
}

canonical_original_code:
void PositionReport_Delete(struct PositionReport *ptr)
{
    ptr->header.NID_PACKET = PositionReportMemoryFreeList;
    PositionReportMemoryFreeList = ptr - PositionReportMemory;
}

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

return_type: void

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


decompiled_code:
_BOOL8 __fastcall OnboardTelephoneNumbers_1_UpperBitsNotSet(unsigned __int64 *a1)
{
return UpperBitsNotSet64(*a1, 64);
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int64 *a1)
{
return func0(*a1, 64);
}

original_code:
int OnboardTelephoneNumbers_1_UpperBitsNotSet(const OnboardTelephoneNumbers_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->NID_RADIO, 64);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_1_UpperBitsNotSet(struct OnboardTelephoneNumbers_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->NID_RADIO, 64);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct OnboardTelephoneNumbers_1 { unsigned long NID_RADIO; } *

variable_types: status int

return_type: int


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

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

original_code:
int OnboardTelephoneNumbers_1_EncodeBit(const OnboardTelephoneNumbers_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 64))
    {
        if (OnboardTelephoneNumbers_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 64, p->NID_RADIO);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_1_EncodeBit(struct OnboardTelephoneNumbers_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 64))
    {
        if (OnboardTelephoneNumbers_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 64, p->NID_RADIO);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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

user_defined_types: struct OnboardTelephoneNumbers_1 { unsigned long NID_RADIO; }


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

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

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

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

original_code:
int OnboardTelephoneNumbers_1_DecodeBit(OnboardTelephoneNumbers_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 64))
    {
        {
            p->NID_RADIO = Bitstream_Read(stream, 64);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_1_DecodeBit(struct OnboardTelephoneNumbers_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 64))
    {
        {
            p->NID_RADIO = Bitstream_Read(stream, 64);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

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


decompiled_code:
__int64 __fastcall OnboardTelephoneNumbers_1_EncodeInt(__int64 *a1, _DWORD *a2, __int64 a3)
{
__int64 v3; // rcx
int v4; // eax

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

original_code:
int OnboardTelephoneNumbers_1_EncodeInt(const OnboardTelephoneNumbers_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->NID_RADIO;
    return 1;
}

canonical_original_code:
int OnboardTelephoneNumbers_1_EncodeInt(struct OnboardTelephoneNumbers_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->NID_RADIO;
    return 1;
}

variable_types:
startAddress
int *

variable_types:
stream
int *


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

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

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, _DWORD *a2, __int64 a3)
{
int v3; // eax

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

original_code:
int OnboardTelephoneNumbers_1_DecodeInt(OnboardTelephoneNumbers_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->NID_RADIO = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int OnboardTelephoneNumbers_1_DecodeInt(struct OnboardTelephoneNumbers_1 *p, int *startAddress, int *stream)
{
    p->NID_RADIO = stream[(*startAddress)++];
    return 1;
}


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

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

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

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

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

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

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long


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

v1 = *a1;
result = UpperBitsNotSet64(*a1, 1);
if ( v1 != 1 )
{
if ( !result )
return result;
return UpperBitsNotSet64(a1[2], 14);
}
if ( result )
{
result = UpperBitsNotSet64(a1[1], 10);
if ( result )
return UpperBitsNotSet64(a1[2], 14);
}
return result;
}

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

v1 = *a1;
result = func0(*a1, 1);
if ( v1 != 1 )
{
if ( !result )
return result;
return func0(a1[2], 14);
}
if ( result )
{
result = func0(a1[1], 10);
if ( result )
return func0(a1[2], 14);
}
return result;
}

original_code:
int ListOfBalisesForSHArea_1_UpperBitsNotSet(const ListOfBalisesForSHArea_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY, 1) ;
    if (p->Q_NEWCOUNTRY == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_C, 10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG, 14);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ListOfBalisesForSHArea_1_UpperBitsNotSet(struct ListOfBalisesForSHArea_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY, 1) ;
    if (p->Q_NEWCOUNTRY == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_C, 10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG, 14);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct ListOfBalisesForSHArea_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; } *


decompiled_code:
__int64 __fastcall ListOfBalisesForSHArea_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 15LL) )
return 0xFFFFFFFFLL;
if ( !ListOfBalisesForSHArea_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 1LL, *a1);
if ( *a1 == 1 )
Bitstream_Write(a2, 10LL, a1[1]);
Bitstream_Write(a2, 14LL, a1[2]);
return 1LL;
}

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

original_code:
int ListOfBalisesForSHArea_1_EncodeBit(const ListOfBalisesForSHArea_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 15))
    {
        if (ListOfBalisesForSHArea_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 1, p->Q_NEWCOUNTRY);
            if (p->Q_NEWCOUNTRY == 1)
            {
                Bitstream_Write(stream, 10, p->NID_C);
            }
            Bitstream_Write(stream, 14, p->NID_BG);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int ListOfBalisesForSHArea_1_EncodeBit(struct ListOfBalisesForSHArea_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 15))
    {
        if (ListOfBalisesForSHArea_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 1, p->Q_NEWCOUNTRY);
            if (p->Q_NEWCOUNTRY == 1)
            {
                Bitstream_Write(stream, 10, p->NID_C);
            }
            Bitstream_Write(stream, 14, p->NID_BG);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int ListOfBalisesForSHArea_1_DecodeBit(ListOfBalisesForSHArea_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 15))
    {
        {
            p->Q_NEWCOUNTRY = Bitstream_Read(stream, 1);
        }
        if (p->Q_NEWCOUNTRY == 1)
        {
            {
                p->NID_C = Bitstream_Read(stream, 10);
            }
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ListOfBalisesForSHArea_1_DecodeBit(struct ListOfBalisesForSHArea_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 15))
    {
        {
            p->Q_NEWCOUNTRY = Bitstream_Read(stream, 1);
        }
        if (p->Q_NEWCOUNTRY == 1)
        {
            {
                p->NID_C = Bitstream_Read(stream, 10);
            }
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int ListOfBalisesForSHArea_1_EncodeInt(const ListOfBalisesForSHArea_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->Q_NEWCOUNTRY;
    stream[(*startAddress)++] = p->NID_C;
    stream[(*startAddress)++] = p->NID_BG;
    return 1;
}

canonical_original_code:
int ListOfBalisesForSHArea_1_EncodeInt(struct ListOfBalisesForSHArea_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->Q_NEWCOUNTRY;
    stream[(*startAddress)++] = p->NID_C;
    stream[(*startAddress)++] = p->NID_BG;
    return 1;
}


decompiled_code:
__int64 __fastcall ListOfBalisesForSHArea_1_DecodeInt(_QWORD *a1, _DWORD *a2, __int64 a3)
{
int v3; // eax
int v4; // eax
int v5; // eax

v3 = (*a2)++;
*a1 = *(int *)(a3 + 4LL * v3);
v4 = (*a2)++;
a1[1] = *(int *)(a3 + 4LL * v4);
v5 = (*a2)++;
a1[2] = *(int *)(a3 + 4LL * v5);
return 1LL;
}

original_code:
int ListOfBalisesForSHArea_1_DecodeInt(ListOfBalisesForSHArea_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->Q_NEWCOUNTRY = stream[(*startAddress)++];
    p->NID_C = stream[(*startAddress)++];
    p->NID_BG = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int ListOfBalisesForSHArea_1_DecodeInt(struct ListOfBalisesForSHArea_1 *p, int *startAddress, int *stream)
{
    p->Q_NEWCOUNTRY = stream[(*startAddress)++];
    p->NID_C = stream[(*startAddress)++];
    p->NID_BG = stream[(*startAddress)++];
    return 1;
}


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

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

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

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

original_code:
int TemporarySpeedRestriction_UpperBitsNotSet(const TemporarySpeedRestriction* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->NID_TSR, 8) ;
    status = status && UpperBitsNotSet64(p->D_TSR, 15);
    status = status && UpperBitsNotSet64(p->L_TSR, 15);
    status = status && UpperBitsNotSet64(p->Q_FRONT, 1) ;
    status = status && UpperBitsNotSet64(p->V_TSR, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TemporarySpeedRestriction_UpperBitsNotSet(struct TemporarySpeedRestriction *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->NID_TSR, 8) ;
    status = status && UpperBitsNotSet64(p->D_TSR, 15);
    status = status && UpperBitsNotSet64(p->L_TSR, 15);
    status = status && UpperBitsNotSet64(p->Q_FRONT, 1) ;
    status = status && UpperBitsNotSet64(p->V_TSR, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

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

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


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

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

original_code:
int TemporarySpeedRestriction_EncodeBit(const TemporarySpeedRestriction* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 63))
    {
        if (TemporarySpeedRestriction_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 8, p->NID_TSR);
            Bitstream_Write(stream, 15, p->D_TSR);
            Bitstream_Write(stream, 15, p->L_TSR);
            Bitstream_Write(stream, 1, p->Q_FRONT);
            Bitstream_Write(stream, 7, p->V_TSR);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int TemporarySpeedRestriction_EncodeBit(struct TemporarySpeedRestriction *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 63))
    {
        if (TemporarySpeedRestriction_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 8, p->NID_TSR);
            Bitstream_Write(stream, 15, p->D_TSR);
            Bitstream_Write(stream, 15, p->L_TSR);
            Bitstream_Write(stream, 1, p->Q_FRONT);
            Bitstream_Write(stream, 7, p->V_TSR);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int TemporarySpeedRestriction_DecodeBit(TemporarySpeedRestriction* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 63))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->NID_TSR = Bitstream_Read(stream, 8);
        }
        {
            p->D_TSR = Bitstream_Read(stream, 15);
        }
        {
            p->L_TSR = Bitstream_Read(stream, 15);
        }
        {
            p->Q_FRONT = Bitstream_Read(stream, 1);
        }
        {
            p->V_TSR = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TemporarySpeedRestriction_DecodeBit(struct TemporarySpeedRestriction *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 63))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->NID_TSR = Bitstream_Read(stream, 8);
        }
        {
            p->D_TSR = Bitstream_Read(stream, 15);
        }
        {
            p->L_TSR = Bitstream_Read(stream, 15);
        }
        {
            p->Q_FRONT = Bitstream_Read(stream, 1);
        }
        {
            p->V_TSR = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int TemporarySpeedRestriction_EncodeInt(const TemporarySpeedRestriction* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 65;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->NID_TSR;
    stream[startAddress++] = p->D_TSR;
    stream[startAddress++] = p->L_TSR;
    stream[startAddress++] = p->Q_FRONT;
    stream[startAddress++] = p->V_TSR;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int TemporarySpeedRestriction_EncodeInt(struct TemporarySpeedRestriction *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 65;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->NID_TSR;
    stream[startAddress++] = p->D_TSR;
    stream[startAddress++] = p->L_TSR;
    stream[startAddress++] = p->Q_FRONT;
    stream[startAddress++] = p->V_TSR;
    data->endAddress = startAddress-1;
    return 1;
}

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

variable_types: startAddress int


original_code:
int TemporarySpeedRestriction_DecodeInt(TemporarySpeedRestriction* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 65)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->NID_TSR = stream[startAddress++];
    p->D_TSR = stream[startAddress++];
    p->L_TSR = stream[startAddress++];
    p->Q_FRONT = stream[startAddress++];
    p->V_TSR = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int TemporarySpeedRestriction_DecodeInt(struct TemporarySpeedRestriction *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 65)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->NID_TSR = stream[startAddress++];
    p->D_TSR = stream[startAddress++];
    p->L_TSR = stream[startAddress++];
    p->Q_FRONT = stream[startAddress++];
    p->V_TSR = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

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


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

if ( TemporarySpeedRestrictionMemoryFreeList == -1 )
{
if ( (unsigned __int64)TemporarySpeedRestrictionMemoryTop > 7 )
return 0LL;
v0 = &TemporarySpeedRestrictionMemory[10 * TemporarySpeedRestrictionMemoryTop++];
}
else
{
v0 = &TemporarySpeedRestrictionMemory[10 * TemporarySpeedRestrictionMemoryFreeList];
TemporarySpeedRestrictionMemoryFreeList = *v0;
}
TemporarySpeedRestriction_Init(v0);
return v0;
}

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

if ( TemporarySpeedRestrictionMemoryFreeList == -1 )
{
if ( (unsigned __int64)TemporarySpeedRestrictionMemoryTop > 7 )
return 0LL;
v0 = &TemporarySpeedRestrictionMemory[10 * TemporarySpeedRestrictionMemoryTop++];
}
else
{
v0 = &TemporarySpeedRestrictionMemory[10 * TemporarySpeedRestrictionMemoryFreeList];
TemporarySpeedRestrictionMemoryFreeList = *v0;
}
func1(v0);
return v0;
}

original_code:
TemporarySpeedRestriction* TemporarySpeedRestriction_New(void)
{
    TemporarySpeedRestriction* ptr;
    if (TemporarySpeedRestrictionMemoryFreeList != (-1))
    {
        ptr = &TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryFreeList];
        TemporarySpeedRestrictionMemoryFreeList = TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryFreeList].header.NID_PACKET;
    }
    else if (TemporarySpeedRestrictionMemoryTop < 8)
    {
        ptr = &TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryTop];
        TemporarySpeedRestrictionMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TemporarySpeedRestriction_Init(ptr);
    return ptr;
}

canonical_original_code:
struct TemporarySpeedRestriction *TemporarySpeedRestriction_New()
{
    struct TemporarySpeedRestriction *ptr;
    if (TemporarySpeedRestrictionMemoryFreeList != (-1))
    {
        ptr = &TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryFreeList];
        TemporarySpeedRestrictionMemoryFreeList = TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryFreeList].header.NID_PACKET;
    }
    else if (TemporarySpeedRestrictionMemoryTop < 8)
    {
        ptr = &TemporarySpeedRestrictionMemory[TemporarySpeedRestrictionMemoryTop];
        TemporarySpeedRestrictionMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TemporarySpeedRestriction_Init(ptr);
    return ptr;
}

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


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

*(_QWORD *)a1 = TemporarySpeedRestrictionMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
TemporarySpeedRestrictionMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * ((a1 - (char *)TemporarySpeedRestrictionMemory) >> 4);
return result;
}

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

*(_QWORD *)a1 = TemporarySpeedRestrictionMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
TemporarySpeedRestrictionMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * ((a1 - (char *)TemporarySpeedRestrictionMemory) >> 4);
return result;
}

original_code:
void TemporarySpeedRestriction_Delete(TemporarySpeedRestriction* ptr)
{
    ptr->header.NID_PACKET = TemporarySpeedRestrictionMemoryFreeList;
    TemporarySpeedRestrictionMemoryFreeList = ptr - TemporarySpeedRestrictionMemory;
}

canonical_original_code:
void TemporarySpeedRestriction_Delete(struct TemporarySpeedRestriction *ptr)
{
    ptr->header.NID_PACKET = TemporarySpeedRestrictionMemoryFreeList;
    TemporarySpeedRestrictionMemoryFreeList = ptr - TemporarySpeedRestrictionMemory;
}


decompiled_code:
_BOOL8 __fastcall ListOfBalisesInSRAuthority_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL4 v1; // eax
unsigned int i; // ebx

v1 = UpperBitsNotSet64(a1[2], 2);
if ( v1 )
{
v1 = UpperBitsNotSet64(a1[3], 13);
if ( v1 )
v1 = UpperBitsNotSet64(a1[4], 5);
}
for ( i = 0; i < a1[4]; ++i )
{
if ( v1 )
v1 = ListOfBalisesInSRAuthority_1_UpperBitsNotSet(&a1[3 * i + 5]) != 0;
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(unsigned __int64 *a1)
{
_BOOL4 v1; // eax
unsigned int i; // ebx

v1 = func0(a1[2], 2);
if ( v1 )
{
v1 = func0(a1[3], 13);
if ( v1 )
v1 = func0(a1[4], 5);
}
for ( i = 0; i < a1[4]; ++i )
{
if ( v1 )
v1 = ListOfBalisesInSRAuthority_1_UpperBitsNotSet(&a1[3 * i + 5]) != 0;
}
return v1;
}

original_code:
int ListOfBalisesInSRAuthority_UpperBitsNotSet(const ListOfBalisesInSRAuthority* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && ListOfBalisesInSRAuthority_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ListOfBalisesInSRAuthority_UpperBitsNotSet(struct ListOfBalisesInSRAuthority *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && ListOfBalisesInSRAuthority_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct ListOfBalisesInSRAuthority { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long N_ITER_1; struct ListOfBalisesInSRAuthority_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; } sub_1[31]; } *

variable_types:
i
unsigned int

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


decompiled_code:
__int64 __fastcall ListOfBalisesInSRAuthority_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !(unsigned int)Bitstream_Normal(a2, 20LL) )
return 0xFFFFFFFFLL;
if ( !ListOfBalisesInSRAuthority_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 5LL, a1[4]);
if ( !a1[4] )
return 1LL;
v2 = 0;
do
ListOfBalisesInSRAuthority_1_EncodeBit(&a1[3 * v2++ + 5], a2);
while ( v2 < a1[4] );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !(unsigned int)Bitstream_Normal(a2, 20LL) )
return 0xFFFFFFFFLL;
if ( !func3(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 5LL, a1[4]);
if ( !a1[4] )
return 1LL;
v2 = 0;
do
ListOfBalisesInSRAuthority_1_EncodeBit(&a1[3 * v2++ + 5], a2);
while ( v2 < a1[4] );
return 1LL;
}

original_code:
int ListOfBalisesInSRAuthority_EncodeBit(const ListOfBalisesInSRAuthority* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 20))
    {
        if (ListOfBalisesInSRAuthority_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (uint32_t i = 0; i < p->N_ITER_1; ++i)
            {
                ListOfBalisesInSRAuthority_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int ListOfBalisesInSRAuthority_EncodeBit(struct ListOfBalisesInSRAuthority *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 20))
    {
        if (ListOfBalisesInSRAuthority_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (unsigned int i = 0; i < p->N_ITER_1; ++i)
            {
                ListOfBalisesInSRAuthority_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


decompiled_code:
__int64 __fastcall ListOfBalisesInSRAuthority_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebx

result = Bitstream_Normal(a2, 20LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
v3 = Bitstream_Read(a2, 5LL);
a1[4] = v3;
if ( v3 )
{
v4 = 0;
do
ListOfBalisesInSRAuthority_1_DecodeBit(&a1[3 * v4++ + 5], a2);
while ( (unsigned __int64)v4 < a1[4] );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebx

result = Bitstream_Normal(a2, 20LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
v3 = Bitstream_Read(a2, 5LL);
a1[4] = v3;
if ( v3 )
{
v4 = 0;
do
ListOfBalisesInSRAuthority_1_DecodeBit(&a1[3 * v4++ + 5], a2);
while ( (unsigned __int64)v4 < a1[4] );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int ListOfBalisesInSRAuthority_DecodeBit(ListOfBalisesInSRAuthority* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 20))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_1; ++i)
        {
            ListOfBalisesInSRAuthority_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ListOfBalisesInSRAuthority_DecodeBit(struct ListOfBalisesInSRAuthority *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 20))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_1; ++i)
        {
            ListOfBalisesInSRAuthority_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int ListOfBalisesInSRAuthority_EncodeInt(const ListOfBalisesInSRAuthority* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 63;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->N_ITER_1;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        ListOfBalisesInSRAuthority_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int ListOfBalisesInSRAuthority_EncodeInt(struct ListOfBalisesInSRAuthority *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 63;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->N_ITER_1;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        ListOfBalisesInSRAuthority_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}


decompiled_code:
_BOOL8 __fastcall ListOfBalisesInSRAuthority_DecodeInt(_QWORD *a1, _DWORD *a2, __int64 a3)
{
_BOOL8 result; // rax
int v5; // edx
__int64 v6; // rax
unsigned int v7; // ebx
int v8[11]; // [rsp+0h] [rbp-2Ch] BYREF

result = 0LL;
if ( *a2 == 63 )
{
v5 = a2[3];
*a1 = *(int *)(a3 + 4LL * v5);
a1[2] = *(int *)(a3 + 4LL * v5 + 4);
a1[3] = *(int *)(a3 + 4LL * v5 + 8);
v8[0] = v5 + 4;
v6 = *(int *)(a3 + 4LL * v5 + 12);
a1[4] = v6;
if ( v6 )
{
v7 = 0;
do
ListOfBalisesInSRAuthority_1_DecodeInt(&a1[3 * v7++ + 5], v8, a3);
while ( (unsigned __int64)v7 < a1[4] );
}
result = v8[0] - 1 == a2[4];
}
return result;
}

original_code:
int ListOfBalisesInSRAuthority_DecodeInt(ListOfBalisesInSRAuthority* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 63)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        ListOfBalisesInSRAuthority_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int ListOfBalisesInSRAuthority_DecodeInt(struct ListOfBalisesInSRAuthority *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 63)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        ListOfBalisesInSRAuthority_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


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

if ( ListOfBalisesInSRAuthorityMemoryFreeList == -1 )
{
if ( (unsigned __int64)ListOfBalisesInSRAuthorityMemoryTop > 7 )
return 0LL;
v0 = &ListOfBalisesInSRAuthorityMemory[98 * ListOfBalisesInSRAuthorityMemoryTop++];
}
else
{
v0 = &ListOfBalisesInSRAuthorityMemory[98 * ListOfBalisesInSRAuthorityMemoryFreeList];
ListOfBalisesInSRAuthorityMemoryFreeList = *v0;
}
ListOfBalisesInSRAuthority_Init(v0);
return v0;
}

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

if ( ListOfBalisesInSRAuthorityMemoryFreeList == -1 )
{
if ( (unsigned __int64)ListOfBalisesInSRAuthorityMemoryTop > 7 )
return 0LL;
v0 = &ListOfBalisesInSRAuthorityMemory[98 * ListOfBalisesInSRAuthorityMemoryTop++];
}
else
{
v0 = &ListOfBalisesInSRAuthorityMemory[98 * ListOfBalisesInSRAuthorityMemoryFreeList];
ListOfBalisesInSRAuthorityMemoryFreeList = *v0;
}
func2(v0);
return v0;
}

original_code:
ListOfBalisesInSRAuthority* ListOfBalisesInSRAuthority_New(void)
{
    ListOfBalisesInSRAuthority* ptr;
    if (ListOfBalisesInSRAuthorityMemoryFreeList != (-1))
    {
        ptr = &ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryFreeList];
        ListOfBalisesInSRAuthorityMemoryFreeList = ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryFreeList].header.NID_PACKET;
    }
    else if (ListOfBalisesInSRAuthorityMemoryTop < 8)
    {
        ptr = &ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryTop];
        ListOfBalisesInSRAuthorityMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    ListOfBalisesInSRAuthority_Init(ptr);
    return ptr;
}

canonical_original_code:
struct ListOfBalisesInSRAuthority *ListOfBalisesInSRAuthority_New()
{
    struct ListOfBalisesInSRAuthority *ptr;
    if (ListOfBalisesInSRAuthorityMemoryFreeList != (-1))
    {
        ptr = &ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryFreeList];
        ListOfBalisesInSRAuthorityMemoryFreeList = ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryFreeList].header.NID_PACKET;
    }
    else if (ListOfBalisesInSRAuthorityMemoryTop < 8)
    {
        ptr = &ListOfBalisesInSRAuthorityMemory[ListOfBalisesInSRAuthorityMemoryTop];
        ListOfBalisesInSRAuthorityMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    ListOfBalisesInSRAuthority_Init(ptr);
    return ptr;
}

return_type: struct ListOfBalisesInSRAuthority { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long N_ITER_1; struct ListOfBalisesInSRAuthority_1 { unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; } sub_1[31]; } *


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

*(_QWORD *)a1 = ListOfBalisesInSRAuthorityMemoryFreeList;
result = 0x7D6343EB1A1F58D1LL;
ListOfBalisesInSRAuthorityMemoryFreeList = 0x7D6343EB1A1F58D1LL
* ((a1 - (char *)ListOfBalisesInSRAuthorityMemory) >> 4);
return result;
}

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

*(_QWORD *)a1 = ListOfBalisesInSRAuthorityMemoryFreeList;
result = 0x7D6343EB1A1F58D1LL;
ListOfBalisesInSRAuthorityMemoryFreeList = 0x7D6343EB1A1F58D1LL
* ((a1 - (char *)ListOfBalisesInSRAuthorityMemory) >> 4);
return result;
}

original_code:
void ListOfBalisesInSRAuthority_Delete(ListOfBalisesInSRAuthority* ptr)
{
    ptr->header.NID_PACKET = ListOfBalisesInSRAuthorityMemoryFreeList;
    ListOfBalisesInSRAuthorityMemoryFreeList = ptr - ListOfBalisesInSRAuthorityMemory;
}

canonical_original_code:
void ListOfBalisesInSRAuthority_Delete(struct ListOfBalisesInSRAuthority *ptr)
{
    ptr->header.NID_PACKET = ListOfBalisesInSRAuthorityMemoryFreeList;
    ListOfBalisesInSRAuthorityMemoryFreeList = ptr - ListOfBalisesInSRAuthorityMemory;
}


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

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


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

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

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

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

original_code:
int TrackCondition_1_UpperBitsNotSet(const TrackCondition_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->D_TRACKCOND, 15);
    status = status && UpperBitsNotSet64(p->L_TRACKCOND, 15);
    status = status && UpperBitsNotSet64(p->M_TRACKCOND, 4) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackCondition_1_UpperBitsNotSet(struct TrackCondition_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->D_TRACKCOND, 15);
    status = status && UpperBitsNotSet64(p->L_TRACKCOND, 15);
    status = status && UpperBitsNotSet64(p->M_TRACKCOND, 4) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct TrackCondition_1 { unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; unsigned long M_TRACKCOND; } *


decompiled_code:
__int64 __fastcall TrackCondition_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 34LL) )
return 0xFFFFFFFFLL;
if ( !TrackCondition_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 15LL, a1[1]);
Bitstream_Write(a2, 4LL, a1[2]);
return 1LL;
}

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

original_code:
int TrackCondition_1_EncodeBit(const TrackCondition_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 34))
    {
        if (TrackCondition_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_TRACKCOND);
            Bitstream_Write(stream, 15, p->L_TRACKCOND);
            Bitstream_Write(stream, 4, p->M_TRACKCOND);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int TrackCondition_1_EncodeBit(struct TrackCondition_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 34))
    {
        if (TrackCondition_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_TRACKCOND);
            Bitstream_Write(stream, 15, p->L_TRACKCOND);
            Bitstream_Write(stream, 4, p->M_TRACKCOND);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int TrackCondition_1_DecodeBit(TrackCondition_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 34))
    {
        {
            p->D_TRACKCOND = Bitstream_Read(stream, 15);
        }
        {
            p->L_TRACKCOND = Bitstream_Read(stream, 15);
        }
        {
            p->M_TRACKCOND = Bitstream_Read(stream, 4);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackCondition_1_DecodeBit(struct TrackCondition_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 34))
    {
        {
            p->D_TRACKCOND = Bitstream_Read(stream, 15);
        }
        {
            p->L_TRACKCOND = Bitstream_Read(stream, 15);
        }
        {
            p->M_TRACKCOND = Bitstream_Read(stream, 4);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int TrackCondition_1_EncodeInt(const TrackCondition_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->D_TRACKCOND;
    stream[(*startAddress)++] = p->L_TRACKCOND;
    stream[(*startAddress)++] = p->M_TRACKCOND;
    return 1;
}

canonical_original_code:
int TrackCondition_1_EncodeInt(struct TrackCondition_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->D_TRACKCOND;
    stream[(*startAddress)++] = p->L_TRACKCOND;
    stream[(*startAddress)++] = p->M_TRACKCOND;
    return 1;
}


original_code:
int TrackCondition_1_DecodeInt(TrackCondition_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->D_TRACKCOND = stream[(*startAddress)++];
    p->L_TRACKCOND = stream[(*startAddress)++];
    p->M_TRACKCOND = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int TrackCondition_1_DecodeInt(struct TrackCondition_1 *p, int *startAddress, int *stream)
{
    p->D_TRACKCOND = stream[(*startAddress)++];
    p->L_TRACKCOND = stream[(*startAddress)++];
    p->M_TRACKCOND = stream[(*startAddress)++];
    return 1;
}


decompiled_code:
_BOOL8 __fastcall OnboardTelephoneNumbers_UpperBitsNotSet(__int64 a1)
{
_BOOL4 v1; // eax
unsigned int i; // ebx

v1 = UpperBitsNotSet64(*(_QWORD *)(a1 + 16), 13);
if ( v1 )
v1 = UpperBitsNotSet64(*(_QWORD *)(a1 + 24), 5);
for ( i = 0; (unsigned __int64)i < *(_QWORD *)(a1 + 24); ++i )
{
if ( v1 )
v1 = OnboardTelephoneNumbers_1_UpperBitsNotSet(a1 + 8LL * i + 32) != 0;
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
_BOOL4 v1; // eax
unsigned int i; // ebx

v1 = func0(*(_QWORD *)(a1 + 16), 13);
if ( v1 )
v1 = func0(*(_QWORD *)(a1 + 24), 5);
for ( i = 0; (unsigned __int64)i < *(_QWORD *)(a1 + 24); ++i )
{
if ( v1 )
v1 = OnboardTelephoneNumbers_1_UpperBitsNotSet(a1 + 8LL * i + 32) != 0;
}
return v1;
}

original_code:
int OnboardTelephoneNumbers_UpperBitsNotSet(const OnboardTelephoneNumbers* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && OnboardTelephoneNumbers_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_UpperBitsNotSet(struct OnboardTelephoneNumbers *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && OnboardTelephoneNumbers_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct OnboardTelephoneNumbers { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long L_PACKET; unsigned long N_ITER_1; struct OnboardTelephoneNumbers_1 { unsigned long NID_RADIO; } sub_1[31]; } *

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


decompiled_code:
__int64 __fastcall OnboardTelephoneNumbers_EncodeBit(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !(unsigned int)Bitstream_Normal(a2, 18LL) )
return 0xFFFFFFFFLL;
if ( !OnboardTelephoneNumbers_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 13LL, *(_QWORD *)(a1 + 16));
Bitstream_Write(a2, 5LL, *(_QWORD *)(a1 + 24));
if ( !*(_QWORD *)(a1 + 24) )
return 1LL;
v2 = 0;
do
OnboardTelephoneNumbers_1_EncodeBit(a1 + 8LL * v2++ + 32, a2);
while ( (unsigned __int64)v2 < *(_QWORD *)(a1 + 24) );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !(unsigned int)Bitstream_Normal(a2, 18LL) )
return 0xFFFFFFFFLL;
if ( !func3(a1) )
return 4294967294LL;
Bitstream_Write(a2, 13LL, *(_QWORD *)(a1 + 16));
Bitstream_Write(a2, 5LL, *(_QWORD *)(a1 + 24));
if ( !*(_QWORD *)(a1 + 24) )
return 1LL;
v2 = 0;
do
OnboardTelephoneNumbers_1_EncodeBit(a1 + 8LL * v2++ + 32, a2);
while ( (unsigned __int64)v2 < *(_QWORD *)(a1 + 24) );
return 1LL;
}

original_code:
int OnboardTelephoneNumbers_EncodeBit(const OnboardTelephoneNumbers* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 18))
    {
        if (OnboardTelephoneNumbers_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (uint32_t i = 0; i < p->N_ITER_1; ++i)
            {
                OnboardTelephoneNumbers_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_EncodeBit(struct OnboardTelephoneNumbers *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 18))
    {
        if (OnboardTelephoneNumbers_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (unsigned int i = 0; i < p->N_ITER_1; ++i)
            {
                OnboardTelephoneNumbers_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}


decompiled_code:
__int64 __fastcall OnboardTelephoneNumbers_DecodeBit(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebx

result = Bitstream_Normal(a2, 18LL);
if ( (_DWORD)result )
{
*(_QWORD *)(a1 + 16) = Bitstream_Read(a2, 13LL);
v3 = Bitstream_Read(a2, 5LL);
*(_QWORD *)(a1 + 24) = v3;
if ( v3 )
{
v4 = 0;
do
OnboardTelephoneNumbers_1_DecodeBit(a1 + 8LL * v4++ + 32, a2);
while ( (unsigned __int64)v4 < *(_QWORD *)(a1 + 24) );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebx

result = Bitstream_Normal(a2, 18LL);
if ( (_DWORD)result )
{
*(_QWORD *)(a1 + 16) = Bitstream_Read(a2, 13LL);
v3 = Bitstream_Read(a2, 5LL);
*(_QWORD *)(a1 + 24) = v3;
if ( v3 )
{
v4 = 0;
do
OnboardTelephoneNumbers_1_DecodeBit(a1 + 8LL * v4++ + 32, a2);
while ( (unsigned __int64)v4 < *(_QWORD *)(a1 + 24) );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int OnboardTelephoneNumbers_DecodeBit(OnboardTelephoneNumbers* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 18))
    {
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_1; ++i)
        {
            OnboardTelephoneNumbers_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int OnboardTelephoneNumbers_DecodeBit(struct OnboardTelephoneNumbers *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 18))
    {
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_1; ++i)
        {
            OnboardTelephoneNumbers_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


decompiled_code:
__int64 __fastcall OnboardTelephoneNumbers_EncodeInt(_QWORD *a1, __int64 a2, __int64 a3)
{
int v4; // eax
__int64 v5; // rdx
__int64 v6; // rcx
unsigned int v7; // ebx
int v9[11]; // [rsp+Ch] [rbp-2Ch] BYREF

*(_DWORD *)a2 = 3;
*(_BYTE *)(a2 + 8) = 1;
v4 = *(_DWORD *)(a2 + 12);
v5 = 4LL * v4;
*(_DWORD *)(a3 + v5) = *a1;
*(_DWORD *)(a3 + v5 + 4) = a1[2];
v6 = a1[3];
v9[0] = v4 + 3;
*(_DWORD *)(a3 + v5 + 8) = v6;
if ( a1[3] )
{
v7 = 0;
do
OnboardTelephoneNumbers_1_EncodeInt(&a1[v7++ + 4], v9, a3);
while ( (unsigned __int64)v7 < a1[3] );
}
*(_DWORD *)(a2 + 16) = v9[0] - 1;
return 1LL;
}

original_code:
int OnboardTelephoneNumbers_EncodeInt(const OnboardTelephoneNumbers* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 3;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->N_ITER_1;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        OnboardTelephoneNumbers_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int OnboardTelephoneNumbers_EncodeInt(struct OnboardTelephoneNumbers *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 3;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->N_ITER_1;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        OnboardTelephoneNumbers_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}


decompiled_code:
_BOOL8 __fastcall OnboardTelephoneNumbers_DecodeInt(_QWORD *a1, _DWORD *a2, __int64 a3)
{
_BOOL8 result; // rax
int v5; // eax
__int64 v6; // rax
unsigned int v7; // ebx
int v8[11]; // [rsp+0h] [rbp-2Ch] BYREF

result = 0LL;
if ( *a2 == 3 )
{
v5 = a2[3];
*a1 = *(int *)(a3 + 4LL * v5);
a1[2] = *(int *)(a3 + 4LL * v5 + 4);
v8[0] = v5 + 3;
v6 = *(int *)(a3 + 4LL * v5 + 8);
a1[3] = v6;
if ( v6 )
{
v7 = 0;
do
OnboardTelephoneNumbers_1_DecodeInt(&a1[v7++ + 4], v8, a3);
while ( (unsigned __int64)v7 < a1[3] );
}
result = v8[0] - 1 == a2[4];
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(_QWORD *a1, _DWORD *a2, __int64 a3)
{
_BOOL8 result; // rax
int v5; // eax
__int64 v6; // rax
unsigned int v7; // ebx
int v8[11]; // [rsp+0h] [rbp-2Ch] BYREF

result = 0LL;
if ( *a2 == 3 )
{
v5 = a2[3];
*a1 = *(int *)(a3 + 4LL * v5);
a1[2] = *(int *)(a3 + 4LL * v5 + 4);
v8[0] = v5 + 3;
v6 = *(int *)(a3 + 4LL * v5 + 8);
a1[3] = v6;
if ( v6 )
{
v7 = 0;
do
OnboardTelephoneNumbers_1_DecodeInt(&a1[v7++ + 4], v8, a3);
while ( (unsigned __int64)v7 < a1[3] );
}
result = v8[0] - 1 == a2[4];
}
return result;
}

original_code:
int OnboardTelephoneNumbers_DecodeInt(OnboardTelephoneNumbers* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 3)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        OnboardTelephoneNumbers_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int OnboardTelephoneNumbers_DecodeInt(struct OnboardTelephoneNumbers *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 3)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        OnboardTelephoneNumbers_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


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

if ( OnboardTelephoneNumbersMemoryFreeList == -1 )
{
if ( (unsigned __int64)OnboardTelephoneNumbersMemoryTop > 7 )
return 0LL;
v0 = &OnboardTelephoneNumbersMemory[35 * OnboardTelephoneNumbersMemoryTop++];
}
else
{
v0 = &OnboardTelephoneNumbersMemory[35 * OnboardTelephoneNumbersMemoryFreeList];
OnboardTelephoneNumbersMemoryFreeList = *v0;
}
OnboardTelephoneNumbers_Init(v0);
return v0;
}

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

if ( OnboardTelephoneNumbersMemoryFreeList == -1 )
{
if ( (unsigned __int64)OnboardTelephoneNumbersMemoryTop > 7 )
return 0LL;
v0 = &OnboardTelephoneNumbersMemory[35 * OnboardTelephoneNumbersMemoryTop++];
}
else
{
v0 = &OnboardTelephoneNumbersMemory[35 * OnboardTelephoneNumbersMemoryFreeList];
OnboardTelephoneNumbersMemoryFreeList = *v0;
}
func2(v0);
return v0;
}

original_code:
OnboardTelephoneNumbers* OnboardTelephoneNumbers_New(void)
{
    OnboardTelephoneNumbers* ptr;
    if (OnboardTelephoneNumbersMemoryFreeList != (-1))
    {
        ptr = &OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryFreeList];
        OnboardTelephoneNumbersMemoryFreeList = OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryFreeList].header.NID_PACKET;
    }
    else if (OnboardTelephoneNumbersMemoryTop < 8)
    {
        ptr = &OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryTop];
        OnboardTelephoneNumbersMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    OnboardTelephoneNumbers_Init(ptr);
    return ptr;
}

canonical_original_code:
struct OnboardTelephoneNumbers *OnboardTelephoneNumbers_New()
{
    struct OnboardTelephoneNumbers *ptr;
    if (OnboardTelephoneNumbersMemoryFreeList != (-1))
    {
        ptr = &OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryFreeList];
        OnboardTelephoneNumbersMemoryFreeList = OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryFreeList].header.NID_PACKET;
    }
    else if (OnboardTelephoneNumbersMemoryTop < 8)
    {
        ptr = &OnboardTelephoneNumbersMemory[OnboardTelephoneNumbersMemoryTop];
        OnboardTelephoneNumbersMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    OnboardTelephoneNumbers_Init(ptr);
    return ptr;
}

return_type: struct OnboardTelephoneNumbers { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long L_PACKET; unsigned long N_ITER_1; struct OnboardTelephoneNumbers_1 { unsigned long NID_RADIO; } sub_1[31]; } *


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

*a1 = OnboardTelephoneNumbersMemoryFreeList;
result = 0xAF8AF8AF8AF8AF8BLL;
OnboardTelephoneNumbersMemoryFreeList = 0xAF8AF8AF8AF8AF8BLL * (a1 - OnboardTelephoneNumbersMemory);
return result;
}

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

*a1 = OnboardTelephoneNumbersMemoryFreeList;
result = 0xAF8AF8AF8AF8AF8BLL;
OnboardTelephoneNumbersMemoryFreeList = 0xAF8AF8AF8AF8AF8BLL * (a1 - OnboardTelephoneNumbersMemory);
return result;
}

original_code:
void OnboardTelephoneNumbers_Delete(OnboardTelephoneNumbers* ptr)
{
    ptr->header.NID_PACKET = OnboardTelephoneNumbersMemoryFreeList;
    OnboardTelephoneNumbersMemoryFreeList = ptr - OnboardTelephoneNumbersMemory;
}

canonical_original_code:
void OnboardTelephoneNumbers_Delete(struct OnboardTelephoneNumbers *ptr)
{
    ptr->header.NID_PACKET = OnboardTelephoneNumbersMemoryFreeList;
    OnboardTelephoneNumbersMemoryFreeList = ptr - OnboardTelephoneNumbersMemory;
}


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

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

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

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

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

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

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

variable_types:
b
struct PacketHeader *


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

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

original_code:
static inline int AdhesionFactor_Equal(const AdhesionFactor* a, const AdhesionFactor* b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->Q_DIR == b->Q_DIR);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->Q_SCALE == b->Q_SCALE);
    status = status && (a->D_ADHESION == b->D_ADHESION);
    status = status && (a->L_ADHESION == b->L_ADHESION);
    status = status && (a->M_ADHESION == b->M_ADHESION);
    return status;
}

canonical_original_code:
static inline int AdhesionFactor_Equal(struct AdhesionFactor *a, struct AdhesionFactor *b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->Q_DIR == b->Q_DIR);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->Q_SCALE == b->Q_SCALE);
    status = status && (a->D_ADHESION == b->D_ADHESION);
    status = status && (a->L_ADHESION == b->L_ADHESION);
    status = status && (a->M_ADHESION == b->M_ADHESION);
    return status;
}

variable_types: struct AdhesionFactor { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SCALE; unsigned long D_ADHESION; unsigned long L_ADHESION; unsigned long M_ADHESION; } *

variable_types:
b
struct AdhesionFactor *

variable_types: status int

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


decompiled_code:
int AdhesionFactor_Tests()
{
_QWORD *v0; // rbx
_QWORD *v1; // r13
_QWORD *v2; // rbp
_QWORD *v3; // r12
_QWORD *v4; // rbx
_QWORD *v5; // rbp
_QWORD *v6; // rdi
_QWORD *v7; // rax
_QWORD v9[8]; // [rsp+0h] [rbp-A8h] BYREF
_QWORD v10[13]; // [rsp+40h] [rbp-68h] BYREF

puts("\nstart AdhesionFactor_Tests");
AdhesionFactor_Init(v10);
AdhesionFactor_Print(v10, stdout);
putchar(10);
AdhesionFactor_Init(v9);
if ( !AdhesionFactor_Equal(v10, v9) )
_assert_fail("AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 0x25u, "AdhesionFactor_Tests");
if ( !PacketHeader_Equal(v10, v9) )
_assert_fail("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 0x27u, "AdhesionFactor_Tests");
v9[5] = 2LL;
if ( AdhesionFactor_Equal(v10, v9) )
_assert_fail("!AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 0x2Au, "AdhesionFactor_Tests");
if ( !PacketHeader_Equal(v10, v9) )
_assert_fail("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 0x2Cu, "AdhesionFactor_Tests");
v0 = (_QWORD *)PacketFactory_TrackToTrain(71LL, 1LL);
AdhesionFactor_Print(v0, stdout);
putchar(10);
if ( !AdhesionFactor_Equal(v10, v0) )
_assert_fail("AdhesionFactor_Equal(&a, p)", "AdhesionFactor_Tests.c", 0x33u, "AdhesionFactor_Tests");
AdhesionFactor_Delete(v0);
v1 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v1);
v2 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v2);
v3 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v3);
v4 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v4);
AdhesionFactor_Delete(v2);
AdhesionFactor_Delete(v4);
v5 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v5);
v6 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v6);
v7 = (_QWORD *)AdhesionFactor_New();
AdhesionFactor_Init(v7);
AdhesionFactor_Delete(v1);
AdhesionFactor_Delete(v3);
AdhesionFactor_Delete(v5);
AdhesionFactor_Delete(v6);
return puts("end AdhesionFactor_Test");
}

canonical_decompiled_code:
int func5()
{
_QWORD *v0; // rbx
_QWORD *v1; // r13
_QWORD *v2; // rbp
_QWORD *v3; // r12
_QWORD *v4; // rbx
_QWORD *v5; // rbp
_QWORD *v6; // rdi
_QWORD *v7; // rax
_QWORD v9[8]; // [rsp+0h] [rbp-A8h] BYREF
_QWORD v10[13]; // [rsp+40h] [rbp-68h] BYREF

puts("\nstart AdhesionFactor_Tests");
func1(v10);
func4(v10, stdout);
putchar(10);
func1(v9);
if ( !func2(v10, v9) )
_assert_fail("AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 0x25u, "AdhesionFactor_Tests");
if ( !func0(v10, v9) )
_assert_fail("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 0x27u, "AdhesionFactor_Tests");
v9[5] = 2LL;
if ( func2(v10, v9) )
_assert_fail("!AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 0x2Au, "AdhesionFactor_Tests");
if ( !func0(v10, v9) )
_assert_fail("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 0x2Cu, "AdhesionFactor_Tests");
v0 = (_QWORD *)PacketFactory_TrackToTrain(71LL, 1LL);
func4(v0, stdout);
putchar(10);
if ( !func2(v10, v0) )
_assert_fail("AdhesionFactor_Equal(&a, p)", "AdhesionFactor_Tests.c", 0x33u, "AdhesionFactor_Tests");
AdhesionFactor_Delete(v0);
v1 = (_QWORD *)AdhesionFactor_New();
func1(v1);
v2 = (_QWORD *)AdhesionFactor_New();
func1(v2);
v3 = (_QWORD *)AdhesionFactor_New();
func1(v3);
v4 = (_QWORD *)AdhesionFactor_New();
func1(v4);
AdhesionFactor_Delete(v2);
AdhesionFactor_Delete(v4);
v5 = (_QWORD *)AdhesionFactor_New();
func1(v5);
v6 = (_QWORD *)AdhesionFactor_New();
func1(v6);
v7 = (_QWORD *)AdhesionFactor_New();
func1(v7);
AdhesionFactor_Delete(v1);
AdhesionFactor_Delete(v3);
AdhesionFactor_Delete(v5);
AdhesionFactor_Delete(v6);
return puts("end AdhesionFactor_Test");
}

original_code:
void AdhesionFactor_Tests(void)
{
    printf("\nstart AdhesionFactor_Tests\n");
    AdhesionFactor a;
    AdhesionFactor_Init(&a);
    AdhesionFactor_Print(&a, stdout);
    printf("\n");
    AdhesionFactor b;
    AdhesionFactor_Init(&b);
    ((AdhesionFactor_Equal(&a, &b)) ? (void) (0) : __assert_fail ("AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    ((PacketHeader_Equal(&a.header, &b.header)) ? (void) (0) : __assert_fail ("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 39, __extension__ __PRETTY_FUNCTION__));
    b.D_ADHESION = 2;
    ((!AdhesionFactor_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 42, __extension__ __PRETTY_FUNCTION__));
    ((PacketHeader_Equal(&a.header, &b.header)) ? (void) (0) : __assert_fail ("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 44, __extension__ __PRETTY_FUNCTION__));
    PacketHeader header = {71, 1};
    PacketHeader* base = PacketFactory_TrackToTrain(header);
    AdhesionFactor* p = (AdhesionFactor*)(base);
    AdhesionFactor_Print(p, stdout);
    printf("\n");
    ((AdhesionFactor_Equal(&a, p)) ? (void) (0) : __assert_fail ("AdhesionFactor_Equal(&a, p)", "AdhesionFactor_Tests.c", 51, __extension__ __PRETTY_FUNCTION__));
    AdhesionFactor_Delete(p);
    {
        AdhesionFactor* p = AdhesionFactor_New();
        AdhesionFactor_Init(p);
        AdhesionFactor* q = AdhesionFactor_New();
        AdhesionFactor_Init(q);
        AdhesionFactor* r = AdhesionFactor_New();
        AdhesionFactor_Init(r);
        AdhesionFactor* s = AdhesionFactor_New();
        AdhesionFactor_Init(s);
        AdhesionFactor_Delete(q);
        AdhesionFactor_Delete(s);
        AdhesionFactor* t = AdhesionFactor_New();
        AdhesionFactor_Init(t);
        AdhesionFactor* u = AdhesionFactor_New();
        AdhesionFactor_Init(u);
        AdhesionFactor* v = AdhesionFactor_New();
        AdhesionFactor_Init(v);
 AdhesionFactor_Delete(p);
 AdhesionFactor_Delete(r);
 AdhesionFactor_Delete(t);
 AdhesionFactor_Delete(u);
    }
    printf("end AdhesionFactor_Test\n");
}

canonical_original_code:
void AdhesionFactor_Tests()
{
    printf("\nstart AdhesionFactor_Tests\n");
    struct AdhesionFactor a;
    AdhesionFactor_Init(&a);
    AdhesionFactor_Print(&a, stdout);
    printf("\n");
    struct AdhesionFactor b;
    AdhesionFactor_Init(&b);
    ((AdhesionFactor_Equal(&a, &b)) ? (void) (0) : __assert_fail ("AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    ((PacketHeader_Equal(&a.header, &b.header)) ? (void) (0) : __assert_fail ("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 39, __extension__ __PRETTY_FUNCTION__));
    b.D_ADHESION = 2;
    ((!AdhesionFactor_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!AdhesionFactor_Equal(&a, &b)", "AdhesionFactor_Tests.c", 42, __extension__ __PRETTY_FUNCTION__));
    ((PacketHeader_Equal(&a.header, &b.header)) ? (void) (0) : __assert_fail ("PacketHeader_Equal(&a.header, &b.header)", "AdhesionFactor_Tests.c", 44, __extension__ __PRETTY_FUNCTION__));
    struct PacketHeader header = {71, 1};
    struct PacketHeader *base = PacketFactory_TrackToTrain(header);
    struct AdhesionFactor *p = (AdhesionFactor*)(base);
    AdhesionFactor_Print(p, stdout);
    printf("\n");
    ((AdhesionFactor_Equal(&a, p)) ? (void) (0) : __assert_fail ("AdhesionFactor_Equal(&a, p)", "AdhesionFactor_Tests.c", 51, __extension__ __PRETTY_FUNCTION__));
    AdhesionFactor_Delete(p);
    {
        struct AdhesionFactor *p = AdhesionFactor_New();
        AdhesionFactor_Init(p);
        struct AdhesionFactor *q = AdhesionFactor_New();
        AdhesionFactor_Init(q);
        struct AdhesionFactor *r = AdhesionFactor_New();
        AdhesionFactor_Init(r);
        struct AdhesionFactor *s = AdhesionFactor_New();
        AdhesionFactor_Init(s);
        AdhesionFactor_Delete(q);
        AdhesionFactor_Delete(s);
        struct AdhesionFactor *t = AdhesionFactor_New();
        AdhesionFactor_Init(t);
        struct AdhesionFactor *u = AdhesionFactor_New();
        AdhesionFactor_Init(u);
        struct AdhesionFactor *v = AdhesionFactor_New();
        AdhesionFactor_Init(v);
 AdhesionFactor_Delete(p);
 AdhesionFactor_Delete(r);
 AdhesionFactor_Delete(t);
 AdhesionFactor_Delete(u);
    }
    printf("end AdhesionFactor_Test\n");
}

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


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

result = PacketHeader_Equal(a1, a2);
if ( result )
{
result = 0LL;
if ( a1[2] == a2[2] )
result = a1[3] == a2[3];
}
return result;
}

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

result = func0(a1, a2);
if ( result )
{
result = 0LL;
if ( a1[2] == a2[2] )
result = a1[3] == a2[3];
}
return result;
}

original_code:
static inline int Level23TransitionInformation_Equal(const Level23TransitionInformation* a, const Level23TransitionInformation* b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->NID_LTRBG == b->NID_LTRBG);
    return status;
}

canonical_original_code:
static inline int Level23TransitionInformation_Equal(struct Level23TransitionInformation *a, struct Level23TransitionInformation *b)
{
    int status = PacketHeader_Equal(&a->header, &b->header);
    status = status && (a->L_PACKET == b->L_PACKET);
    status = status && (a->NID_LTRBG == b->NID_LTRBG);
    return status;
}

variable_types: struct Level23TransitionInformation { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long L_PACKET; unsigned long NID_LTRBG; } *

variable_types:
b
struct Level23TransitionInformation *

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


decompiled_code:
int Level23TransitionInformation_Tests()
{
_QWORD *v0; // rbx
_QWORD v2[4]; // [rsp+0h] [rbp-48h] BYREF
_QWORD v3[5]; // [rsp+20h] [rbp-28h] BYREF

puts("\nstart Level23TransitionInformation_Tests");
Level23TransitionInformation_Init(v3);
Level23TransitionInformation_Print(v3, stdout);
putchar(10);
Level23TransitionInformation_Init(v2);
if ( !Level23TransitionInformation_Equal(v3, v2) )
_assert_fail(
"Level23TransitionInformation_Equal(&a, &b)",
"Level23TransitionInformation_Tests.c",
0x25u,
"Level23TransitionInformation_Tests");
v2[3] = 17LL;
if ( Level23TransitionInformation_Equal(v3, v2) )
_assert_fail(
"!Level23TransitionInformation_Equal(&a, &b)",
"Level23TransitionInformation_Tests.c",
0x28u,
"Level23TransitionInformation_Tests");
v0 = (_QWORD *)PacketFactory_TrainToTrack(9LL, 0LL);
Level23TransitionInformation_Print(v0, stdout);
putchar(10);
if ( !Level23TransitionInformation_Equal(v3, v0) )
_assert_fail(
"Level23TransitionInformation_Equal(&a, p)",
"Level23TransitionInformation_Tests.c",
0x2Fu,
"Level23TransitionInformation_Tests");
Level23TransitionInformation_Delete(v0);
return puts("end Level23TransitionInformation_Tests");
}

canonical_decompiled_code:
int func5()
{
_QWORD *v0; // rbx
_QWORD v2[4]; // [rsp+0h] [rbp-48h] BYREF
_QWORD v3[5]; // [rsp+20h] [rbp-28h] BYREF

puts("\nstart Level23TransitionInformation_Tests");
func1(v3);
func4(v3, stdout);
putchar(10);
func1(v2);
if ( !func2(v3, v2) )
_assert_fail(
"Level23TransitionInformation_Equal(&a, &b)",
"Level23TransitionInformation_Tests.c",
0x25u,
"Level23TransitionInformation_Tests");
v2[3] = 17LL;
if ( func2(v3, v2) )
_assert_fail(
"!Level23TransitionInformation_Equal(&a, &b)",
"Level23TransitionInformation_Tests.c",
0x28u,
"Level23TransitionInformation_Tests");
v0 = (_QWORD *)PacketFactory_TrainToTrack(9LL, 0LL);
func4(v0, stdout);
putchar(10);
if ( !func2(v3, v0) )
_assert_fail(
"Level23TransitionInformation_Equal(&a, p)",
"Level23TransitionInformation_Tests.c",
0x2Fu,
"Level23TransitionInformation_Tests");
Level23TransitionInformation_Delete(v0);
return puts("end Level23TransitionInformation_Tests");
}

original_code:
void Level23TransitionInformation_Tests(void)
{
    printf("\nstart Level23TransitionInformation_Tests\n");
    Level23TransitionInformation a;
    Level23TransitionInformation_Init(&a);
    Level23TransitionInformation_Print(&a, stdout);
    printf("\n");
    Level23TransitionInformation b;
    Level23TransitionInformation_Init(&b);
    ((Level23TransitionInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("Level23TransitionInformation_Equal(&a, &b)", "Level23TransitionInformation_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    b.NID_LTRBG = 17;
    ((!Level23TransitionInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!Level23TransitionInformation_Equal(&a, &b)", "Level23TransitionInformation_Tests.c", 40, __extension__ __PRETTY_FUNCTION__));
    PacketHeader header = {9, 0};
    PacketHeader* base = PacketFactory_TrainToTrack(header);
    Level23TransitionInformation* p = (Level23TransitionInformation*)(base);
    Level23TransitionInformation_Print(p, stdout);
    printf("\n");
    ((Level23TransitionInformation_Equal(&a, p)) ? (void) (0) : __assert_fail ("Level23TransitionInformation_Equal(&a, p)", "Level23TransitionInformation_Tests.c", 47, __extension__ __PRETTY_FUNCTION__));
    Level23TransitionInformation_Delete(p);
    printf("end Level23TransitionInformation_Tests\n");
}

canonical_original_code:
void Level23TransitionInformation_Tests()
{
    printf("\nstart Level23TransitionInformation_Tests\n");
    struct Level23TransitionInformation a;
    Level23TransitionInformation_Init(&a);
    Level23TransitionInformation_Print(&a, stdout);
    printf("\n");
    struct Level23TransitionInformation b;
    Level23TransitionInformation_Init(&b);
    ((Level23TransitionInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("Level23TransitionInformation_Equal(&a, &b)", "Level23TransitionInformation_Tests.c", 37, __extension__ __PRETTY_FUNCTION__));
    b.NID_LTRBG = 17;
    ((!Level23TransitionInformation_Equal(&a, &b)) ? (void) (0) : __assert_fail ("!Level23TransitionInformation_Equal(&a, &b)", "Level23TransitionInformation_Tests.c", 40, __extension__ __PRETTY_FUNCTION__));
    struct PacketHeader header = {9, 0};
    struct PacketHeader *base = PacketFactory_TrainToTrack(header);
    struct Level23TransitionInformation *p = (Level23TransitionInformation*)(base);
    Level23TransitionInformation_Print(p, stdout);
    printf("\n");
    ((Level23TransitionInformation_Equal(&a, p)) ? (void) (0) : __assert_fail ("Level23TransitionInformation_Equal(&a, p)", "Level23TransitionInformation_Tests.c", 47, __extension__ __PRETTY_FUNCTION__));
    Level23TransitionInformation_Delete(p);
    printf("end Level23TransitionInformation_Tests\n");
}

variable_types: struct Level23TransitionInformation { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long L_PACKET; unsigned long NID_LTRBG; }


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

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

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

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

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

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

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long


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

result = UpperBitsNotSet64(a1[2], 2);
if ( result )
{
result = UpperBitsNotSet64(a1[3], 13);
if ( result )
result = UpperBitsNotSet64(a1[4], 32);
}
return result;
}

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

result = func0(a1[2], 2);
if ( result )
{
result = func0(a1[3], 13);
if ( result )
result = func0(a1[4], 32);
}
return result;
}

original_code:
int TrainRunningNumberFromRBC_UpperBitsNotSet(const TrainRunningNumberFromRBC* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->NID_OPERATIONAL, 32);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrainRunningNumberFromRBC_UpperBitsNotSet(struct TrainRunningNumberFromRBC *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->NID_OPERATIONAL, 32);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct TrainRunningNumberFromRBC { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_OPERATIONAL; } *

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


decompiled_code:
__int64 __fastcall TrainRunningNumberFromRBC_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 47LL) )
return 0xFFFFFFFFLL;
if ( !TrainRunningNumberFromRBC_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 32LL, a1[4]);
return 1LL;
}

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

original_code:
int TrainRunningNumberFromRBC_EncodeBit(const TrainRunningNumberFromRBC* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 47))
    {
        if (TrainRunningNumberFromRBC_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 32, p->NID_OPERATIONAL);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int TrainRunningNumberFromRBC_EncodeBit(struct TrainRunningNumberFromRBC *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 47))
    {
        if (TrainRunningNumberFromRBC_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 32, p->NID_OPERATIONAL);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

result = Bitstream_Normal(a2, 47LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 32LL);
result = 1LL;
}
return result;
}

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

result = Bitstream_Normal(a2, 47LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 32LL);
result = 1LL;
}
return result;
}

original_code:
int TrainRunningNumberFromRBC_DecodeBit(TrainRunningNumberFromRBC* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 47))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->NID_OPERATIONAL = Bitstream_Read(stream, 32);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrainRunningNumberFromRBC_DecodeBit(struct TrainRunningNumberFromRBC *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 47))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->NID_OPERATIONAL = Bitstream_Read(stream, 32);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int TrainRunningNumberFromRBC_EncodeInt(const TrainRunningNumberFromRBC* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 140;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->NID_OPERATIONAL;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int TrainRunningNumberFromRBC_EncodeInt(struct TrainRunningNumberFromRBC *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 140;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->NID_OPERATIONAL;
    data->endAddress = startAddress-1;
    return 1;
}

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

variable_types:
stream
int *

variable_types: startAddress int


decompiled_code:
_BOOL8 __fastcall TrainRunningNumberFromRBC_DecodeInt(_QWORD *a1, _DWORD *a2, __int64 a3)
{
_BOOL8 result; // rax
int v4; // eax

result = 0LL;
if ( *a2 == 140 )
{
v4 = a2[3];
*a1 = *(int *)(a3 + 4LL * v4);
a1[2] = *(int *)(a3 + 4LL * v4 + 4);
a1[3] = *(int *)(a3 + 4LL * v4 + 8);
a1[4] = *(int *)(a3 + 4LL * v4 + 12);
result = a2[4] == v4 + 3;
}
return result;
}

original_code:
int TrainRunningNumberFromRBC_DecodeInt(TrainRunningNumberFromRBC* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 140)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->NID_OPERATIONAL = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int TrainRunningNumberFromRBC_DecodeInt(struct TrainRunningNumberFromRBC *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 140)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->NID_OPERATIONAL = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


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

if ( TrainRunningNumberFromRBCMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrainRunningNumberFromRBCMemoryTop > 7 )
return 0LL;
v0 = &TrainRunningNumberFromRBCMemory[5 * TrainRunningNumberFromRBCMemoryTop++];
}
else
{
v0 = &TrainRunningNumberFromRBCMemory[5 * TrainRunningNumberFromRBCMemoryFreeList];
TrainRunningNumberFromRBCMemoryFreeList = *v0;
}
TrainRunningNumberFromRBC_Init(v0);
return v0;
}

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

if ( TrainRunningNumberFromRBCMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrainRunningNumberFromRBCMemoryTop > 7 )
return 0LL;
v0 = &TrainRunningNumberFromRBCMemory[5 * TrainRunningNumberFromRBCMemoryTop++];
}
else
{
v0 = &TrainRunningNumberFromRBCMemory[5 * TrainRunningNumberFromRBCMemoryFreeList];
TrainRunningNumberFromRBCMemoryFreeList = *v0;
}
func1(v0);
return v0;
}

original_code:
TrainRunningNumberFromRBC* TrainRunningNumberFromRBC_New(void)
{
    TrainRunningNumberFromRBC* ptr;
    if (TrainRunningNumberFromRBCMemoryFreeList != (-1))
    {
        ptr = &TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryFreeList];
        TrainRunningNumberFromRBCMemoryFreeList = TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryFreeList].header.NID_PACKET;
    }
    else if (TrainRunningNumberFromRBCMemoryTop < 8)
    {
        ptr = &TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryTop];
        TrainRunningNumberFromRBCMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrainRunningNumberFromRBC_Init(ptr);
    return ptr;
}

canonical_original_code:
struct TrainRunningNumberFromRBC *TrainRunningNumberFromRBC_New()
{
    struct TrainRunningNumberFromRBC *ptr;
    if (TrainRunningNumberFromRBCMemoryFreeList != (-1))
    {
        ptr = &TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryFreeList];
        TrainRunningNumberFromRBCMemoryFreeList = TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryFreeList].header.NID_PACKET;
    }
    else if (TrainRunningNumberFromRBCMemoryTop < 8)
    {
        ptr = &TrainRunningNumberFromRBCMemory[TrainRunningNumberFromRBCMemoryTop];
        TrainRunningNumberFromRBCMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrainRunningNumberFromRBC_Init(ptr);
    return ptr;
}

return_type: struct TrainRunningNumberFromRBC { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_OPERATIONAL; } *


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

*a1 = TrainRunningNumberFromRBCMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
TrainRunningNumberFromRBCMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - TrainRunningNumberFromRBCMemory);
return result;
}

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

*a1 = TrainRunningNumberFromRBCMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
TrainRunningNumberFromRBCMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - TrainRunningNumberFromRBCMemory);
return result;
}

original_code:
void TrainRunningNumberFromRBC_Delete(TrainRunningNumberFromRBC* ptr)
{
    ptr->header.NID_PACKET = TrainRunningNumberFromRBCMemoryFreeList;
    TrainRunningNumberFromRBCMemoryFreeList = ptr - TrainRunningNumberFromRBCMemory;
}

canonical_original_code:
void TrainRunningNumberFromRBC_Delete(struct TrainRunningNumberFromRBC *ptr)
{
    ptr->header.NID_PACKET = TrainRunningNumberFromRBCMemoryFreeList;
    TrainRunningNumberFromRBCMemoryFreeList = ptr - TrainRunningNumberFromRBCMemory;
}


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

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

original_code:
int Onboard_telephone_numbers_Core_1_Encode_Bit(Bitstream* stream, const Onboard_telephone_numbers_Core_1* p)
{
    if (Bitstream_Normal(stream, 64))
    {
        if (Onboard_telephone_numbers_Core_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 64, p->NID_RADIO);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int Onboard_telephone_numbers_Core_1_Encode_Bit(struct Bitstream *stream, struct Onboard_telephone_numbers_Core_1 *p)
{
    if (Bitstream_Normal(stream, 64))
    {
        if (Onboard_telephone_numbers_Core_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 64, p->NID_RADIO);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

variable_types: struct Onboard_telephone_numbers_Core_1 { unsigned long NID_RADIO; } *