decompiled_code:
__int64 __fastcall AxleLoadSpeedProfile_2_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
unsigned int v3; // er12
__int64 v4; // rdi

if ( !(unsigned int)Bitstream_Normal(a2, 36LL) )
return 0xFFFFFFFFLL;
if ( !AxleLoadSpeedProfile_2_UpperBitsNotSet(a1) )
return 4294967294LL;
v3 = 0;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 15LL, a1[1]);
Bitstream_Write(a2, 1LL, a1[2]);
Bitstream_Write(a2, 5LL, a1[3]);
v4 = 0LL;
if ( a1[3] )
{
do
{
AxleLoadSpeedProfile_2_1_EncodeBit(&a1[2 * v4 + 4], a2);
v4 = ++v3;
}
while ( v3 < a1[3] );
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 *a1, __int64 a2)
{
unsigned int v3; // er12
__int64 v4; // rdi

if ( !(unsigned int)Bitstream_Normal(a2, 36LL) )
return 0xFFFFFFFFLL;
if ( !func1(a1) )
return 4294967294LL;
v3 = 0;
Bitstream_Write(a2, 15LL, *a1);
Bitstream_Write(a2, 15LL, a1[1]);
Bitstream_Write(a2, 1LL, a1[2]);
Bitstream_Write(a2, 5LL, a1[3]);
v4 = 0LL;
if ( a1[3] )
{
do
{
AxleLoadSpeedProfile_2_1_EncodeBit(&a1[2 * v4 + 4], a2);
v4 = ++v3;
}
while ( v3 < a1[3] );
}
return 1LL;
}

original_code:
int AxleLoadSpeedProfile_2_EncodeBit(const AxleLoadSpeedProfile_2* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 36))
    {
        if (AxleLoadSpeedProfile_2_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_AXLELOAD);
            Bitstream_Write(stream, 15, p->L_AXLELOAD);
            Bitstream_Write(stream, 1, p->Q_FRONT);
            Bitstream_Write(stream, 5, p->N_ITER_2_1);
            for (uint32_t i = 0; i < p->N_ITER_2_1; ++i)
            {
                AxleLoadSpeedProfile_2_1_EncodeBit(&(p->sub_2_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int AxleLoadSpeedProfile_2_EncodeBit(struct AxleLoadSpeedProfile_2 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 36))
    {
        if (AxleLoadSpeedProfile_2_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 15, p->D_AXLELOAD);
            Bitstream_Write(stream, 15, p->L_AXLELOAD);
            Bitstream_Write(stream, 1, p->Q_FRONT);
            Bitstream_Write(stream, 5, p->N_ITER_2_1);
            for (unsigned int i = 0; i < p->N_ITER_2_1; ++i)
            {
                AxleLoadSpeedProfile_2_1_EncodeBit(&(p->sub_2_1[i]), stream);
            }
            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 AxleLoadSpeedProfile_2_1 { unsigned long M_AXLELOAD; unsigned long V_AXLELOAD; }


repo: openETCS/dataDictionary

decompiled_code:
__int64 __fastcall AxleLoadSpeedProfile_2_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
unsigned int v4; // er12
__int64 v5; // rax
__int64 v6; // rdi

result = Bitstream_Normal(a2, 36LL);
if ( (_DWORD)result )
{
v4 = 0;
*a1 = Bitstream_Read(a2, 15LL);
a1[1] = Bitstream_Read(a2, 15LL);
a1[2] = Bitstream_Read(a2, 1LL);
v5 = Bitstream_Read(a2, 5LL);
v6 = 0LL;
a1[3] = v5;
if ( v5 )
{
do
{
AxleLoadSpeedProfile_2_1_DecodeBit(&a1[2 * v6 + 4], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[3] );
}
result = 1LL;
}
return result;
}

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

result = Bitstream_Normal(a2, 36LL);
if ( (_DWORD)result )
{
v4 = 0;
*a1 = Bitstream_Read(a2, 15LL);
a1[1] = Bitstream_Read(a2, 15LL);
a1[2] = Bitstream_Read(a2, 1LL);
v5 = Bitstream_Read(a2, 5LL);
v6 = 0LL;
a1[3] = v5;
if ( v5 )
{
do
{
AxleLoadSpeedProfile_2_1_DecodeBit(&a1[2 * v6 + 4], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[3] );
}
result = 1LL;
}
return result;
}

original_code:
int AxleLoadSpeedProfile_2_DecodeBit(AxleLoadSpeedProfile_2* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 36))
    {
        {
            p->D_AXLELOAD = Bitstream_Read(stream, 15);
        }
        {
            p->L_AXLELOAD = Bitstream_Read(stream, 15);
        }
        {
            p->Q_FRONT = Bitstream_Read(stream, 1);
        }
    {
            p->N_ITER_2_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_2_1; ++i)
        {
            AxleLoadSpeedProfile_2_1_DecodeBit(&(p->sub_2_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int AxleLoadSpeedProfile_2_DecodeBit(struct AxleLoadSpeedProfile_2 *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 36))
    {
        {
            p->D_AXLELOAD = Bitstream_Read(stream, 15);
        }
        {
            p->L_AXLELOAD = Bitstream_Read(stream, 15);
        }
        {
            p->Q_FRONT = Bitstream_Read(stream, 1);
        }
    {
            p->N_ITER_2_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_2_1; ++i)
        {
            AxleLoadSpeedProfile_2_1_DecodeBit(&(p->sub_2_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct AxleLoadSpeedProfile_2 { unsigned long D_AXLELOAD; unsigned long L_AXLELOAD; unsigned long Q_FRONT; unsigned long N_ITER_2_1; struct AxleLoadSpeedProfile_2_1 { unsigned long M_AXLELOAD; unsigned long V_AXLELOAD; } sub_2_1[31]; } *

variable_types:
i
unsigned int

return_type: int

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

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


original_code:
int AxleLoadSpeedProfile_2_EncodeInt(const AxleLoadSpeedProfile_2* p, kcg_int* startAddress, kcg_int* stream)
{
    stream[(*startAddress)++] = p->D_AXLELOAD;
    stream[(*startAddress)++] = p->L_AXLELOAD;
    stream[(*startAddress)++] = p->Q_FRONT;
    stream[(*startAddress)++] = p->N_ITER_2_1;
    for (uint32_t i = 0; i < p->N_ITER_2_1; ++i)
    {
        AxleLoadSpeedProfile_2_1_EncodeInt(&(p->sub_2_1[i]), startAddress, stream);
    }
    return 1;
}

canonical_original_code:
int AxleLoadSpeedProfile_2_EncodeInt(struct AxleLoadSpeedProfile_2 *p, int *startAddress, int *stream)
{
    stream[(*startAddress)++] = p->D_AXLELOAD;
    stream[(*startAddress)++] = p->L_AXLELOAD;
    stream[(*startAddress)++] = p->Q_FRONT;
    stream[(*startAddress)++] = p->N_ITER_2_1;
    for (unsigned int i = 0; i < p->N_ITER_2_1; ++i)
    {
        AxleLoadSpeedProfile_2_1_EncodeInt(&(p->sub_2_1[i]), startAddress, stream);
    }
    return 1;
}

variable_types:
startAddress
int *

variable_types:
stream
int *


original_code:
int AxleLoadSpeedProfile_2_DecodeInt(AxleLoadSpeedProfile_2* p, kcg_int* startAddress, const kcg_int* stream)
{
    p->D_AXLELOAD = stream[(*startAddress)++];
    p->L_AXLELOAD = stream[(*startAddress)++];
    p->Q_FRONT = stream[(*startAddress)++];
    p->N_ITER_2_1 = stream[(*startAddress)++];
    for (uint32_t i = 0; i < p->N_ITER_2_1; ++i)
    {
        AxleLoadSpeedProfile_2_1_DecodeInt(&(p->sub_2_1[i]), startAddress, stream);
    }
    return 1;
}

canonical_original_code:
int AxleLoadSpeedProfile_2_DecodeInt(struct AxleLoadSpeedProfile_2 *p, int *startAddress, int *stream)
{
    p->D_AXLELOAD = stream[(*startAddress)++];
    p->L_AXLELOAD = stream[(*startAddress)++];
    p->Q_FRONT = stream[(*startAddress)++];
    p->N_ITER_2_1 = stream[(*startAddress)++];
    for (unsigned int i = 0; i < p->N_ITER_2_1; ++i)
    {
        AxleLoadSpeedProfile_2_1_DecodeInt(&(p->sub_2_1[i]), startAddress, stream);
    }
    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;
    }
}

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long


decompiled_code:
_BOOL8 __fastcall StopIfInStaffResponsible_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), 1);
}
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), 1);
}
return result;
}

original_code:
int StopIfInStaffResponsible_UpperBitsNotSet(const StopIfInStaffResponsible* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SRSTOP, 1) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int StopIfInStaffResponsible_UpperBitsNotSet(struct StopIfInStaffResponsible *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SRSTOP, 1) ;
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct StopIfInStaffResponsible { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SRSTOP; } *

variable_types: status int

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


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

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

original_code:
int StopIfInStaffResponsible_EncodeBit(const StopIfInStaffResponsible* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 16))
    {
        if (StopIfInStaffResponsible_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 1, p->Q_SRSTOP);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int StopIfInStaffResponsible_EncodeBit(struct StopIfInStaffResponsible *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 16))
    {
        if (StopIfInStaffResponsible_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 1, p->Q_SRSTOP);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

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

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

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

original_code:
int StopIfInStaffResponsible_DecodeBit(StopIfInStaffResponsible* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 16))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SRSTOP = Bitstream_Read(stream, 1);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int StopIfInStaffResponsible_DecodeBit(struct StopIfInStaffResponsible *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 16))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SRSTOP = Bitstream_Read(stream, 1);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int StopIfInStaffResponsible_EncodeInt(const StopIfInStaffResponsible* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 137;
    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_SRSTOP;
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int StopIfInStaffResponsible_EncodeInt(struct StopIfInStaffResponsible *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 137;
    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_SRSTOP;
    data->endAddress = startAddress-1;
    return 1;
}

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

variable_types: startAddress int


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

canonical_original_code:
int StopIfInStaffResponsible_DecodeInt(struct StopIfInStaffResponsible *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 137)
    {
         return 0;
    }
    int startAddress = data->startAddress;
    p->header.NID_PACKET = stream[startAddress++];
    p->Q_DIR = stream[startAddress++];
    p->L_PACKET = stream[startAddress++];
    p->Q_SRSTOP = 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 StopIfInStaffResponsible_New()
{
__int64 *v0; // r8
__int64 v1; // r8
__int64 v3; // rdx

if ( StopIfInStaffResponsibleMemoryFreeList == -1 )
{
if ( (unsigned __int64)StopIfInStaffResponsibleMemoryTop > 7 )
return 0LL;
v3 = 5 * StopIfInStaffResponsibleMemoryTop++;
v0 = &StopIfInStaffResponsibleMemory[v3];
}
else
{
v0 = &StopIfInStaffResponsibleMemory[5 * StopIfInStaffResponsibleMemoryFreeList];
StopIfInStaffResponsibleMemoryFreeList = *v0;
}
StopIfInStaffResponsible_Init(v0);
return v1;
}

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

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

original_code:
StopIfInStaffResponsible* StopIfInStaffResponsible_New(void)
{
    StopIfInStaffResponsible* ptr;
    if (StopIfInStaffResponsibleMemoryFreeList != (-1))
    {
        ptr = &StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryFreeList];
        StopIfInStaffResponsibleMemoryFreeList = StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryFreeList].header.NID_PACKET;
    }
    else if (StopIfInStaffResponsibleMemoryTop < 8)
    {
        ptr = &StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryTop];
        StopIfInStaffResponsibleMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    StopIfInStaffResponsible_Init(ptr);
    return ptr;
}

