lsb function

int lsb(
  1. int bb
)

Index of the least-significant set bit. bb must be non-zero.

Uses the trailing-ones mask bb ^ (bb-1) (all bits up to and including the LSB), which is the form _index64 is built for — the same table the folded msb uses. (An isolated bb & -bb would need a different De Bruijn table.)

Implementation

int lsb(int bb) => _index64[(((bb ^ (bb - 1)) * _debruijn64) >>> 58) & 63];