Remember
- 1 shl i is the mask for bit i. OR sets it, AND with the inverse clears it, XOR flips it.
- n and (n - 1) clears the lowest 1 bit. Loop it to count set bits in one round per 1.
- A power of two has exactly one 1 bit, so n and (n - 1) is zero for it and nothing else.