/* Compute first and last byte offsets for the fields given. Interprets the offsets table, which contains struct field offsets.  */
void xfs_btree_offsets(__int64_t fields, const short *offsets, int nbits, int *first, int *last)
/* Compute first and last byte offsets for the fields given. Interprets the offsets table, which contains struct field offsets.  */
void xfs_btree_offsets(__int64_t fields, const short *offsets, int nbits, int *first, int *last)
{
	int		i;
	__int64_t	imask;
	ASSERT(fields != 0);
	for (i = 0, imask = 1LL; ; i++, imask <<= 1) {
		if (imask & fields) {
			*first = offsets[i];
			break;
		}
	}
	for (i = nbits - 1, imask = 1LL << i; ; i--, imask >>= 1) {
		if (imask & fields) {
			*last = offsets[i + 1] - 1;
			break;
		}
	}
}