Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
Bitmasking or Kerninghan's Algorithm
There are two common ways to count set bits: 1. Shift the number one bit at a time and check if the LSB is 1 (`n & 1`). 2. Use Kerninghan's bit trick: `n &= (n - 1)`, which flips the rightmost set bit to 0 in each step. The latter is faster as it only iterates as many times as there are set bits.