code: public static long pop_array(long[] arr, int wordOffset, int numWords) {
      long popCount = 0;
      for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
        popCount += Long.bitCount(arr[i]);
      }
      return popCount;
    }
docs: Returns the number of set bits in an array of longs.