int bit_count(long x) { int n = 0; if (x) do { n++; } while ((x &= x-1)); return(n); }