canonical_original_code:
struct StopIfInStaffResponsible *StopIfInStaffResponsible_New()
{
    struct StopIfInStaffResponsible *ptr;
    if (StopIfInStaffResponsibleMemoryFreeList != (-1))
    {
        ptr = &StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryFreeList];
        StopIfInStaffResponsibleMemoryFreeList = StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryFreeList].header.NID_PACKET;
    }
    else if (StopIfInStaffResponsibleMemoryTop < 8)
    {
        ptr = &StopIfInStaffResponsibleMemory[StopIfInStaffResponsibleMemoryTop];
        StopIfInStaffResponsibleMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    StopIfInStaffResponsible_Init(ptr);
    return ptr;
}

return_type: struct StopIfInStaffResponsible { struct PacketHeader { unsigned long NID_PACKET; unsigned long list; } header; unsigned long Q_DIR; unsigned long L_PACKET; unsigned long Q_SRSTOP; } *


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

*a1 = StopIfInStaffResponsibleMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
StopIfInStaffResponsibleMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - StopIfInStaffResponsibleMemory);
return result;
}

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

*a1 = StopIfInStaffResponsibleMemoryFreeList;
result = 0xCCCCCCCCCCCCCCCDLL;
StopIfInStaffResponsibleMemoryFreeList = 0xCCCCCCCCCCCCCCCDLL * (a1 - StopIfInStaffResponsibleMemory);
return result;
}

original_code:
void StopIfInStaffResponsible_Delete(StopIfInStaffResponsible* ptr)
{
    ptr->header.NID_PACKET = StopIfInStaffResponsibleMemoryFreeList;
    StopIfInStaffResponsibleMemoryFreeList = ptr - StopIfInStaffResponsibleMemory;
}

canonical_original_code:
void StopIfInStaffResponsible_Delete(struct StopIfInStaffResponsible *ptr)
{
    ptr->header.NID_PACKET = StopIfInStaffResponsibleMemoryFreeList;
    StopIfInStaffResponsibleMemoryFreeList = ptr - StopIfInStaffResponsibleMemory;
}

return_type: void


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

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

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

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

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

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

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


original_code:
static inline int TelegramHeader_Equal(const TelegramHeader* a, const TelegramHeader* b)
{
    return (a->Q_UPDOWN == b->Q_UPDOWN) &&
           (a->M_VERSION == b->M_VERSION) &&
           (a->Q_MEDIA == b->Q_MEDIA) &&
           (a->N_PIG == b->N_PIG) &&
           (a->N_TOTAL == b->N_TOTAL) &&
           (a->M_DUP == b->M_DUP) &&
           (a->M_MCOUNT == b->M_MCOUNT) &&
           (a->NID_C == b->NID_C) &&
           (a->NID_BG == b->NID_BG) &&
           (a->Q_LINK == b->Q_LINK);
}

canonical_original_code:
static inline int TelegramHeader_Equal(struct TelegramHeader *a, struct TelegramHeader *b)
{
    return (a->Q_UPDOWN == b->Q_UPDOWN) &&
           (a->M_VERSION == b->M_VERSION) &&
           (a->Q_MEDIA == b->Q_MEDIA) &&
           (a->N_PIG == b->N_PIG) &&
           (a->N_TOTAL == b->N_TOTAL) &&
           (a->M_DUP == b->M_DUP) &&
           (a->M_MCOUNT == b->M_MCOUNT) &&
           (a->NID_C == b->NID_C) &&
           (a->NID_BG == b->NID_BG) &&
           (a->Q_LINK == b->Q_LINK);
}

variable_types:
b
struct TelegramHeader *

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


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

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

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

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

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

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

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

variable_types:
h
struct PacketHeader *

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


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

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

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

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

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

