public static ulong bits_extract(ulong x, int index, int length) { if (Bmi1.IsBmi1Supported) { return(Bmi1.bextr_u64(x, (uint)index, (uint)length)); } else { return((x >> index) & ((1ul << length) - 1)); } }