// CountBitsUint16s count 1's in b
187234
func CountBitsUint16s(b []uint16) int {
	c := 0
	for _, x := range b {
		c += CountBitsUint16(x)
	}
	return c
}
1047666
func BytesToInt16(buf []byte, offset int) int16 {
	return int16(binary.BigEndian.Uint16(buf[offset : offset+uint16sz]))
}
522571
func (c Context) Ints16(key string, i []int16) Context {
	c.l.context = enc.AppendInts16(enc.AppendKey(c.l.context, key), i)
	return c
}
273454
func (b *bmBlock) count(start, end uintptr) (count int) {
	br := b[start/uintptrBits : end/uintptrBits+1]
	for i, w := range br {
		if i == 0 {
			w &= blockmask(start)
		}
		if i == len(br)-1 {
			w &^= blockmask(end)
		}
		count += onesCountPtr(w)
	}
	return count
}
626363
func (r *Redis) BitCount(key string, start, end int) (int64, error) {
	rp, err := r.ExecuteCommand("BITCOUNT", key, start, end)
	if err != nil {
		return 0, err
	}
	return rp.IntegerValue()
}
294056
func (f *decompressor) getBits(n byte) uint16 {
	if f.nbits < n {
		if !f.feed() {
			f.fail(io.ErrUnexpectedEOF)
		}
	}
	c := uint16(f.c >> (32 - n))
	f.c <<= n
	f.nbits -= n
	return c
}
58079
func (s *Bitset) BitCount() int {
	var n int
	s.unsetTop()
	for i, l := 0, len(s.set); i < l; i++ {
		n += BitCount(s.set[i])
	}

	return n
}
1189613
func (pc *ProbabilisticCounter) Count() int {
	ones := float64(pc.bitset.Count())
	length := float64(pc.bitset.Len())
	zeroes := length - ones
	estimator := -1 * length * math.Log(zeroes/length)
	return int(estimator)
}
1235373
func CountBitsIntPopCnt(x int) int {
	if strconv.IntSize == 64 {
		return CountBitsInt64PopCnt(int64(x))
	} else if strconv.IntSize == 32 {
		return CountBitsInt32PopCnt(int32(x))
	}
	panic("strconv.IntSize must be 32 or 64")
}
343624
func Int16s(b0, b1 []int16) int {
	d := 0
	for i, x := range b0 {
		d += Int16(x, b1[i])
	}
	return d
}
993653
func (pw *Writer) WriteBits(v, nb uint) {
	if _, err := pw.PushBits(); err != nil {
		errors.Panic(err)
	}
	pw.bufBits |= uint64(v) << pw.numBits
	pw.numBits += nb
}
917819
func CountBytes(b []byte) (int, error) {
	var count int
	for len(b) >= 8 {
		v := binary.BigEndian.Uint64(b[:8])
		b = b[8:]

		sel := v >> 60
		if sel >= 16 {
			return 0, fmt.Errorf("invalid selector value: %v", sel)
		}
		count += selector[sel].n
	}

	if len(b) > 0 {
		return 0, fmt.Errorf("invalid slice len remaining: %v", len(b))
	}
	return count, nil
}
306729
func toBits(s byte) [8]bool {
	r := [8]bool{}
	for i := range r {
		if s&(uint8(1)<<uint8(7-i)) != 0 {
			r[i] = true
		}
	}
	return r
}
849679
func (db *DB) BitCount(key []byte, start int, end int) (int64, error) {
	if err := checkKeySize(key); err != nil {
		return 0, err
	}

	key = db.encodeKVKey(key)
	value, err := db.bucket.Get(key)
	if err != nil {
		return 0, err
	}

	start, end = getRange(start, end, len(value))
	value = value[start : end+1]

	var n int64

	pos := 0
	for ; pos+4 <= len(value); pos = pos + 4 {
		n += int64(numberBitCount(binary.BigEndian.Uint32(value[pos : pos+4])))
	}

	for ; pos < len(value); pos++ {
		n += int64(bitsInByte[value[pos]])
	}

	return n, nil
}
743007
func (bl *BitList) AddBits(b int, count byte) {
	for i := int(count) - 1; i >= 0; i-- {
		bl.AddBit(((b >> uint(i)) & 1) == 1)
	}
}
880040
func CountBitsUintsPopCnt(x []uint) int {
	if strconv.IntSize == 64 {
		y := (*[]uint64)(unsafe.Pointer(&x)) // #nosec G103
		return CountBitsUint64sPopCnt(*y)
	} else if strconv.IntSize == 32 {
		y := (*[]uint32)(unsafe.Pointer(&x)) // #nosec G103
		return CountBitsUint32sPopCnt(*y)
	}
	panic("strconv.IntSize must be 32 or 64 bits")
}
431383
func (b *bitWriter) addBits16Clean(value uint16, bits uint8) {
	b.bitContainer |= uint64(value) << (b.nBits & 63)
	b.nBits += bits
}