variable_types:
p
struct PacketHeader *

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


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

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

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

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

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

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

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

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


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

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

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

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

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

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall PacketSequence_Back(__int64 a1)
{
int v1; // esi

v1 = *(_DWORD *)(a1 + 400);
if ( !v1 )
_assert_fail("s->size > 0", "..//Telegram/PacketSequence.h", 0x38u, "PacketSequence_Back");
return PacketSequence_Get(a1, v1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
int v1; // esi

v1 = *(_DWORD *)(a1 + 400);
if ( !v1 )
_assert_fail("s->size > 0", "..//Telegram/PacketSequence.h", 0x38u, "PacketSequence_Back");
return func7(a1, v1 - 1);
}

original_code:
static inline const PacketHeader* PacketSequence_Back(const PacketSequence* s)
{
    ((s->size > 0) ? (void) (0) : __assert_fail ("s->size > 0", "..//Telegram/PacketSequence.h", 56, __extension__ __PRETTY_FUNCTION__));
    return PacketSequence_Get(s, s->size - 1);
}

canonical_original_code:
static inline struct PacketHeader *PacketSequence_Back(struct PacketSequence *s)
{
    ((s->size > 0) ? (void) (0) : __assert_fail ("s->size > 0", "..//Telegram/PacketSequence.h", 56, __extension__ __PRETTY_FUNCTION__));
    return PacketSequence_Get(s, s->size - 1);
}


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

result = Bitstream_Normal(a1, 50LL);
if ( (_DWORD)result )
{
*a2 = Bitstream_Read(a1, 1LL);
a2[1] = Bitstream_Read(a1, 7LL);
a2[2] = Bitstream_Read(a1, 1LL);
a2[3] = Bitstream_Read(a1, 3LL);
a2[4] = Bitstream_Read(a1, 3LL);
a2[5] = Bitstream_Read(a1, 2LL);
a2[6] = Bitstream_Read(a1, 8LL);
a2[7] = Bitstream_Read(a1, 10LL);
a2[8] = Bitstream_Read(a1, 14LL);
a2[9] = Bitstream_Read(a1, 1LL);
result = 1LL;
}
return result;
}

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

result = Bitstream_Normal(a1, 50LL);
if ( (_DWORD)result )
{
*a2 = Bitstream_Read(a1, 1LL);
a2[1] = Bitstream_Read(a1, 7LL);
a2[2] = Bitstream_Read(a1, 1LL);
a2[3] = Bitstream_Read(a1, 3LL);
a2[4] = Bitstream_Read(a1, 3LL);
a2[5] = Bitstream_Read(a1, 2LL);
a2[6] = Bitstream_Read(a1, 8LL);
a2[7] = Bitstream_Read(a1, 10LL);
a2[8] = Bitstream_Read(a1, 14LL);
a2[9] = Bitstream_Read(a1, 1LL);
result = 1LL;
}
return result;
}

