/* Multiply 64.16 fixed point value by (2^scalebits) and convert to 128-bit integer.  */
static force_inline void fixed_64_16_to_int128(int64_t hi, int64_t lo, int64_t *rhi, int64_t *rlo, int scalebits)
/* Multiply 64.16 fixed point value by (2^scalebits) and convert to 128-bit integer.  */
static force_inline void fixed_64_16_to_int128(int64_t hi, int64_t lo, int64_t *rhi, int64_t *rlo, int scalebits)
{
    hi += lo >> 16;
    lo &= 0xFFFF;
    if (scalebits <= 0)
    {
        *rlo = hi >> (-scalebits);
        *rhi = *rlo >> 63;
    }
    else
    {
        *rhi = hi >> (64 - scalebits);
        *rlo = (uint64_t)hi << scalebits;
        if (scalebits < 16)
            *rlo += lo >> (16 - scalebits);
        else
            *rlo += lo << (scalebits - 16);
    }
}