decompiled_code:
void RBCTransitionOrder_New()
{
__int64 *v0; // rdi
__int64 v1; // rax

if ( RBCTransitionOrderMemoryFreeList == -1 )
{
if ( (unsigned __int64)RBCTransitionOrderMemoryTop <= 7 )
{
v1 = 10 * RBCTransitionOrderMemoryTop++;
RBCTransitionOrder_Init(&RBCTransitionOrderMemory[v1]);
}
}
else
{
v0 = &RBCTransitionOrderMemory[10 * RBCTransitionOrderMemoryFreeList];
RBCTransitionOrderMemoryFreeList = *v0;
RBCTransitionOrder_Init(v0);
}
}

canonical_decompiled_code:
void func7()
{
__int64 *v0; // rdi
__int64 v1; // rax

if ( RBCTransitionOrderMemoryFreeList == -1 )
{
if ( (unsigned __int64)RBCTransitionOrderMemoryTop <= 7 )
{
v1 = 10 * RBCTransitionOrderMemoryTop++;
func1(&RBCTransitionOrderMemory[v1]);
}
}
else
{
v0 = &RBCTransitionOrderMemory[10 * RBCTransitionOrderMemoryFreeList];
RBCTransitionOrderMemoryFreeList = *v0;
func1(v0);
}
}

original_code:
RBCTransitionOrder* RBCTransitionOrder_New(void)
{
    RBCTransitionOrder* ptr;
    if (RBCTransitionOrderMemoryFreeList != (-1))
    {
        ptr = &RBCTransitionOrderMemory[RBCTransitionOrderMemoryFreeList];
        RBCTransitionOrderMemoryFreeList = RBCTransitionOrderMemory[RBCTransitionOrderMemoryFreeList].header.NID_PACKET;
    }
    else if (RBCTransitionOrderMemoryTop < 8)
    {
        ptr = &RBCTransitionOrderMemory[RBCTransitionOrderMemoryTop];
        RBCTransitionOrderMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    RBCTransitionOrder_Init(ptr);
    return ptr;
}

canonical_original_code:
struct RBCTransitionOrder *RBCTransitionOrder_New()
{
    struct RBCTransitionOrder *ptr;
    if (RBCTransitionOrderMemoryFreeList != (-1))
    {
        ptr = &RBCTransitionOrderMemory[RBCTransitionOrderMemoryFreeList];
        RBCTransitionOrderMemoryFreeList = RBCTransitionOrderMemory[RBCTransitionOrderMemoryFreeList].header.NID_PACKET;
    }
    else if (RBCTransitionOrderMemoryTop < 8)
    {
        ptr = &RBCTransitionOrderMemory[RBCTransitionOrderMemoryTop];
        RBCTransitionOrderMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    RBCTransitionOrder_Init(ptr);
    return ptr;
}

return_type: struct RBCTransitionOrder { 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_RBCTR; unsigned long NID_C; unsigned long NID_RBC; unsigned long NID_RADIO; unsigned long Q_SLEEPSESSION; } *


repo: openETCS/dataDictionary

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

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

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

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

original_code:
void RBCTransitionOrder_Delete(RBCTransitionOrder* ptr)
{
    ptr->header.NID_PACKET = RBCTransitionOrderMemoryFreeList;
    RBCTransitionOrderMemoryFreeList = ptr - RBCTransitionOrderMemory;
}

canonical_original_code:
void RBCTransitionOrder_Delete(struct RBCTransitionOrder *ptr)
{
    ptr->header.NID_PACKET = RBCTransitionOrderMemoryFreeList;
    RBCTransitionOrderMemoryFreeList = ptr - RBCTransitionOrderMemory;
}

variable_types: struct RBCTransitionOrder { 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_RBCTR; unsigned long NID_C; unsigned long NID_RBC; unsigned long NID_RADIO; unsigned long Q_SLEEPSESSION; } *

return_type: void

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


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

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

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

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

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long

return_type: int


decompiled_code:
_BOOL8 __fastcall MovementAuthorityRequestParameters_UpperBitsNotSet(__int64 a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx

result = UpperBitsNotSet64(*(_QWORD *)(a1 + 16), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 24), 13);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 32), 8);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v4 + 40), 10);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v5 + 48), 8);
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx

result = func0(*(_QWORD *)(a1 + 16), 2);
if ( result )
{
result = func0(*(_QWORD *)(v2 + 24), 13);
if ( result )
{
result = func0(*(_QWORD *)(v3 + 32), 8);
if ( result )
{
result = func0(*(_QWORD *)(v4 + 40), 10);
if ( result )
result = func0(*(_QWORD *)(v5 + 48), 8);
}
}
}
return result;
}

original_code:
int MovementAuthorityRequestParameters_UpperBitsNotSet(const MovementAuthorityRequestParameters* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->T_MAR, 8) ;
    status = status && UpperBitsNotSet64(p->T_TIMEOUTRQST, 10);
    status = status && UpperBitsNotSet64(p->T_CYCRQST, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int MovementAuthorityRequestParameters_UpperBitsNotSet(struct MovementAuthorityRequestParameters *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->T_MAR, 8) ;
    status = status && UpperBitsNotSet64(p->T_TIMEOUTRQST, 10);
    status = status && UpperBitsNotSet64(p->T_CYCRQST, 8) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct MovementAuthorityRequestParameters { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long T_MAR; unsigned long T_TIMEOUTRQST; unsigned long T_CYCRQST; } *

variable_types: status int

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


decompiled_code:
__int64 __fastcall MovementAuthorityRequestParameters_EncodeBit(_QWORD *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 41LL) )
return 0xFFFFFFFFLL;
if ( !MovementAuthorityRequestParameters_UpperBitsNotSet((__int64)a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 8LL, a1[4]);
Bitstream_Write(a2, 10LL, a1[5]);
Bitstream_Write(a2, 8LL, a1[6]);
return 1LL;
}

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