original_code:
static inline
int TelegramHeader_DecodeBit(Bitstream* stream, TelegramHeader* p)
{
    if (Bitstream_Normal(stream, 50))
    {
        {
            p->Q_UPDOWN = Bitstream_Read(stream, 1);
        }
        {
            p->M_VERSION = Bitstream_Read(stream, 7);
        }
        {
            p->Q_MEDIA = Bitstream_Read(stream, 1);
        }
        {
            p->N_PIG = Bitstream_Read(stream, 3);
        }
        {
            p->N_TOTAL = Bitstream_Read(stream, 3);
        }
        {
            p->M_DUP = Bitstream_Read(stream, 2);
        }
        {
            p->M_MCOUNT = Bitstream_Read(stream, 8);
        }
        {
            p->NID_C = Bitstream_Read(stream, 10);
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        {
            p->Q_LINK = Bitstream_Read(stream, 1);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
static inline int TelegramHeader_DecodeBit(struct Bitstream *stream, struct TelegramHeader *p)
{
    if (Bitstream_Normal(stream, 50))
    {
        {
            p->Q_UPDOWN = Bitstream_Read(stream, 1);
        }
        {
            p->M_VERSION = Bitstream_Read(stream, 7);
        }
        {
            p->Q_MEDIA = Bitstream_Read(stream, 1);
        }
        {
            p->N_PIG = Bitstream_Read(stream, 3);
        }
        {
            p->N_TOTAL = Bitstream_Read(stream, 3);
        }
        {
            p->M_DUP = Bitstream_Read(stream, 2);
        }
        {
            p->M_MCOUNT = Bitstream_Read(stream, 8);
        }
        {
            p->NID_C = Bitstream_Read(stream, 10);
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        {
            p->Q_LINK = Bitstream_Read(stream, 1);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

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


decompiled_code:
__int64 __fastcall TelegramHeader_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
if ( !(unsigned int)Bitstream_Normal(a2, 50LL) )
return 0xFFFFFFFFLL;
if ( !TelegramHeader_UpperBitsNotSet(a1) )
return 4294967294LL;
Bitstream_Write(a2, 1LL, *a1);
Bitstream_Write(a2, 7LL, a1[1]);
Bitstream_Write(a2, 1LL, a1[2]);
Bitstream_Write(a2, 3LL, a1[3]);
Bitstream_Write(a2, 3LL, a1[4]);
Bitstream_Write(a2, 2LL, a1[5]);
Bitstream_Write(a2, 8LL, a1[6]);
Bitstream_Write(a2, 10LL, a1[7]);
Bitstream_Write(a2, 14LL, a1[8]);
Bitstream_Write(a2, 1LL, a1[9]);
return 1LL;
}

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

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

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


decompiled_code:
__int64 __fastcall PacketHeader_EncodeBit(unsigned __int64 *a1, __int64 a2)
{
__int64 v2; // rdx

if ( !(unsigned int)Bitstream_Normal(a2, 8LL) )
return 0xFFFFFFFFLL;
if ( !PacketHeader_UpperBitsNotSet_isra_0(*a1) )
return 4294967294LL;
Bitstream_Write(a2, 8LL, v2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned __int64 *a1, __int64 a2)
{
__int64 v2; // rdx

if ( !(unsigned int)Bitstream_Normal(a2, 8LL) )
return 0xFFFFFFFFLL;
if ( !func14(*a1) )
return 4294967294LL;
Bitstream_Write(a2, 8LL, v2);
return 1LL;
}

original_code:
static inline
int PacketHeader_EncodeBit(const PacketHeader* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 8))
    {
        if (PacketHeader_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 8, p->NID_PACKET);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
static inline int PacketHeader_EncodeBit(struct PacketHeader *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 8))
    {
        if (PacketHeader_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 8, p->NID_PACKET);
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


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

canonical_decompiled_code:
__int64 __fastcall func17(_QWORD *a1)
{
func1(a1);
return PacketSequence_Clear(a1 + 10);
}

original_code:
void EurobaliseTelegram_Clear(EurobaliseTelegram* t)
{
    TelegramHeader_Init(&t->header);
    PacketSequence_Clear(&t->packets);
}

canonical_original_code:
void EurobaliseTelegram_Clear(struct EurobaliseTelegram *t)
{
    TelegramHeader_Init(&t->header);
    PacketSequence_Clear(&t->packets);
}


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

result = TelegramHeader_Equal(a1, a2);
if ( result )
result = (unsigned int)PacketSequence_Equal(a1 + 10, a2 + 10) != 0;
return result;
}

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

result = func3(a1, a2);
if ( result )
result = (unsigned int)PacketSequence_Equal(a1 + 10, a2 + 10) != 0;
return result;
}

original_code:
int EurobaliseTelegram_Equal(const EurobaliseTelegram* a, const EurobaliseTelegram* b)
{
    return TelegramHeader_Equal(&a->header, &b->header) &&
           PacketSequence_Equal(&a->packets, &b->packets);
}

canonical_original_code:
int EurobaliseTelegram_Equal(struct EurobaliseTelegram *a, struct EurobaliseTelegram *b)
{
    return TelegramHeader_Equal(&a->header, &b->header) &&
           PacketSequence_Equal(&a->packets, &b->packets);
}

variable_types:
b
struct EurobaliseTelegram *


decompiled_code:
__int64 __fastcall EurobaliseTelegram_DecodeBit(_QWORD *a1, __int64 a2)
{
unsigned int v2; // er12
unsigned int v3; // er15
unsigned int v4; // er14
__int64 v5; // rbp
unsigned int v6; // eax
__int64 v8; // rsi
__int64 v9; // [rsp+0h] [rbp-48h] BYREF
__int64 v10; // [rsp+8h] [rbp-40h]

if ( (unsigned int)TelegramHeader_DecodeBit(a2, a1) != 1 )
return 0;
v2 = *(_DWORD *)(a2 + 12);
v3 = 1;
v4 = v2 + 1023;
if ( v2 < 0xFFFFFC01 )
{
while ( 1 )
{
v9 = 0LL;
v10 = 0LL;
PacketHeader_DecodeBit_constprop_0_isra_0(&v9, a2);
if ( v9 == 255 )
break;
if ( *a1 == 1LL )
{
v5 = PacketFactory_TrackToTrain(v9, v10);
if ( !v5 )
return 0;
}
else
{
if ( *a1 )
_assert_fail(
"t->header.Q_UPDOWN == 0",
"..//Telegram/EurobaliseTelegram.c",
0x69u,
"EurobaliseTelegram_DecodeBit");
v5 = PacketFactory_TrainToTrack(v9, v10);
if ( !v5 )
return 0;
}
EurobaliseTelegram_Add((__int64)a1, v5);
Packet_DecodeBit(v5, a2);
v2 += Packet_Length(v5);
v6 = *(_DWORD *)(a2 + 12);
if ( v6 > v4 )
return v3;
if ( v6 != v2 )
return 0;
}
v8 = PacketFactory_BothWays(255LL, v10);
if ( !v8 )
_assert_fail("ptr", "..//Telegram/EurobaliseTelegram.c", 0x50u, "EurobaliseTelegram_DecodeBit");
EurobaliseTelegram_Add((__int64)a1, v8);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func19(_QWORD *a1, __int64 a2)
{
unsigned int v2; // er12
unsigned int v3; // er15
unsigned int v4; // er14
__int64 v5; // rbp
unsigned int v6; // eax
__int64 v8; // rsi
__int64 v9; // [rsp+0h] [rbp-48h] BYREF
__int64 v10; // [rsp+8h] [rbp-40h]

if ( (unsigned int)func10(a2, a1) != 1 )
return 0;
v2 = *(_DWORD *)(a2 + 12);
v3 = 1;
v4 = v2 + 1023;
if ( v2 < 0xFFFFFC01 )
{
while ( 1 )
{
v9 = 0LL;
v10 = 0LL;
func12(&v9, a2);
if ( v9 == 255 )
break;
if ( *a1 == 1LL )
{
v5 = PacketFactory_TrackToTrain(v9, v10);
if ( !v5 )
return 0;
}
else
{
if ( *a1 )
_assert_fail(
"t->header.Q_UPDOWN == 0",
"..//Telegram/EurobaliseTelegram.c",
0x69u,
"EurobaliseTelegram_DecodeBit");
v5 = PacketFactory_TrainToTrack(v9, v10);
if ( !v5 )
return 0;
}
func6((__int64)a1, v5);
Packet_DecodeBit(v5, a2);
v2 += Packet_Length(v5);
v6 = *(_DWORD *)(a2 + 12);
if ( v6 > v4 )
return v3;
if ( v6 != v2 )
return 0;
}
v8 = PacketFactory_BothWays(255LL, v10);
if ( !v8 )
_assert_fail("ptr", "..//Telegram/EurobaliseTelegram.c", 0x50u, "EurobaliseTelegram_DecodeBit");
func6((__int64)a1, v8);
}
return v3;
}

original_code:
int EurobaliseTelegram_DecodeBit(EurobaliseTelegram* t, Bitstream* stream)
{
    if (TelegramHeader_DecodeBit(stream, &t->header) != 1)
    {
        return 0;
    }
    const uint32_t old_pos = stream->bitpos;
    uint32_t current_pos = stream->bitpos;
    while (stream->bitpos <= 1023 + old_pos)
    {
        if (current_pos != stream->bitpos)
        {
            return 0;
        }
        PacketHeader packet_header = {0, 0};
        PacketHeader_DecodeBit(&packet_header, stream);
        PacketHeader* ptr = 0;
        if (packet_header.NID_PACKET == 255)
        {
            ptr = PacketFactory_BothWays(packet_header);
            ((ptr) ? (void) (0) : __assert_fail ("ptr", "..//Telegram/EurobaliseTelegram.c", 80, __extension__ __PRETTY_FUNCTION__));
            EurobaliseTelegram_Add(t, ptr);
            break;
        }
        if (t->header.Q_UPDOWN == 1)
        {
            ptr = PacketFactory_TrackToTrain(packet_header);
            if (ptr)
            {
                EurobaliseTelegram_Add(t, ptr);
            }
            else
            {
                return 0;
            }
        }
        else
        {
            ((t->header.Q_UPDOWN == 0) ? (void) (0) : __assert_fail ("t->header.Q_UPDOWN == 0", "..//Telegram/EurobaliseTelegram.c", 105, __extension__ __PRETTY_FUNCTION__));
            ptr = PacketFactory_TrainToTrack(packet_header);
            if (ptr)
            {
                EurobaliseTelegram_Add(t, ptr);
            }
            else
            {
                return 0;
            }
        }
        if (ptr)
        {
            Packet_DecodeBit(ptr, stream);
            current_pos += Packet_Length(ptr);
        }
    }
    return 1;
}

canonical_original_code:
int EurobaliseTelegram_DecodeBit(struct EurobaliseTelegram *t, struct Bitstream *stream)
{
    if (TelegramHeader_DecodeBit(stream, &t->header) != 1)
    {
        return 0;
    }
    unsigned int old_pos = stream->bitpos;
    unsigned int current_pos = stream->bitpos;
    while (stream->bitpos <= 1023 + old_pos)
    {
        if (current_pos != stream->bitpos)
        {
            return 0;
        }
        struct PacketHeader packet_header = {0, 0};
        PacketHeader_DecodeBit(&packet_header, stream);
        struct PacketHeader *ptr = 0;
        if (packet_header.NID_PACKET == 255)
        {
            ptr = PacketFactory_BothWays(packet_header);
            ((ptr) ? (void) (0) : __assert_fail ("ptr", "..//Telegram/EurobaliseTelegram.c", 80, __extension__ __PRETTY_FUNCTION__));
            EurobaliseTelegram_Add(t, ptr);
            break;
        }
        if (t->header.Q_UPDOWN == 1)
        {
            ptr = PacketFactory_TrackToTrain(packet_header);
            if (ptr)
            {
                EurobaliseTelegram_Add(t, ptr);
            }
            else
            {
                return 0;
            }
        }
        else
        {
            ((t->header.Q_UPDOWN == 0) ? (void) (0) : __assert_fail ("t->header.Q_UPDOWN == 0", "..//Telegram/EurobaliseTelegram.c", 105, __extension__ __PRETTY_FUNCTION__));
            ptr = PacketFactory_TrainToTrack(packet_header);
            if (ptr)
            {
                EurobaliseTelegram_Add(t, ptr);
            }
            else
            {
                return 0;
            }
        }
        if (ptr)
        {
            Packet_DecodeBit(ptr, stream);
            current_pos += Packet_Length(ptr);
        }
    }
    return 1;
}

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


decompiled_code:
__int64 __fastcall EurobaliseTelegram_EncodeBit(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
int v4; // er14
unsigned int v5; // ebx
unsigned int v6; // er14
unsigned __int64 *v7; // rax
__int64 v8; // rax

if ( (unsigned int)TelegramHeader_EncodeBit((unsigned __int64 *)a1, a2) != 1 )
return 0;
v2 = 1;
v4 = *(_DWORD *)(a2 + 12);
if ( *(_QWORD *)PacketSequence_Back(a1 + 80) != 255LL )
_assert_fail(
"PacketSequence_Back(&t->packets)->NID_PACKET == 255",
"..//Telegram/EurobaliseTelegram.c",
0x8Cu,
"EurobaliseTelegram_EncodeBit");
v5 = 0;
v6 = v4 + 1023;
while ( (unsigned int)EurobaliseTelegram_Size_isra_0(*(_DWORD *)(a1 + 480)) > v5 )
{
if ( *(_DWORD *)(a2 + 12) > v6 )
return 0;
v7 = (unsigned __int64 *)EurobaliseTelegram_Get(a1, v5);
if ( (unsigned int)PacketHeader_EncodeBit(v7, a2) != 1 )
return 0;
v8 = EurobaliseTelegram_Get(a1, v5);
if ( (unsigned int)Packet_EncodeBit(v8, a2) != 1 )
return 0;
++v5;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
int v4; // er14
unsigned int v5; // ebx
unsigned int v6; // er14
unsigned __int64 *v7; // rax
__int64 v8; // rax

if ( (unsigned int)func11((unsigned __int64 *)a1, a2) != 1 )
return 0;
v2 = 1;
v4 = *(_DWORD *)(a2 + 12);
if ( *(_QWORD *)func9(a1 + 80) != 255LL )
_assert_fail(
"PacketSequence_Back(&t->packets)->NID_PACKET == 255",
"..//Telegram/EurobaliseTelegram.c",
0x8Cu,
"EurobaliseTelegram_EncodeBit");
v5 = 0;
v6 = v4 + 1023;
while ( (unsigned int)func13(*(_DWORD *)(a1 + 480)) > v5 )
{
if ( *(_DWORD *)(a2 + 12) > v6 )
return 0;
v7 = (unsigned __int64 *)func8(a1, v5);
if ( (unsigned int)func15(v7, a2) != 1 )
return 0;
v8 = func8(a1, v5);
if ( (unsigned int)Packet_EncodeBit(v8, a2) != 1 )
return 0;
++v5;
}
return v2;
}

original_code:
int EurobaliseTelegram_EncodeBit(const EurobaliseTelegram* t, Bitstream* stream)
{
    if (TelegramHeader_EncodeBit(&t->header, stream) != 1)
    {
        return 0;
    }
    uint32_t old_pos = stream->bitpos;
    ((PacketSequence_Back(&t->packets)->NID_PACKET == 255) ? (void) (0) : __assert_fail ("PacketSequence_Back(&t->packets)->NID_PACKET == 255", "..//Telegram/EurobaliseTelegram.c", 140, __extension__ __PRETTY_FUNCTION__));
    for (uint32_t i = 0; i < EurobaliseTelegram_Size(t); ++i)
    {
        if (stream->bitpos > 1023 + old_pos)
        {
            return 0;
        }
        if (PacketHeader_EncodeBit(EurobaliseTelegram_Get(t, i), stream) != 1)
        {
            return 0;
        }
        if (Packet_EncodeBit(EurobaliseTelegram_Get(t, i), stream) != 1)
        {
            return 0;
        }
    }
    return 1;
}

canonical_original_code:
int EurobaliseTelegram_EncodeBit(struct EurobaliseTelegram *t, struct Bitstream *stream)
{
    if (TelegramHeader_EncodeBit(&t->header, stream) != 1)
    {
        return 0;
    }
    unsigned int old_pos = stream->bitpos;
    ((PacketSequence_Back(&t->packets)->NID_PACKET == 255) ? (void) (0) : __assert_fail ("PacketSequence_Back(&t->packets)->NID_PACKET == 255", "..//Telegram/EurobaliseTelegram.c", 140, __extension__ __PRETTY_FUNCTION__));
    for (unsigned int i = 0; i < EurobaliseTelegram_Size(t); ++i)
    {
        if (stream->bitpos > 1023 + old_pos)
        {
            return 0;
        }
        if (PacketHeader_EncodeBit(EurobaliseTelegram_Get(t, i), stream) != 1)
        {
            return 0;
        }
        if (Packet_EncodeBit(EurobaliseTelegram_Get(t, i), stream) != 1)
        {
            return 0;
        }
    }
    return 1;
}


decompiled_code:
__int64 __fastcall EurobaliseTelegram_EncodeInt(__int64 a1)
{
return PacketSequence_EncodeInt(a1 + 80);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1)
{
return PacketSequence_EncodeInt(a1 + 80);
}

original_code:
int EurobaliseTelegram_EncodeInt(const EurobaliseTelegram* t, CompressedPackets* packetStruct)
{
    return PacketSequence_EncodeInt(&(t->packets), packetStruct);
}

canonical_original_code:
int EurobaliseTelegram_EncodeInt(struct EurobaliseTelegram *t, struct CompressedPackets_T_Common_Types_Pkg *packetStruct)
{
    return PacketSequence_EncodeInt(&(t->packets), packetStruct);
}

variable_types: struct CompressedPackets_T_Common_Types_Pkg { struct MetadataElement_T_Common_Types_Pkg { int nid_packet; int q_dir; unsigned char valid; int startAddress; int endAddress; } PacketHeaders[30]; int PacketData[500]; } *

user_defined_types: struct CompressedPackets_T_Common_Types_Pkg { struct MetadataElement_T_Common_Types_Pkg PacketHeaders[30]; int PacketData[500]; }


decompiled_code:
__int64 __fastcall EurobaliseTelegram_DecodeInt(_QWORD *a1, __int64 a2)
{
return PacketSequence_DecodeInt(a1 + 10, *a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(_QWORD *a1, __int64 a2)
{
return PacketSequence_DecodeInt(a1 + 10, *a1, a2);
}

original_code:
int EurobaliseTelegram_DecodeInt(EurobaliseTelegram* t, const CompressedPackets* packetStruct)
{
    return PacketSequence_DecodeInt(&(t->packets), t->header.Q_UPDOWN, packetStruct);;
}

canonical_original_code:
int EurobaliseTelegram_DecodeInt(struct EurobaliseTelegram *t, struct CompressedPackets_T_Common_Types_Pkg *packetStruct)
{
    return PacketSequence_DecodeInt(&(t->packets), t->header.Q_UPDOWN, packetStruct);;
}


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

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

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

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

variable_types:
value
unsigned long

variable_types:
length
unsigned int

variable_types:
MaxValue
unsigned long


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

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

original_code:
int Linking_UpperBitsNotSet(const Linking* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->D_LINK, 15);
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY, 1) ;
    if (p->Q_NEWCOUNTRY == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_C, 10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG, 14);
    status = status && UpperBitsNotSet64(p->Q_LINKORIENTATION, 1) ;
    status = status && UpperBitsNotSet64(p->Q_LINKREACTION, 2) ;
    status = status && UpperBitsNotSet64(p->Q_LOCACC, 6) ;
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && Linking_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int Linking_UpperBitsNotSet(struct Linking *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->D_LINK, 15);
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY, 1) ;
    if (p->Q_NEWCOUNTRY == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_C, 10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG, 14);
    status = status && UpperBitsNotSet64(p->Q_LINKORIENTATION, 1) ;
    status = status && UpperBitsNotSet64(p->Q_LINKREACTION, 2) ;
    status = status && UpperBitsNotSet64(p->Q_LOCACC, 6) ;
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && Linking_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types: struct Linking { 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_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; unsigned long N_ITER_1; struct Linking_1 { unsigned long D_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; } sub_1[31]; } *

variable_types: status int

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


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

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

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

if ( !(unsigned int)Bitstream_Normal(a2, 61LL) )
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, 15LL, a1[5]);
Bitstream_Write(a2, 1LL, a1[6]);
if ( a1[6] == 1 )
Bitstream_Write(a2, 10LL, a1[7]);
v2 = 0;
Bitstream_Write(a2, 14LL, a1[8]);
Bitstream_Write(a2, 1LL, a1[9]);
Bitstream_Write(a2, 2LL, a1[10]);
Bitstream_Write(a2, 6LL, a1[11]);
Bitstream_Write(a2, 5LL, a1[12]);
v3 = 0LL;
if ( a1[12] )
{
do
{
Linking_1_EncodeBit(&a1[7 * v3 + 13], a2);
v3 = ++v2;
}
while ( v2 < a1[12] );
}
return 1LL;
}

original_code:
int Linking_EncodeBit(const Linking* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 61))
    {
        if (Linking_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 15, p->D_LINK);
            Bitstream_Write(stream, 1, p->Q_NEWCOUNTRY);
            if (p->Q_NEWCOUNTRY == 1)
            {
                Bitstream_Write(stream, 10, p->NID_C);
            }
            Bitstream_Write(stream, 14, p->NID_BG);
            Bitstream_Write(stream, 1, p->Q_LINKORIENTATION);
            Bitstream_Write(stream, 2, p->Q_LINKREACTION);
            Bitstream_Write(stream, 6, p->Q_LOCACC);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (uint32_t i = 0; i < p->N_ITER_1; ++i)
            {
                Linking_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int Linking_EncodeBit(struct Linking *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 61))
    {
        if (Linking_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 2, p->Q_SCALE);
            Bitstream_Write(stream, 15, p->D_LINK);
            Bitstream_Write(stream, 1, p->Q_NEWCOUNTRY);
            if (p->Q_NEWCOUNTRY == 1)
            {
                Bitstream_Write(stream, 10, p->NID_C);
            }
            Bitstream_Write(stream, 14, p->NID_BG);
            Bitstream_Write(stream, 1, p->Q_LINKORIENTATION);
            Bitstream_Write(stream, 2, p->Q_LINKREACTION);
            Bitstream_Write(stream, 6, p->Q_LOCACC);
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (unsigned int i = 0; i < p->N_ITER_1; ++i)
            {
                Linking_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

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


decompiled_code:
__int64 __fastcall Linking_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, 61LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 15LL);
v3 = Bitstream_Read(a2, 1LL);
a1[6] = v3;
if ( v3 == 1 )
a1[7] = Bitstream_Read(a2, 10LL);
v4 = 0;
a1[8] = Bitstream_Read(a2, 14LL);
a1[9] = Bitstream_Read(a2, 1LL);
a1[10] = Bitstream_Read(a2, 2LL);
a1[11] = Bitstream_Read(a2, 6LL);
v5 = Bitstream_Read(a2, 5LL);
a1[12] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
Linking_1_DecodeBit(&a1[7 * v6 + 13], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[12] );
}
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, 61LL);
if ( (_DWORD)result )
{
a1[2] = Bitstream_Read(a2, 2LL);
a1[3] = Bitstream_Read(a2, 13LL);
a1[4] = Bitstream_Read(a2, 2LL);
a1[5] = Bitstream_Read(a2, 15LL);
v3 = Bitstream_Read(a2, 1LL);
a1[6] = v3;
if ( v3 == 1 )
a1[7] = Bitstream_Read(a2, 10LL);
v4 = 0;
a1[8] = Bitstream_Read(a2, 14LL);
a1[9] = Bitstream_Read(a2, 1LL);
a1[10] = Bitstream_Read(a2, 2LL);
a1[11] = Bitstream_Read(a2, 6LL);
v5 = Bitstream_Read(a2, 5LL);
a1[12] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
Linking_1_DecodeBit(&a1[7 * v6 + 13], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[12] );
}
result = 1LL;
}
return result;
}

original_code:
int Linking_DecodeBit(Linking* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 61))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->D_LINK = Bitstream_Read(stream, 15);
        }
        {
            p->Q_NEWCOUNTRY = Bitstream_Read(stream, 1);
        }
        if (p->Q_NEWCOUNTRY == 1)
        {
            {
                p->NID_C = Bitstream_Read(stream, 10);
            }
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        {
            p->Q_LINKORIENTATION = Bitstream_Read(stream, 1);
        }
        {
            p->Q_LINKREACTION = Bitstream_Read(stream, 2);
        }
        {
            p->Q_LOCACC = Bitstream_Read(stream, 6);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_1; ++i)
        {
            Linking_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int Linking_DecodeBit(struct Linking *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 61))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->Q_SCALE = Bitstream_Read(stream, 2);
        }
        {
            p->D_LINK = Bitstream_Read(stream, 15);
        }
        {
            p->Q_NEWCOUNTRY = Bitstream_Read(stream, 1);
        }
        if (p->Q_NEWCOUNTRY == 1)
        {
            {
                p->NID_C = Bitstream_Read(stream, 10);
            }
        }
        {
            p->NID_BG = Bitstream_Read(stream, 14);
        }
        {
            p->Q_LINKORIENTATION = Bitstream_Read(stream, 1);
        }
        {
            p->Q_LINKREACTION = Bitstream_Read(stream, 2);
        }
        {
            p->Q_LOCACC = Bitstream_Read(stream, 6);
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_1; ++i)
        {
            Linking_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


original_code:
int Linking_EncodeInt(const Linking* p, Metadata* data, kcg_int* stream)
{
    data->nid_packet = 5;
    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->N_ITER_1 + 1;
    stream[startAddress++] = p->D_LINK;
    stream[startAddress++] = p->Q_NEWCOUNTRY;
    stream[startAddress++] = p->NID_C;
    stream[startAddress++] = p->NID_BG;
    stream[startAddress++] = p->Q_LINKORIENTATION;
    stream[startAddress++] = p->Q_LINKREACTION;
    stream[startAddress++] = p->Q_LOCACC;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        Linking_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    data->endAddress = startAddress-1;
    return 1;
}

canonical_original_code:
int Linking_EncodeInt(struct Linking *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    data->nid_packet = 5;
    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->N_ITER_1 + 1;
    stream[startAddress++] = p->D_LINK;
    stream[startAddress++] = p->Q_NEWCOUNTRY;
    stream[startAddress++] = p->NID_C;
    stream[startAddress++] = p->NID_BG;
    stream[startAddress++] = p->Q_LINKORIENTATION;
    stream[startAddress++] = p->Q_LINKREACTION;
    stream[startAddress++] = p->Q_LOCACC;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        Linking_1_EncodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    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 Linking_DecodeInt(Linking* p, const Metadata* data, const kcg_int* stream)
{
    if(data->nid_packet != 5)
    {
         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->N_ITER_1 = stream[startAddress++] - 1;
    p->D_LINK = stream[startAddress++];
    p->Q_NEWCOUNTRY = stream[startAddress++];
    p->NID_C = stream[startAddress++];
    p->NID_BG = stream[startAddress++];
    p->Q_LINKORIENTATION = stream[startAddress++];
    p->Q_LINKREACTION = stream[startAddress++];
    p->Q_LOCACC = stream[startAddress++];
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        Linking_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}

canonical_original_code:
int Linking_DecodeInt(struct Linking *p, struct MetadataElement_T_Common_Types_Pkg *data, int *stream)
{
    if(data->nid_packet != 5)
    {
         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->N_ITER_1 = stream[startAddress++] - 1;
    p->D_LINK = stream[startAddress++];
    p->Q_NEWCOUNTRY = stream[startAddress++];
    p->NID_C = stream[startAddress++];
    p->NID_BG = stream[startAddress++];
    p->Q_LINKORIENTATION = stream[startAddress++];
    p->Q_LINKREACTION = stream[startAddress++];
    p->Q_LOCACC = stream[startAddress++];
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        Linking_1_DecodeInt(&(p->sub_1[i]), &startAddress, stream);
    }
    if(startAddress-1 != data->endAddress)
    {
         return 0;
    }
    return 1;
}


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

if ( LinkingMemoryFreeList == -1 )
{
if ( (unsigned __int64)LinkingMemoryTop > 7 )
return 0LL;
v3 = 230 * LinkingMemoryTop++;
v0 = &LinkingMemory[v3];
}
else
{
v0 = &LinkingMemory[230 * LinkingMemoryFreeList];
LinkingMemoryFreeList = *v0;
}
Linking_Init(v0);
return v1;
}

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

if ( LinkingMemoryFreeList == -1 )
{
if ( (unsigned __int64)LinkingMemoryTop > 7 )
return 0LL;
v3 = 230 * LinkingMemoryTop++;
v0 = &LinkingMemory[v3];
}
else
{
v0 = &LinkingMemory[230 * LinkingMemoryFreeList];
LinkingMemoryFreeList = *v0;
}
func2(v0);
return v1;
}

original_code:
Linking* Linking_New(void)
{
    Linking* ptr;
    if (LinkingMemoryFreeList != (-1))
    {
        ptr = &LinkingMemory[LinkingMemoryFreeList];
        LinkingMemoryFreeList = LinkingMemory[LinkingMemoryFreeList].header.NID_PACKET;
    }
    else if (LinkingMemoryTop < 8)
    {
        ptr = &LinkingMemory[LinkingMemoryTop];
        LinkingMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    Linking_Init(ptr);
    return ptr;
}

canonical_original_code:
struct Linking *Linking_New()
{
    struct Linking *ptr;
    if (LinkingMemoryFreeList != (-1))
    {
        ptr = &LinkingMemory[LinkingMemoryFreeList];
        LinkingMemoryFreeList = LinkingMemory[LinkingMemoryFreeList].header.NID_PACKET;
    }
    else if (LinkingMemoryTop < 8)
    {
        ptr = &LinkingMemory[LinkingMemoryTop];
        LinkingMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    Linking_Init(ptr);
    return ptr;
}

return_type: struct Linking { 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_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; unsigned long N_ITER_1; struct Linking_1 { unsigned long D_LINK; unsigned long Q_NEWCOUNTRY; unsigned long NID_C; unsigned long NID_BG; unsigned long Q_LINKORIENTATION; unsigned long Q_LINKREACTION; unsigned long Q_LOCACC; } sub_1[31]; } *


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

*(_QWORD *)a1 = LinkingMemoryFreeList;
result = 0x2A4BAFDC61F2A4BBLL;
LinkingMemoryFreeList = 0x2A4BAFDC61F2A4BBLL * ((a1 - (char *)LinkingMemory) >> 4);
return result;
}

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

*(_QWORD *)a1 = LinkingMemoryFreeList;
result = 0x2A4BAFDC61F2A4BBLL;
LinkingMemoryFreeList = 0x2A4BAFDC61F2A4BBLL * ((a1 - (char *)LinkingMemory) >> 4);
return result;
}

original_code:
void Linking_Delete(Linking* ptr)
{
    ptr->header.NID_PACKET = LinkingMemoryFreeList;
    LinkingMemoryFreeList = ptr - LinkingMemory;
}

canonical_original_code:
void Linking_Delete(struct Linking *ptr)
{
    ptr->header.NID_PACKET = LinkingMemoryFreeList;
    LinkingMemoryFreeList = ptr - LinkingMemory;
}


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

if ( !UpperBitsNotSet64(a1[2], 2)
|| !UpperBitsNotSet64(a1[3], 13)
|| !UpperBitsNotSet64(a1[4], 3)
|| v1 == 1 && !UpperBitsNotSet64(a1[5], 8) )
{
v3 = a1[6];
if ( !v3 )
return 0LL;
LODWORD(v4) = 0;
do
{
LABEL_14:
if ( v3 <= (unsigned int)(v4 + 1) )
break;
v4 = (unsigned int)(v4 + 2);
}
while ( v4 < v3 );
return 0LL;
}
v2 = UpperBitsNotSet64(a1[6], 5);
if ( v3 )
{
LODWORD(v4) = 0;
if ( v2 )
{
v5 = 0LL;
while ( 1 )
{
v6 = ConditionalLevelTransitionOrder_1_UpperBitsNotSet(&a1[2 * v5 + 7]);
v5 = (unsigned int)(v4 + 1);
LODWORD(v4) = v4 + 1;
if ( !v6 )
break;
if ( a1[6] <= v5 )
return 1LL;
}
v3 = a1[6];
if ( v3 > v5 )
goto LABEL_14;
return 0LL;
}
goto LABEL_14;
}
return v2;
}

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

if ( !func0(a1[2], 2)
|| !func0(a1[3], 13)
|| !func0(a1[4], 3)
|| v1 == 1 && !func0(a1[5], 8) )
{
v3 = a1[6];
if ( !v3 )
return 0LL;
LODWORD(v4) = 0;
do
{
LABEL_14:
if ( v3 <= (unsigned int)(v4 + 1) )
break;
v4 = (unsigned int)(v4 + 2);
}
while ( v4 < v3 );
return 0LL;
}
v2 = func0(a1[6], 5);
if ( v3 )
{
LODWORD(v4) = 0;
if ( v2 )
{
v5 = 0LL;
while ( 1 )
{
v6 = ConditionalLevelTransitionOrder_1_UpperBitsNotSet(&a1[2 * v5 + 7]);
v5 = (unsigned int)(v4 + 1);
LODWORD(v4) = v4 + 1;
if ( !v6 )
break;
if ( a1[6] <= v5 )
return 1LL;
}
v3 = a1[6];
if ( v3 > v5 )
goto LABEL_14;
return 0LL;
}
goto LABEL_14;
}
return v2;
}

original_code:
int ConditionalLevelTransitionOrder_UpperBitsNotSet(const ConditionalLevelTransitionOrder* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->M_LEVELTR, 3) ;
    if (p->M_LEVELTR == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM, 8) ;
    }
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && ConditionalLevelTransitionOrder_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ConditionalLevelTransitionOrder_UpperBitsNotSet(struct ConditionalLevelTransitionOrder *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->Q_DIR, 2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->M_LEVELTR, 3) ;
    if (p->M_LEVELTR == 1)
    {
        status = status && UpperBitsNotSet64(p->NID_STM, 8) ;
    }
    status = status && UpperBitsNotSet64(p->N_ITER_1, 5) ;
    for (unsigned int i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && ConditionalLevelTransitionOrder_1_UpperBitsNotSet(&(p->sub_1[i]));
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

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

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


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

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

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 v3; // 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, 3LL, a1[4]);
if ( a1[4] == 1 )
Bitstream_Write(a2, 8LL, a1[5]);
v2 = 0;
Bitstream_Write(a2, 5LL, a1[6]);
v3 = 0LL;
if ( a1[6] )
{
do
{
ConditionalLevelTransitionOrder_1_EncodeBit(&a1[2 * v3 + 7], a2);
v3 = ++v2;
}
while ( v2 < a1[6] );
}
return 1LL;
}

