code: private static int trailingZeroBits(int x) {
          Assert.check(wordlen == 32);
          if (x == 0) {
              return 32;
          }
          int n = 1;
          if ((x & 0xffff) == 0) { n += 16; x >>>= 16; }
          if ((x & 0x00ff) == 0) { n +=  8; x >>>=  8; }
          if ((x & 0x000f) == 0) { n +=  4; x >>>=  4; }
          if ((x & 0x0003) == 0) { n +=  2; x >>>=  2; }
          return n - (x&1);
      }
docs: Count trailing zero bits in an int. Algorithm from "Hacker's
  Delight" by Henry S. Warren Jr. (figure 5-13)