original_code:
int MovementAuthorityRequestParameters_EncodeBit(const MovementAuthorityRequestParameters* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        if (MovementAuthorityRequestParameters_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 8, p->T_MAR);
            Bitstream_Write(stream, 10, p->T_TIMEOUTRQST);
            Bitstream_Write(stream, 8, p->T_CYCRQST);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int MovementAuthorityRequestParameters_EncodeBit(struct MovementAuthorityRequestParameters *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        if (MovementAuthorityRequestParameters_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 8, p->T_MAR);
            Bitstream_Write(stream, 10, p->T_TIMEOUTRQST);
            Bitstream_Write(stream, 8, p->T_CYCRQST);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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

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


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

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

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

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

original_code:
int MovementAuthorityRequestParameters_DecodeBit(MovementAuthorityRequestParameters* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->T_MAR = Bitstream_Read(stream, 8);
        }
        {
            p->T_TIMEOUTRQST = Bitstream_Read(stream, 10);
        }
        {
            p->T_CYCRQST = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int MovementAuthorityRequestParameters_DecodeBit(struct MovementAuthorityRequestParameters *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->T_MAR = Bitstream_Read(stream, 8);
        }
        {
            p->T_TIMEOUTRQST = Bitstream_Read(stream, 10);
        }
        {
            p->T_CYCRQST = Bitstream_Read(stream, 8);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

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


original_code:
int MovementAuthorityRequestParameters_EncodeInt(const MovementAuthorityRequestParameters* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 57;
    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->T_MAR;
    stream[startAddress++] = p->T_TIMEOUTRQST;
    stream[startAddress++] = p->T_CYCRQST;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int MovementAuthorityRequestParameters_EncodeInt(struct MovementAuthorityRequestParameters *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 57;
    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->T_MAR;
    stream[startAddress++] = p->T_TIMEOUTRQST;
    stream[startAddress++] = p->T_CYCRQST;
    data->endAddress = startAddress-1;
    return 1;
}

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

variable_types:
stream
int *

variable_types: startAddress int


original_code:
int MovementAuthorityRequestParameters_DecodeInt(MovementAuthorityRequestParameters* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 57)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->T_MAR = stream[startAddress++];
    p->T_TIMEOUTRQST = stream[startAddress++];
    p->T_CYCRQST = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int MovementAuthorityRequestParameters_DecodeInt(struct MovementAuthorityRequestParameters *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 57)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->T_MAR = stream[startAddress++];
    p->T_TIMEOUTRQST = stream[startAddress++];
    p->T_CYCRQST = 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 MovementAuthorityRequestParameters_New()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( MovementAuthorityRequestParametersMemoryFreeList == -1 )
{
if ( (unsigned __int64)MovementAuthorityRequestParametersMemoryTop > 7 )
return 0LL;
v3 = 7 * MovementAuthorityRequestParametersMemoryTop++;
v0 = &MovementAuthorityRequestParametersMemory[v3];
}
else
{
v0 = &MovementAuthorityRequestParametersMemory[7 * MovementAuthorityRequestParametersMemoryFreeList];
MovementAuthorityRequestParametersMemoryFreeList = *v0;
}
MovementAuthorityRequestParameters_Init(v0);
return v1;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( MovementAuthorityRequestParametersMemoryFreeList == -1 )
{
if ( (unsigned __int64)MovementAuthorityRequestParametersMemoryTop > 7 )
return 0LL;
v3 = 7 * MovementAuthorityRequestParametersMemoryTop++;
v0 = &MovementAuthorityRequestParametersMemory[v3];
}
else
{
v0 = &MovementAuthorityRequestParametersMemory[7 * MovementAuthorityRequestParametersMemoryFreeList];
MovementAuthorityRequestParametersMemoryFreeList = *v0;
}
func1(v0);
return v1;
}

original_code:
MovementAuthorityRequestParameters* MovementAuthorityRequestParameters_New(void)
{
    MovementAuthorityRequestParameters* ptr;
    if (MovementAuthorityRequestParametersMemoryFreeList != (-1))
    {
        ptr = &MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryFreeList];
        MovementAuthorityRequestParametersMemoryFreeList = MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryFreeList].header.NID_PACKET;
    }
    else if (MovementAuthorityRequestParametersMemoryTop < 8)
    {
        ptr = &MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryTop];
        MovementAuthorityRequestParametersMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    MovementAuthorityRequestParameters_Init(ptr);
    return ptr;
}

canonical_original_code:
struct MovementAuthorityRequestParameters *MovementAuthorityRequestParameters_New()
{
    struct MovementAuthorityRequestParameters *ptr;
    if (MovementAuthorityRequestParametersMemoryFreeList != (-1))
    {
        ptr = &MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryFreeList];
        MovementAuthorityRequestParametersMemoryFreeList = MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryFreeList].header.NID_PACKET;
    }
    else if (MovementAuthorityRequestParametersMemoryTop < 8)
    {
        ptr = &MovementAuthorityRequestParametersMemory[MovementAuthorityRequestParametersMemoryTop];
        MovementAuthorityRequestParametersMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    MovementAuthorityRequestParameters_Init(ptr);
    return ptr;
}

return_type: struct MovementAuthorityRequestParameters { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long T_MAR; unsigned long T_TIMEOUTRQST; unsigned long T_CYCRQST; } *


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

*a1 = MovementAuthorityRequestParametersMemoryFreeList;
result = 0x6DB6DB6DB6DB6DB7LL;
MovementAuthorityRequestParametersMemoryFreeList = 0x6DB6DB6DB6DB6DB7LL
* (a1 - MovementAuthorityRequestParametersMemory);
return result;
}

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

*a1 = MovementAuthorityRequestParametersMemoryFreeList;
result = 0x6DB6DB6DB6DB6DB7LL;
MovementAuthorityRequestParametersMemoryFreeList = 0x6DB6DB6DB6DB6DB7LL
* (a1 - MovementAuthorityRequestParametersMemory);
return result;
}

original_code:
void MovementAuthorityRequestParameters_Delete(MovementAuthorityRequestParameters* ptr)
{
    ptr->header.NID_PACKET = MovementAuthorityRequestParametersMemoryFreeList;
    MovementAuthorityRequestParametersMemoryFreeList = ptr - MovementAuthorityRequestParametersMemory;
}

canonical_original_code:
void MovementAuthorityRequestParameters_Delete(struct MovementAuthorityRequestParameters *ptr)
{
    ptr->header.NID_PACKET = MovementAuthorityRequestParametersMemoryFreeList;
    MovementAuthorityRequestParametersMemoryFreeList = ptr - MovementAuthorityRequestParametersMemory;
}


decompiled_code:
_BOOL8 __fastcall UpperBitsNotSet64(unsigned __int64 a1)
{
return a1 <= 0x3FF;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int64 a1)
{
return a1 <= 0x3FF;
}


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

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