original_code:
int ConditionalLevelTransitionOrder_EncodeBit(const ConditionalLevelTransitionOrder* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        if (ConditionalLevelTransitionOrder_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 3, p->M_LEVELTR);
            if (p->M_LEVELTR == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM);
            }
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (uint32_t i = 0; i < p->N_ITER_1; ++i)
            {
                ConditionalLevelTransitionOrder_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

canonical_original_code:
int ConditionalLevelTransitionOrder_EncodeBit(struct ConditionalLevelTransitionOrder *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        if (ConditionalLevelTransitionOrder_UpperBitsNotSet(p))
        {
            Bitstream_Write(stream, 2, p->Q_DIR);
            Bitstream_Write(stream, 13, p->L_PACKET);
            Bitstream_Write(stream, 3, p->M_LEVELTR);
            if (p->M_LEVELTR == 1)
            {
                Bitstream_Write(stream, 8, p->NID_STM);
            }
            Bitstream_Write(stream, 5, p->N_ITER_1);
            for (unsigned int i = 0; i < p->N_ITER_1; ++i)
            {
                ConditionalLevelTransitionOrder_1_EncodeBit(&(p->sub_1[i]), stream);
            }
            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}

user_defined_types: struct ConditionalLevelTransitionOrder_1 { unsigned long M_LEVELTR; unsigned long NID_STM; }


decompiled_code:
__int64 __fastcall ConditionalLevelTransitionOrder_DecodeBit(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebp
__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);
v3 = Bitstream_Read(a2, 3LL);
a1[4] = v3;
if ( v3 == 1 )
a1[5] = Bitstream_Read(a2, 8LL);
v4 = 0;
v5 = Bitstream_Read(a2, 5LL);
a1[6] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
ConditionalLevelTransitionOrder_1_DecodeBit(&a1[2 * v6 + 7], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[6] );
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
unsigned int v4; // ebp
__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);
v3 = Bitstream_Read(a2, 3LL);
a1[4] = v3;
if ( v3 == 1 )
a1[5] = Bitstream_Read(a2, 8LL);
v4 = 0;
v5 = Bitstream_Read(a2, 5LL);
a1[6] = v5;
v6 = 0LL;
if ( v5 )
{
do
{
ConditionalLevelTransitionOrder_1_DecodeBit(&a1[2 * v6 + 7], a2);
v6 = ++v4;
}
while ( (unsigned __int64)v4 < a1[6] );
}
result = 1LL;
}
return result;
}

