int Staff_Responsible_distance_Information_from_loop_Core_1_Encode_Bit(Bitstream* stream, const Staff_Responsible_distance_Information_from_loop_Core_1* p)
{
    if (Bitstream_Normal(stream, STAFF_RESPONSIBLE_DISTANCE_INFORMATION_FROM_LOOP_CORE_1_CORE_BITSIZE))
    {
        if (Staff_Responsible_distance_Information_from_loop_Core_1_UpperBitsNotSet(p))
        {
            //@ ghost const uint32_t pos = stream->bitpos;

            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, 15, p->D_SR);


            //@ assert Q_NEWCOUNTRY:      EqualBits(stream, pos,       pos + 1,   p->Q_NEWCOUNTRY);

            return 1;
        }
        else
        {
            return -2;
        }
    }
    else
    {
        return -1;
    }
}
int Staff_Responsible_distance_Information_from_loop_UpperBitsNotSet(const Staff_Responsible_distance_Information_from_loop_Core* p)
{
    bool status = true;

    status = status && UpperBitsNotSet64(p->Q_DIR,             2) ;
    status = status && UpperBitsNotSet64(p->L_PACKET,          13);
    status = status && UpperBitsNotSet64(p->Q_SCALE,           2) ;
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY_0,    1) ;
    if (p->Q_NEWCOUNTRY_0 == 1)
    {
    status = status && UpperBitsNotSet64(p->NID_C_0,           10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG_0,          14);
    status = status && UpperBitsNotSet64(p->Q_NEWCOUNTRY_1,    1) ;
    if (p->Q_NEWCOUNTRY_1 == 1)
    {
    status = status && UpperBitsNotSet64(p->NID_C_1,           10);
    }
    status = status && UpperBitsNotSet64(p->NID_BG_1,          14);
    status = status && UpperBitsNotSet64(p->D_SR,              15);
    status = status && UpperBitsNotSet64(p->N_ITER_1,          5) ;
    for (uint32_t i = 0; i < p->N_ITER_1; ++i)
    {
        status = status && Staff_Responsible_distance_Information_from_loop_Core_1_UpperBitsNotSet(&(p->sub_1[i]));
    }

    if (status)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}