original_code:
int National_Values_Core_1_Encode_Bit(Bitstream* stream, const National_Values_Core_1* p)
{
    if (Bitstream_Normal(stream, 10))
    {
        if (National_Values_Core_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 10, p->NID_C);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int National_Values_Core_1_Encode_Bit(struct Bitstream *stream, struct National_Values_Core_1 *p)
{
    if (Bitstream_Normal(stream, 10))
    {
        if (National_Values_Core_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 10, p->NID_C);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

variable_types: struct National_Values_Core_1 { unsigned long NID_C; } *


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

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

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

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

original_code:
int National_Values_Core_1_Decode_Bit(Bitstream* stream, National_Values_Core_1* p)
{
    if (Bitstream_Normal(stream, 10))
    {
        {
            p->NID_C = Bitstream_Read(stream, 10);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int National_Values_Core_1_Decode_Bit(struct Bitstream *stream, struct National_Values_Core_1 *p)
{
    if (Bitstream_Normal(stream, 10))
    {
        {
            p->NID_C = Bitstream_Read(stream, 10);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

user_defined_types: struct National_Values_Core_1 { unsigned long NID_C; }


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

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


decompiled_code:
__int64 __fastcall National_Values_Core_1_Decode_Int(__int64 a1, __int64 a2, _QWORD *a3)
{
__int64 v3; // rax

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

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

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


decompiled_code:
_BOOL8 __fastcall PacketForSendingPlainTextMessages_UpperBitsNotSet(__int64 a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
unsigned __int64 v9; // rdi
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // rdx
unsigned __int64 v14; // rdi
__int64 v15; // rdx
__int64 v16; // rdx
__int64 v17; // rdx

result = UpperBitsNotSet64(*(_QWORD *)(a1 + 16), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 24), 13);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 32), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v4 + 40), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v5 + 48), 1);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v6 + 56), 15);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v7 + 64), 4);
if ( result )
{
v9 = *(_QWORD *)(v8 + 72);
result = UpperBitsNotSet64(v9, 3);
if ( result && (v9 != 1 || (result = UpperBitsNotSet64(*(_QWORD *)(v10 + 80), 8))) )
{
result = UpperBitsNotSet64(*(_QWORD *)(v10 + 88), 15);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v11 + 96), 10);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v12 + 104), 4);
if ( result )
{
v14 = *(_QWORD *)(v13 + 112);
result = UpperBitsNotSet64(v14, 3);
if ( result && (v14 != 1 || (result = UpperBitsNotSet64(*(_QWORD *)(v15 + 120), 8))) )
{
result = UpperBitsNotSet64(*(_QWORD *)(v15 + 128), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v16 + 136), 8);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v17 + 144), 8);
}
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}

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

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

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

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


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

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

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

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


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

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

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

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

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

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


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

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


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

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


decompiled_code:
__int64 PacketForSendingPlainTextMessages_New()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( PacketForSendingPlainTextMessagesMemoryFreeList == -1 )
{
if ( (unsigned __int64)PacketForSendingPlainTextMessagesMemoryTop > 7 )
return 0LL;
v3 = 19 * PacketForSendingPlainTextMessagesMemoryTop++;
v0 = &PacketForSendingPlainTextMessagesMemory[v3];
}
else
{
v0 = &PacketForSendingPlainTextMessagesMemory[19 * PacketForSendingPlainTextMessagesMemoryFreeList];
PacketForSendingPlainTextMessagesMemoryFreeList = *v0;
}
PacketForSendingPlainTextMessages_Init(v0);
return v1;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( PacketForSendingPlainTextMessagesMemoryFreeList == -1 )
{
if ( (unsigned __int64)PacketForSendingPlainTextMessagesMemoryTop > 7 )
return 0LL;
v3 = 19 * PacketForSendingPlainTextMessagesMemoryTop++;
v0 = &PacketForSendingPlainTextMessagesMemory[v3];
}
else
{
v0 = &PacketForSendingPlainTextMessagesMemory[19 * PacketForSendingPlainTextMessagesMemoryFreeList];
PacketForSendingPlainTextMessagesMemoryFreeList = *v0;
}
func1(v0);
return v1;
}

original_code:
PacketForSendingPlainTextMessages* PacketForSendingPlainTextMessages_New(void)
{
    PacketForSendingPlainTextMessages* ptr;
    if (PacketForSendingPlainTextMessagesMemoryFreeList != (-1))
    {
        ptr = &PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryFreeList];
        PacketForSendingPlainTextMessagesMemoryFreeList = PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryFreeList].header.NID_PACKET;
    }
    else if (PacketForSendingPlainTextMessagesMemoryTop < 8)
    {
        ptr = &PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryTop];
        PacketForSendingPlainTextMessagesMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PacketForSendingPlainTextMessages_Init(ptr);
    return ptr;
}

canonical_original_code:
struct PacketForSendingPlainTextMessages *PacketForSendingPlainTextMessages_New()
{
    struct PacketForSendingPlainTextMessages *ptr;
    if (PacketForSendingPlainTextMessagesMemoryFreeList != (-1))
    {
        ptr = &PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryFreeList];
        PacketForSendingPlainTextMessagesMemoryFreeList = PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryFreeList].header.NID_PACKET;
    }
    else if (PacketForSendingPlainTextMessagesMemoryTop < 8)
    {
        ptr = &PacketForSendingPlainTextMessagesMemory[PacketForSendingPlainTextMessagesMemoryTop];
        PacketForSendingPlainTextMessagesMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    PacketForSendingPlainTextMessages_Init(ptr);
    return ptr;
}

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


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

*a1 = PacketForSendingPlainTextMessagesMemoryFreeList;
result = 0x86BCA1AF286BCA1BLL;
PacketForSendingPlainTextMessagesMemoryFreeList = 0x86BCA1AF286BCA1BLL
* (a1 - PacketForSendingPlainTextMessagesMemory);
return result;
}

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

*a1 = PacketForSendingPlainTextMessagesMemoryFreeList;
result = 0x86BCA1AF286BCA1BLL;
PacketForSendingPlainTextMessagesMemoryFreeList = 0x86BCA1AF286BCA1BLL
* (a1 - PacketForSendingPlainTextMessagesMemory);
return result;
}

original_code:
void PacketForSendingPlainTextMessages_Delete(PacketForSendingPlainTextMessages* ptr)
{
    ptr->header.NID_PACKET = PacketForSendingPlainTextMessagesMemoryFreeList;
    PacketForSendingPlainTextMessagesMemoryFreeList = ptr - PacketForSendingPlainTextMessagesMemory;
}

canonical_original_code:
void PacketForSendingPlainTextMessages_Delete(struct PacketForSendingPlainTextMessages *ptr)
{
    ptr->header.NID_PACKET = PacketForSendingPlainTextMessagesMemoryFreeList;
    PacketForSendingPlainTextMessagesMemoryFreeList = ptr - PacketForSendingPlainTextMessagesMemory;
}


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 RadioNetworkRegistration_UpperBitsNotSet(__int64 a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx

result = UpperBitsNotSet64(*(_QWORD *)(a1 + 16), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 24), 13);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 32), 24);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx

result = func0(*(_QWORD *)(a1 + 16), 2);
if ( result )
{
result = func0(*(_QWORD *)(v2 + 24), 13);
if ( result )
result = func0(*(_QWORD *)(v3 + 32), 24);
}
return result;
}