original_code:
int ConditionalLevelTransitionOrder_DecodeBit(ConditionalLevelTransitionOrder* p, Bitstream* stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->M_LEVELTR = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTR == 1)
        {
            {
                p->NID_STM = Bitstream_Read(stream, 8);
            }
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (uint32_t i = 0; i < p->N_ITER_1; ++i)
        {
            ConditionalLevelTransitionOrder_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int ConditionalLevelTransitionOrder_DecodeBit(struct ConditionalLevelTransitionOrder *p, struct Bitstream *stream)
{
    if (Bitstream_Normal(stream, 23))
    {
        {
            p->Q_DIR = Bitstream_Read(stream, 2);
        }
        {
            p->L_PACKET = Bitstream_Read(stream, 13);
        }
        {
            p->M_LEVELTR = Bitstream_Read(stream, 3);
        }
        if (p->M_LEVELTR == 1)
        {
            {
                p->NID_STM = Bitstream_Read(stream, 8);
            }
        }
    {
            p->N_ITER_1 = Bitstream_Read(stream, 5);
        }
        for (unsigned int i = 0; i < p->N_ITER_1; ++i)
        {
            ConditionalLevelTransitionOrder_1_DecodeBit(&(p->sub_1[i]), stream);
        }
        return 1;
    }
    else
    {
        return 0;
    }
}


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

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


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

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


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

if ( ConditionalLevelTransitionOrderMemoryFreeList == -1 )
{
if ( (unsigned __int64)ConditionalLevelTransitionOrderMemoryTop > 7 )
return 0LL;
v3 = 69 * ConditionalLevelTransitionOrderMemoryTop++;
v0 = &ConditionalLevelTransitionOrderMemory[v3];
}
else
{
v0 = &ConditionalLevelTransitionOrderMemory[69 * ConditionalLevelTransitionOrderMemoryFreeList];
ConditionalLevelTransitionOrderMemoryFreeList = *v0;
}
ConditionalLevelTransitionOrder_Init(v0);
return v1;
}

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

if ( ConditionalLevelTransitionOrderMemoryFreeList == -1 )
{
if ( (unsigned __int64)ConditionalLevelTransitionOrderMemoryTop > 7 )
return 0LL;
v3 = 69 * ConditionalLevelTransitionOrderMemoryTop++;
v0 = &ConditionalLevelTransitionOrderMemory[v3];
}
else
{
v0 = &ConditionalLevelTransitionOrderMemory[69 * ConditionalLevelTransitionOrderMemoryFreeList];
ConditionalLevelTransitionOrderMemoryFreeList = *v0;
}
func2(v0);
return v1;
}

original_code:
ConditionalLevelTransitionOrder* ConditionalLevelTransitionOrder_New(void)
{
    ConditionalLevelTransitionOrder* ptr;
    if (ConditionalLevelTransitionOrderMemoryFreeList != (-1))
    {
        ptr = &ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryFreeList];
        ConditionalLevelTransitionOrderMemoryFreeList = ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryFreeList].header.NID_PACKET;
    }
    else if (ConditionalLevelTransitionOrderMemoryTop < 8)
    {
        ptr = &ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryTop];
        ConditionalLevelTransitionOrderMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    ConditionalLevelTransitionOrder_Init(ptr);
    return ptr;
}

canonical_original_code:
struct ConditionalLevelTransitionOrder *ConditionalLevelTransitionOrder_New()
{
    struct ConditionalLevelTransitionOrder *ptr;
    if (ConditionalLevelTransitionOrderMemoryFreeList != (-1))
    {
        ptr = &ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryFreeList];
        ConditionalLevelTransitionOrderMemoryFreeList = ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryFreeList].header.NID_PACKET;
    }
    else if (ConditionalLevelTransitionOrderMemoryTop < 8)
    {
        ptr = &ConditionalLevelTransitionOrderMemory[ConditionalLevelTransitionOrderMemoryTop];
        ConditionalLevelTransitionOrderMemoryTop += 1;
    }
    else
    {
        return 0;
    }
    ConditionalLevelTransitionOrder_Init(ptr);
    return ptr;
}

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


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