original_code:
int RadioNetworkRegistration_UpperBitsNotSet(const RadioNetworkRegistration* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->NID_MN, 24);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int RadioNetworkRegistration_UpperBitsNotSet(struct RadioNetworkRegistration *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->NID_MN, 24);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct RadioNetworkRegistration { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_MN; } *

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


decompiled_code:
__int64 __fastcall RadioNetworkRegistration_EncodeBit(_QWORD *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 39LL) )
return 0xFFFFFFFFLL;
if ( !RadioNetworkRegistration_UpperBitsNotSet((__int64)a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 24LL, a1[4]);
return 1LL;
}

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

original_code:
int RadioNetworkRegistration_EncodeBit(const RadioNetworkRegistration* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 39))
    {
        if (RadioNetworkRegistration_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 24, p->NID_MN);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int RadioNetworkRegistration_EncodeBit(struct RadioNetworkRegistration *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 39))
    {
        if (RadioNetworkRegistration_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 24, p->NID_MN);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}


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

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

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

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

original_code:
int RadioNetworkRegistration_DecodeBit(RadioNetworkRegistration* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 39))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->NID_MN = Bitstream_Read(stream, 24);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int RadioNetworkRegistration_DecodeBit(struct RadioNetworkRegistration *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 39))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->NID_MN = Bitstream_Read(stream, 24);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int RadioNetworkRegistration_EncodeInt(const RadioNetworkRegistration* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 45;
    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_MN;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int RadioNetworkRegistration_EncodeInt(struct RadioNetworkRegistration *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 45;
    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_MN;
    data->endAddress = startAddress-1;
    return 1;
}


original_code:
int RadioNetworkRegistration_DecodeInt(RadioNetworkRegistration* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 45)
    {
         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_MN = stream[startAddress++];
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

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


decompiled_code:
__int64 RadioNetworkRegistration_New()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( RadioNetworkRegistrationMemoryFreeList == -1 )
{
if ( (unsigned __int64)RadioNetworkRegistrationMemoryTop > 7 )
return 0LL;
v3 = 5 * RadioNetworkRegistrationMemoryTop++;
v0 = &RadioNetworkRegistrationMemory[v3];
}
else
{
v0 = &RadioNetworkRegistrationMemory[5 * RadioNetworkRegistrationMemoryFreeList];
RadioNetworkRegistrationMemoryFreeList = *v0;
}
RadioNetworkRegistration_Init(v0);
return v1;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( RadioNetworkRegistrationMemoryFreeList == -1 )
{
if ( (unsigned __int64)RadioNetworkRegistrationMemoryTop > 7 )
return 0LL;
v3 = 5 * RadioNetworkRegistrationMemoryTop++;
v0 = &RadioNetworkRegistrationMemory[v3];
}
else
{
v0 = &RadioNetworkRegistrationMemory[5 * RadioNetworkRegistrationMemoryFreeList];
RadioNetworkRegistrationMemoryFreeList = *v0;
}
func1(v0);
return v1;
}

original_code:
RadioNetworkRegistration* RadioNetworkRegistration_New(void)
{
    RadioNetworkRegistration* ptr;
    if (RadioNetworkRegistrationMemoryFreeList != (-1))
    {
        ptr = &RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryFreeList];
        RadioNetworkRegistrationMemoryFreeList = RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryFreeList].header.NID_PACKET;
    }
    else if (RadioNetworkRegistrationMemoryTop < 8)
    {
        ptr = &RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryTop];
        RadioNetworkRegistrationMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    RadioNetworkRegistration_Init(ptr);
    return ptr;
}

canonical_original_code:
struct RadioNetworkRegistration *RadioNetworkRegistration_New()
{
    struct RadioNetworkRegistration *ptr;
    if (RadioNetworkRegistrationMemoryFreeList != (-1))
    {
        ptr = &RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryFreeList];
        RadioNetworkRegistrationMemoryFreeList = RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryFreeList].header.NID_PACKET;
    }
    else if (RadioNetworkRegistrationMemoryTop < 8)
    {
        ptr = &RadioNetworkRegistrationMemory[RadioNetworkRegistrationMemoryTop];
        RadioNetworkRegistrationMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    RadioNetworkRegistration_Init(ptr);
    return ptr;
}

return_type: struct RadioNetworkRegistration { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long NID_MN; } *


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

*a1 = RadioNetworkRegistrationMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
RadioNetworkRegistrationMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - RadioNetworkRegistrationMemory);
return result;
}

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

*a1 = RadioNetworkRegistrationMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
RadioNetworkRegistrationMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - RadioNetworkRegistrationMemory);
return result;
}

original_code:
void RadioNetworkRegistration_Delete(RadioNetworkRegistration* ptr)
{
    ptr->header.NID_PACKET = RadioNetworkRegistrationMemoryFreeList;
    RadioNetworkRegistrationMemoryFreeList = ptr - RadioNetworkRegistrationMemory;
}

canonical_original_code:
void RadioNetworkRegistration_Delete(struct RadioNetworkRegistration *ptr)
{
    ptr->header.NID_PACKET = RadioNetworkRegistrationMemoryFreeList;
    RadioNetworkRegistrationMemoryFreeList = ptr - RadioNetworkRegistrationMemory;
}


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

result = UpperBitsNotSet64(*a1, 4);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 8), 7);
return result;
}

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

result = func0(*a1, 4);
if ( result )
result = func0(*(_QWORD *)(v2 + 8), 7);
return result;
}

original_code:
int InternationalStaticSpeedProfile_1_UpperBitsNotSet(const InternationalStaticSpeedProfile_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->NC_DIFF, 4) ;
    status = status && UpperBitsNotSet64(p->V_DIFF, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int InternationalStaticSpeedProfile_1_UpperBitsNotSet(struct InternationalStaticSpeedProfile_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->NC_DIFF, 4) ;
    status = status && UpperBitsNotSet64(p->V_DIFF, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct InternationalStaticSpeedProfile_1 { unsigned long NC_DIFF; unsigned long V_DIFF; } *


decompiled_code:
__int64 __fastcall InternationalStaticSpeedProfile_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 11LL) )
return 0xFFFFFFFFLL;
if ( !InternationalStaticSpeedProfile_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 4LL, *a1);
Bitstream_Write(a2, 7LL, a1[1]);
return 1LL;
}

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

original_code:
int InternationalStaticSpeedProfile_1_EncodeBit(const InternationalStaticSpeedProfile_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 11))
    {
        if (InternationalStaticSpeedProfile_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 4, p->NC_DIFF);
            Bitstream_Write(stream, 7, p->V_DIFF);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int InternationalStaticSpeedProfile_1_EncodeBit(struct InternationalStaticSpeedProfile_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 11))
    {
        if (InternationalStaticSpeedProfile_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 4, p->NC_DIFF);
            Bitstream_Write(stream, 7, p->V_DIFF);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int InternationalStaticSpeedProfile_1_DecodeBit(InternationalStaticSpeedProfile_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 11))
    {
        {
            p->NC_DIFF = Bitstream_Read(stream, 4);
        }
        {
            p->V_DIFF = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int InternationalStaticSpeedProfile_1_DecodeBit(struct InternationalStaticSpeedProfile_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 11))
    {
        {
            p->NC_DIFF = Bitstream_Read(stream, 4);
        }
        {
            p->V_DIFF = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int InternationalStaticSpeedProfile_1_EncodeInt(const InternationalStaticSpeedProfile_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->NC_DIFF;
    stream[(*startAddress)++] = p->V_DIFF;
    return 1;
}

canonical_original_code:
int InternationalStaticSpeedProfile_1_EncodeInt(struct InternationalStaticSpeedProfile_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->NC_DIFF;
    stream[(*startAddress)++] = p->V_DIFF;
    return 1;
}

variable_types:
startAddress
int *


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

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

original_code:
int InternationalStaticSpeedProfile_1_DecodeInt(InternationalStaticSpeedProfile_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->NC_DIFF = stream[(*startAddress)++];
    p->V_DIFF = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int InternationalStaticSpeedProfile_1_DecodeInt(struct InternationalStaticSpeedProfile_1 *p, int *startAddress, int *stream)
{
    p->NC_DIFF = stream[(*startAddress)++];
    p->V_DIFF = stream[(*startAddress)++];
    return 1;
}


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

result = UpperBitsNotSet64_constprop_0(*a1);
if ( result )
result = UpperBitsNotSet64_constprop_0(*(_QWORD *)(v2 + 8));
return result;
}

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

result = func0(*a1);
if ( result )
result = func0(*(_QWORD *)(v2 + 8));
return result;
}

original_code:
int AxleLoadSpeedProfile_2_1_UpperBitsNotSet(const AxleLoadSpeedProfile_2_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->M_AXLELOAD, 7) ;
    status = status && UpperBitsNotSet64(p->V_AXLELOAD, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int AxleLoadSpeedProfile_2_1_UpperBitsNotSet(struct AxleLoadSpeedProfile_2_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->M_AXLELOAD, 7) ;
    status = status && UpperBitsNotSet64(p->V_AXLELOAD, 7) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct AxleLoadSpeedProfile_2_1 { unsigned long M_AXLELOAD; unsigned long V_AXLELOAD; } *


decompiled_code:
__int64 __fastcall AxleLoadSpeedProfile_2_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 14LL) )
return 0xFFFFFFFFLL;
if ( !AxleLoadSpeedProfile_2_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 7LL, *a1);
Bitstream_Write(a2, 7LL, a1[1]);
return 1LL;
}

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

original_code:
int AxleLoadSpeedProfile_2_1_EncodeBit(const AxleLoadSpeedProfile_2_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 14))
    {
        if (AxleLoadSpeedProfile_2_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 7, p->M_AXLELOAD);
            Bitstream_Write(stream, 7, p->V_AXLELOAD);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int AxleLoadSpeedProfile_2_1_EncodeBit(struct AxleLoadSpeedProfile_2_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 14))
    {
        if (AxleLoadSpeedProfile_2_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 7, p->M_AXLELOAD);
            Bitstream_Write(stream, 7, p->V_AXLELOAD);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int AxleLoadSpeedProfile_2_1_DecodeBit(AxleLoadSpeedProfile_2_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 14))
    {
        {
            p->M_AXLELOAD = Bitstream_Read(stream, 7);
        }
        {
            p->V_AXLELOAD = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int AxleLoadSpeedProfile_2_1_DecodeBit(struct AxleLoadSpeedProfile_2_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 14))
    {
        {
            p->M_AXLELOAD = Bitstream_Read(stream, 7);
        }
        {
            p->V_AXLELOAD = Bitstream_Read(stream, 7);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int AxleLoadSpeedProfile_2_1_EncodeInt(const AxleLoadSpeedProfile_2_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->M_AXLELOAD;
    stream[(*startAddress)++] = p->V_AXLELOAD;
    return 1;
}

canonical_original_code:
int AxleLoadSpeedProfile_2_1_EncodeInt(struct AxleLoadSpeedProfile_2_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->M_AXLELOAD;
    stream[(*startAddress)++] = p->V_AXLELOAD;
    return 1;
}


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

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

original_code:
int AxleLoadSpeedProfile_2_1_DecodeInt(AxleLoadSpeedProfile_2_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->M_AXLELOAD = stream[(*startAddress)++];
    p->V_AXLELOAD = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int AxleLoadSpeedProfile_2_1_DecodeInt(struct AxleLoadSpeedProfile_2_1 *p, int *startAddress, int *stream)
{
    p->M_AXLELOAD = stream[(*startAddress)++];
    p->V_AXLELOAD = stream[(*startAddress)++];
    return 1;
}


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

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

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

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


decompiled_code:
_BOOL8 __fastcall Level23MovementAuthority_1_UpperBitsNotSet(unsigned __int64 *a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx

result = UpperBitsNotSet64(*a1, 15);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 8), 1);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 16), 10);
if ( result )
result = UpperBitsNotSet64(*(_QWORD *)(v4 + 24), 15);
}
}
return result;
}

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

result = func0(*a1, 15);
if ( result )
{
result = func0(*(_QWORD *)(v2 + 8), 1);
if ( result )
{
result = func0(*(_QWORD *)(v3 + 16), 10);
if ( result )
result = func0(*(_QWORD *)(v4 + 24), 15);
}
}
return result;
}

original_code:
int Level23MovementAuthority_1_UpperBitsNotSet(const Level23MovementAuthority_1* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_SECTION, 15);
    status = status && UpperBitsNotSet64(p->Q_SECTIONTIMER, 1) ;
    status = status && UpperBitsNotSet64(p->T_SECTIONTIMER, 10);
    status = status && UpperBitsNotSet64(p->D_SECTIONTIMERSTOPLOC, 15);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int Level23MovementAuthority_1_UpperBitsNotSet(struct Level23MovementAuthority_1 *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_SECTION, 15);
    status = status && UpperBitsNotSet64(p->Q_SECTIONTIMER, 1) ;
    status = status && UpperBitsNotSet64(p->T_SECTIONTIMER, 10);
    status = status && UpperBitsNotSet64(p->D_SECTIONTIMERSTOPLOC, 15);
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

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