*a1 = ConditionalLevelTransitionOrderMemoryFreeList;
result = 0xF128CFC4A33F128DLL;
ConditionalLevelTransitionOrderMemoryFreeList = 0xF128CFC4A33F128DLL * (a1 - ConditionalLevelTransitionOrderMemory);
return result;
}

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

*a1 = ConditionalLevelTransitionOrderMemoryFreeList;
result = 0xF128CFC4A33F128DLL;
ConditionalLevelTransitionOrderMemoryFreeList = 0xF128CFC4A33F128DLL * (a1 - ConditionalLevelTransitionOrderMemory);
return result;
}

original_code:
void ConditionalLevelTransitionOrder_Delete(ConditionalLevelTransitionOrder* ptr)
{
    ptr->header.NID_PACKET = ConditionalLevelTransitionOrderMemoryFreeList;
    ConditionalLevelTransitionOrderMemoryFreeList = ptr - ConditionalLevelTransitionOrderMemory;
}

canonical_original_code:
void ConditionalLevelTransitionOrder_Delete(struct ConditionalLevelTransitionOrder *ptr)
{
    ptr->header.NID_PACKET = ConditionalLevelTransitionOrderMemoryFreeList;
    ConditionalLevelTransitionOrderMemoryFreeList = ptr - ConditionalLevelTransitionOrderMemory;
}


decompiled_code:
_BOOL8 __fastcall PositionReportBasedOnTwoBaliseGroups_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
__int64 v9; // rdx
__int64 v10; // rdx
unsigned __int64 v11; // rdi
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
unsigned __int64 v16; // rdi
__int64 v17; // rdx

result = UpperBitsNotSet64(*(_QWORD *)(a1 + 16), 13);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v2 + 24), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v3 + 32), 24);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v4 + 40), 24);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v5 + 48), 15);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v6 + 56), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v7 + 64), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v8 + 72), 15);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v9 + 80), 15);
if ( result )
{
v11 = *(_QWORD *)(v10 + 88);
result = UpperBitsNotSet64(v11, 2);
if ( result && (v11 - 1 > 1 || (result = UpperBitsNotSet64(*(_QWORD *)(v12 + 96), 15))) )
{
result = UpperBitsNotSet64(*(_QWORD *)(v12 + 104), 7);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v13 + 112), 2);
if ( result )
{
result = UpperBitsNotSet64(*(_QWORD *)(v14 + 120), 4);
if ( result )
{
v16 = *(_QWORD *)(v15 + 128);
result = UpperBitsNotSet64(v16, 3);
if ( result )
{
result = 1LL;
if ( v16 == 1 )
result = UpperBitsNotSet64(*(_QWORD *)(v17 + 136), 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
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
unsigned __int64 v11; // rdi
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
unsigned __int64 v16; // rdi
__int64 v17; // rdx

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

original_code:
int PositionReportBasedOnTwoBaliseGroups_UpperBitsNotSet(const PositionReportBasedOnTwoBaliseGroups* p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->NID_LRBG, 24);
    status = status && UpperBitsNotSet64(p->NID_PRVLRBG, 24);
    status = status && UpperBitsNotSet64(p->D_LRBG, 15);
    status = status && UpperBitsNotSet64(p->Q_DIRLRBG, 2) ;
    status = status && UpperBitsNotSet64(p->Q_DLRBG, 2) ;
    status = status && UpperBitsNotSet64(p->L_DOUBTOVER, 15);
    status = status && UpperBitsNotSet64(p->L_DOUBTUNDER, 15);
    status = status && UpperBitsNotSet64(p->Q_LENGTH, 2) ;
    if ((p-> Q_LENGTH == 1 ) || (p-> Q_LENGTH == 2))
    {
        status = status && UpperBitsNotSet64(p->L_TRAININT, 15);
    }
    status = status && UpperBitsNotSet64(p->V_TRAIN, 7) ;
    status = status && UpperBitsNotSet64(p->Q_DIRTRAIN, 2) ;
    status = status && UpperBitsNotSet64(p->M_MODE, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVEL, 3) ;
    if (p-> M_LEVEL == 1 )
    {
        status = status && UpperBitsNotSet64(p->NID_STM, 8) ;
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

canonical_original_code:
int PositionReportBasedOnTwoBaliseGroups_UpperBitsNotSet(struct PositionReportBasedOnTwoBaliseGroups *p)
{
    int status = 1;
    status = status && UpperBitsNotSet64(p->L_PACKET, 13);
    status = status && UpperBitsNotSet64(p->Q_SCALE, 2) ;
    status = status && UpperBitsNotSet64(p->NID_LRBG, 24);
    status = status && UpperBitsNotSet64(p->NID_PRVLRBG, 24);
    status = status && UpperBitsNotSet64(p->D_LRBG, 15);
    status = status && UpperBitsNotSet64(p->Q_DIRLRBG, 2) ;
    status = status && UpperBitsNotSet64(p->Q_DLRBG, 2) ;
    status = status && UpperBitsNotSet64(p->L_DOUBTOVER, 15);
    status = status && UpperBitsNotSet64(p->L_DOUBTUNDER, 15);
    status = status && UpperBitsNotSet64(p->Q_LENGTH, 2) ;
    if ((p-> Q_LENGTH == 1 ) || (p-> Q_LENGTH == 2))
    {
        status = status && UpperBitsNotSet64(p->L_TRAININT, 15);
    }
    status = status && UpperBitsNotSet64(p->V_TRAIN, 7) ;
    status = status && UpperBitsNotSet64(p->Q_DIRTRAIN, 2) ;
    status = status && UpperBitsNotSet64(p->M_MODE, 4) ;
    status = status && UpperBitsNotSet64(p->M_LEVEL, 3) ;
    if (p-> M_LEVEL == 1 )
    {
        status = status && UpperBitsNotSet64(p->NID_STM, 8) ;
    }
    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

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

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