decompiled_code:
__int64 __fastcall Level23MovementAuthority_1_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 41LL) )
return 0xFFFFFFFFLL;
if ( !Level23MovementAuthority_1_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 1LL, a1[1]);
Bitstream_Write(a2, 10LL, a1[2]);
Bitstream_Write(a2, 15LL, a1[3]);
return 1LL;
}

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

original_code:
int Level23MovementAuthority_1_EncodeBit(const Level23MovementAuthority_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        if (Level23MovementAuthority_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->L_SECTION);
            Bitstream_Write(stream, 1, p->Q_SECTIONTIMER);
            Bitstream_Write(stream, 10, p->T_SECTIONTIMER);
            Bitstream_Write(stream, 15, p->D_SECTIONTIMERSTOPLOC);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int Level23MovementAuthority_1_EncodeBit(struct Level23MovementAuthority_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        if (Level23MovementAuthority_1_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->L_SECTION);
            Bitstream_Write(stream, 1, p->Q_SECTIONTIMER);
            Bitstream_Write(stream, 10, p->T_SECTIONTIMER);
            Bitstream_Write(stream, 15, p->D_SECTIONTIMERSTOPLOC);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int Level23MovementAuthority_1_DecodeBit(Level23MovementAuthority_1* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        {
            p->L_SECTION = Bitstream_Read(stream, 15);
        }
        {
            p->Q_SECTIONTIMER = Bitstream_Read(stream, 1);
        }
        {
            p->T_SECTIONTIMER = Bitstream_Read(stream, 10);
        }
        {
            p->D_SECTIONTIMERSTOPLOC = Bitstream_Read(stream, 15);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int Level23MovementAuthority_1_DecodeBit(struct Level23MovementAuthority_1 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 41))
    {
        {
            p->L_SECTION = Bitstream_Read(stream, 15);
        }
        {
            p->Q_SECTIONTIMER = Bitstream_Read(stream, 1);
        }
        {
            p->T_SECTIONTIMER = Bitstream_Read(stream, 10);
        }
        {
            p->D_SECTIONTIMERSTOPLOC = Bitstream_Read(stream, 15);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int Level23MovementAuthority_1_EncodeInt(const Level23MovementAuthority_1* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->L_SECTION;
    stream[(*startAddress)++] = p->Q_SECTIONTIMER;
    stream[(*startAddress)++] = p->T_SECTIONTIMER;
    stream[(*startAddress)++] = p->D_SECTIONTIMERSTOPLOC;
    return 1;
}

canonical_original_code:
int Level23MovementAuthority_1_EncodeInt(struct Level23MovementAuthority_1 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->L_SECTION;
    stream[(*startAddress)++] = p->Q_SECTIONTIMER;
    stream[(*startAddress)++] = p->T_SECTIONTIMER;
    stream[(*startAddress)++] = p->D_SECTIONTIMERSTOPLOC;
    return 1;
}


original_code:
int Level23MovementAuthority_1_DecodeInt(Level23MovementAuthority_1* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->L_SECTION = stream[(*startAddress)++];
    p->Q_SECTIONTIMER = stream[(*startAddress)++];
    p->T_SECTIONTIMER = stream[(*startAddress)++];
    p->D_SECTIONTIMERSTOPLOC = stream[(*startAddress)++];
    return 1;
}

canonical_original_code:
int Level23MovementAuthority_1_DecodeInt(struct Level23MovementAuthority_1 *p, int *startAddress, int *stream)
{
    p->L_SECTION = stream[(*startAddress)++];
    p->Q_SECTIONTIMER = stream[(*startAddress)++];
    p->T_SECTIONTIMER = stream[(*startAddress)++];
    p->D_SECTIONTIMERSTOPLOC = stream[(*startAddress)++];
    return 1;
}


decompiled_code:
_BOOL8 __fastcall TrackCondition_UpperBitsNotSet(unsigned __int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rdx
unsigned __int64 v4; // rbx
_BOOL4 v5; // eax
unsigned __int64 v6; // rax
int v7; // er8

if ( !UpperBitsNotSet64(a1[2], 2)
|| !UpperBitsNotSet64(a1[3], 13)
|| !UpperBitsNotSet64(a1[4], 2)
|| !UpperBitsNotSet64(a1[5], 1) )
{
goto LABEL_10;
}
if ( v1 == 1 )
{
if ( !UpperBitsNotSet64(a1[6], 15) )
{
LABEL_10:
v2 = a1[10];
if ( !v2 )
return 0LL;
LODWORD(v4) = 0;
do
{
LABEL_13:
if ( (unsigned int)(v4 + 1) >= v2 )
break;
v4 = (unsigned int)(v4 + 2);
}
while ( v4 < v2 );
return 0LL;
}
}
else if ( !v1 && (!UpperBitsNotSet64(a1[7], 15) || !UpperBitsNotSet64(a1[8], 15) || !UpperBitsNotSet64(a1[9], 4)) )
{
goto LABEL_10;
}
v5 = UpperBitsNotSet64(a1[10], 5);
if ( v2 )
{
LODWORD(v4) = 0;
if ( v5 )
{
v6 = 0LL;
while ( 1 )
{
v7 = TrackCondition_1_UpperBitsNotSet(&a1[3 * v6 + 11]);
v6 = (unsigned int)(v4 + 1);
LODWORD(v4) = v4 + 1;
if ( !v7 )
break;
if ( v6 >= a1[10] )
return 1LL;
}
v2 = a1[10];
if ( v6 < v2 )
goto LABEL_13;
return 0LL;
}
goto LABEL_13;
}
return v5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(unsigned __int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rdx
unsigned __int64 v4; // rbx
_BOOL4 v5; // eax
unsigned __int64 v6; // rax
int v7; // er8

if ( !func0(a1[2], 2)
|| !func0(a1[3], 13)
|| !func0(a1[4], 2)
|| !func0(a1[5], 1) )
{
goto LABEL_10;
}
if ( v1 == 1 )
{
if ( !func0(a1[6], 15) )
{
LABEL_10:
v2 = a1[10];
if ( !v2 )
return 0LL;
LODWORD(v4) = 0;
do
{
LABEL_13:
if ( (unsigned int)(v4 + 1) >= v2 )
break;
v4 = (unsigned int)(v4 + 2);
}
while ( v4 < v2 );
return 0LL;
}
}
else if ( !v1 && (!func0(a1[7], 15) || !func0(a1[8], 15) || !func0(a1[9], 4)) )
{
goto LABEL_10;
}
v5 = func0(a1[10], 5);
if ( v2 )
{
LODWORD(v4) = 0;
if ( v5 )
{
v6 = 0LL;
while ( 1 )
{
v7 = TrackCondition_1_UpperBitsNotSet(&a1[3 * v6 + 11]);
v6 = (unsigned int)(v4 + 1);
LODWORD(v4) = v4 + 1;
if ( !v7 )
break;
if ( v6 >= a1[10] )
return 1LL;
}
v2 = a1[10];
if ( v6 < v2 )
goto LABEL_13;
return 0LL;
}
goto LABEL_13;
}
return v5;
}

original_code:
int TrackCondition_UpperBitsNotSet(const TrackCondition* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TRACKINIT, 1) ;
    if (p->Q_TRACKINIT == 1)
    {
        status = status && UpperBitsNotSet64(p->D_TRACKINIT, 15);
    }
    if (p->Q_TRACKINIT == 0)
    {
        status = status && UpperBitsNotSet64(p->D_TRACKCOND, 15);
        status = status && UpperBitsNotSet64(p->L_TRACKCOND, 15);
        status = status && UpperBitsNotSet64(p->M_TRACKCOND, 4) ;
    }
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && TrackCondition_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackCondition_UpperBitsNotSet(struct TrackCondition *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->Q_TRACKINIT, 1) ;
    if (p->Q_TRACKINIT == 1)
    {
        status = status && UpperBitsNotSet64(p->D_TRACKINIT, 15);
    }
    if (p->Q_TRACKINIT == 0)
    {
        status = status && UpperBitsNotSet64(p->D_TRACKCOND, 15);
        status = status && UpperBitsNotSet64(p->L_TRACKCOND, 15);
        status = status && UpperBitsNotSet64(p->M_TRACKCOND, 4) ;
    }
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && TrackCondition_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

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

variable_types:
i
unsigned int

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


decompiled_code:
__int64 __fastcall TrackCondition_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // ebp
__int64 v4; // rax

if ( !(unsigned int)Bitstream_Normal(a2, 23LL) )
return 0xFFFFFFFFLL;
if ( !TrackCondition_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, 1LL, a1[5]);
v2 = a1[5];
if ( v2 == 1 )
{
Bitstream_Write(a2, 15LL, a1[6]);
v2 = a1[5];
}
if ( !v2 )
{
Bitstream_Write(a2, 15LL, a1[7]);
Bitstream_Write(a2, 15LL, a1[8]);
Bitstream_Write(a2, 4LL, a1[9]);
}
v3 = 0;
Bitstream_Write(a2, 5LL, a1[10]);
v4 = 0LL;
if ( a1[10] )
{
do
{
TrackCondition_1_EncodeBit(&a1[3 * v4 + 11], a2);
v4 = ++v3;
}
while ( v3 < a1[10] );
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, __int64 a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // ebp
__int64 v4; // rax

if ( !(unsigned int)Bitstream_Normal(a2, 23LL) )
return 0xFFFFFFFFLL;
if ( !func3(a1) )
return 4294967294LL;
Bitstream_Write(a2, 2LL, a1[2]);
Bitstream_Write(a2, 13LL, a1[3]);
Bitstream_Write(a2, 2LL, a1[4]);
Bitstream_Write(a2, 1LL, a1[5]);
v2 = a1[5];
if ( v2 == 1 )
{
Bitstream_Write(a2, 15LL, a1[6]);
v2 = a1[5];
}
if ( !v2 )
{
Bitstream_Write(a2, 15LL, a1[7]);
Bitstream_Write(a2, 15LL, a1[8]);
Bitstream_Write(a2, 4LL, a1[9]);
}
v3 = 0;
Bitstream_Write(a2, 5LL, a1[10]);
v4 = 0LL;
if ( a1[10] )
{
do
{
TrackCondition_1_EncodeBit(&a1[3 * v4 + 11], a2);
v4 = ++v3;
}
while ( v3 < a1[10] );
}
return 1LL;
}

original_code:
int TrackCondition_EncodeBit(const TrackCondition* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        if (TrackCondition_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, 1, p->Q_TRACKINIT);
            if (p->Q_TRACKINIT == 1)
            {
                Bitstream_Write(stream, 15, p->D_TRACKINIT);
            }
            if (p->Q_TRACKINIT == 0)
            {
                Bitstream_Write(stream, 15, p->D_TRACKCOND);
                Bitstream_Write(stream, 15, p->L_TRACKCOND);
                Bitstream_Write(stream, 4, p->M_TRACKCOND);
            }
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (uint32_t i = 0; i < p->N_ITER_1; ++i)
            {
                TrackCondition_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int TrackCondition_EncodeBit(struct TrackCondition *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        if (TrackCondition_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, 1, p->Q_TRACKINIT);
            if (p->Q_TRACKINIT == 1)
            {
                Bitstream_Write(stream, 15, p->D_TRACKINIT);
            }
            if (p->Q_TRACKINIT == 0)
            {
                Bitstream_Write(stream, 15, p->D_TRACKCOND);
                Bitstream_Write(stream, 15, p->L_TRACKCOND);
                Bitstream_Write(stream, 4, p->M_TRACKCOND);
            }
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (unsigned int i = 0; i < p->N_ITER_1; ++i)
            {
                TrackCondition_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            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_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // er12
__int64 v5; // rdx
__int64 v6; // rax

result = Bitstream_Normal(a2, 23LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
v3 = Bitstream_Read(a2, 1LL);
a1[5] = v3;
if ( v3 == 1 )
{
a1[6] = Bitstream_Read(a2, 15LL);
v3 = a1[5];
}
if ( !v3 )
{
a1[7] = Bitstream_Read(a2, 15LL);
a1[8] = Bitstream_Read(a2, 15LL);
a1[9] = Bitstream_Read(a2, 4LL);
}
v4 = 0;
v5 = Bitstream_Read(a2, 5LL);
a1[10] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
TrackCondition_1_DecodeBit(&a1[3 * v6 + 11], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[10] );
}
result = 1LL;
}
return result;
}

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

result = Bitstream_Normal(a2, 23LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
v3 = Bitstream_Read(a2, 1LL);
a1[5] = v3;
if ( v3 == 1 )
{
a1[6] = Bitstream_Read(a2, 15LL);
v3 = a1[5];
}
if ( !v3 )
{
a1[7] = Bitstream_Read(a2, 15LL);
a1[8] = Bitstream_Read(a2, 15LL);
a1[9] = Bitstream_Read(a2, 4LL);
}
v4 = 0;
v5 = Bitstream_Read(a2, 5LL);
a1[10] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
TrackCondition_1_DecodeBit(&a1[3 * v6 + 11], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[10] );
}
result = 1LL;
}
return result;
}

original_code:
int TrackCondition_DecodeBit(TrackCondition* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TRACKINIT = Bitstream_Read(stream, 1);
        }
        if (p->Q_TRACKINIT == 1)
        {
            {
                p->D_TRACKINIT = Bitstream_Read(stream, 15);
            }
        }
        if (p->Q_TRACKINIT == 0)
        {
            {
                p->D_TRACKCOND = Bitstream_Read(stream, 15);
            }
            {
                p->L_TRACKCOND = Bitstream_Read(stream, 15);
            }
            {
                p->M_TRACKCOND = Bitstream_Read(stream, 4);
            }
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_1; ++i)
        {
            TrackCondition_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int TrackCondition_DecodeBit(struct TrackCondition *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->Q_TRACKINIT = Bitstream_Read(stream, 1);
        }
        if (p->Q_TRACKINIT == 1)
        {
            {
                p->D_TRACKINIT = Bitstream_Read(stream, 15);
            }
        }
        if (p->Q_TRACKINIT == 0)
        {
            {
                p->D_TRACKCOND = Bitstream_Read(stream, 15);
            }
            {
                p->L_TRACKCOND = Bitstream_Read(stream, 15);
            }
            {
                p->M_TRACKCOND = Bitstream_Read(stream, 4);
            }
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_1; ++i)
        {
            TrackCondition_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int TrackCondition_EncodeInt(const TrackCondition* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 68;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    kcg_int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->Q_TRACKINIT;
    stream[startAddress++] = p->D_TRACKINIT;
    stream[startAddress++] = p->D_TRACKCOND;
    stream[startAddress++] = p->L_TRACKCOND;
    stream[startAddress++] = p->M_TRACKCOND;
    stream[startAddress++] = p->N_ITER_1;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        TrackCondition_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int TrackCondition_EncodeInt(struct TrackCondition *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 68;
    data->q_dir = p->Q_DIR;
    data->valid = 1;
    int startAddress = data->startAddress;
    stream[startAddress++] = p->header.NID_PACKET;
    stream[startAddress++] = p->Q_DIR;
    stream[startAddress++] = p->L_PACKET;
    stream[startAddress++] = p->Q_SCALE;
    stream[startAddress++] = p->Q_TRACKINIT;
    stream[startAddress++] = p->D_TRACKINIT;
    stream[startAddress++] = p->D_TRACKCOND;
    stream[startAddress++] = p->L_TRACKCOND;
    stream[startAddress++] = p->M_TRACKCOND;
    stream[startAddress++] = p->N_ITER_1;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        TrackCondition_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}


original_code:
int TrackCondition_DecodeInt(TrackCondition* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 68)
    {
         return 0;
    }
    kcg_int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->Q_TRACKINIT = stream[startAddress++];
    p->D_TRACKINIT = stream[startAddress++];
    p->D_TRACKCOND = stream[startAddress++];
    p->L_TRACKCOND = stream[startAddress++];
    p->M_TRACKCOND = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        TrackCondition_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int TrackCondition_DecodeInt(struct TrackCondition *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 68)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SCALE = stream[startAddress++];
    p->Q_TRACKINIT = stream[startAddress++];
    p->D_TRACKINIT = stream[startAddress++];
    p->D_TRACKCOND = stream[startAddress++];
    p->L_TRACKCOND = stream[startAddress++];
    p->M_TRACKCOND = stream[startAddress++];
    p->N_ITER_1 = stream[startAddress++];
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        TrackCondition_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


decompiled_code:
__int64 TrackCondition_New()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // r8

if ( TrackConditionMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrackConditionMemoryTop > 7 )
return 0LL;
v3 = 104 * TrackConditionMemoryTop++;
v0 = &TrackConditionMemory[v3];
}
else
{
v0 = &TrackConditionMemory[104 * TrackConditionMemoryFreeList];
TrackConditionMemoryFreeList = *v0;
}
TrackCondition_Init(v0);
return v1;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // r8

if ( TrackConditionMemoryFreeList == -1 )
{
if ( (unsigned __int64)TrackConditionMemoryTop > 7 )
return 0LL;
v3 = 104 * TrackConditionMemoryTop++;
v0 = &TrackConditionMemory[v3];
}
else
{
v0 = &TrackConditionMemory[104 * TrackConditionMemoryFreeList];
TrackConditionMemoryFreeList = *v0;
}
func2(v0);
return v1;
}

original_code:
TrackCondition* TrackCondition_New(void)
{
    TrackCondition* ptr;
    if (TrackConditionMemoryFreeList != (-1))
    {
        ptr = &TrackConditionMemory[TrackConditionMemoryFreeList];
        TrackConditionMemoryFreeList = TrackConditionMemory[TrackConditionMemoryFreeList].header.NID_PACKET;
    }
    else if (TrackConditionMemoryTop < 8)
    {
        ptr = &TrackConditionMemory[TrackConditionMemoryTop];
        TrackConditionMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrackCondition_Init(ptr);
    return ptr;
}

canonical_original_code:
struct TrackCondition *TrackCondition_New()
{
    struct TrackCondition *ptr;
    if (TrackConditionMemoryFreeList != (-1))
    {
        ptr = &TrackConditionMemory[TrackConditionMemoryFreeList];
        TrackConditionMemoryFreeList = TrackConditionMemory[TrackConditionMemoryFreeList].header.NID_PACKET;
    }
    else if (TrackConditionMemoryTop < 8)
    {
        ptr = &TrackConditionMemory[TrackConditionMemoryTop];
        TrackConditionMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    TrackCondition_Init(ptr);
    return ptr;
}

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


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

*(_QWORD *)a1 = TrackConditionMemoryFreeList;
result = 0x4EC4EC4EC4EC4EC5LL;
TrackConditionMemoryFreeList = 0x4EC4EC4EC4EC4EC5LL * ((a1 - (char *)TrackConditionMemory) >> 6);
return result;
}

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

*(_QWORD *)a1 = TrackConditionMemoryFreeList;
result = 0x4EC4EC4EC4EC4EC5LL;
TrackConditionMemoryFreeList = 0x4EC4EC4EC4EC4EC5LL * ((a1 - (char *)TrackConditionMemory) >> 6);
return result;
}

original_code:
void TrackCondition_Delete(TrackCondition* ptr)
{
    ptr->header.NID_PACKET = TrackConditionMemoryFreeList;
    TrackConditionMemoryFreeList = ptr - TrackConditionMemory;
}

canonical_original_code:
void TrackCondition_Delete(struct TrackCondition *ptr)
{
    ptr->header.NID_PACKET = TrackConditionMemoryFreeList;
    TrackConditionMemoryFreeList = ptr - TrackConditionMemory;
}


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

result = UpperBitsNotSet64_constprop_0(*a1);
if ( result )
result = UpperBitsNotSet64_constprop_0(*(_QWORD *)(v2 + 8));
return result;
}

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

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

variable_types: struct TrackConditionBigMetalMasses_1 { unsigned long D_TRACKCOND; unsigned long L_TRACKCOND; } *