// helper function which converts a big endian []byte to a uint64
345978
func FromUint64(data [8]byte) uint64 {
	ui64 := binary.BigEndian.Uint64(data[:])
	return ui64
}
713139
func ParseBytes(str string) (uint64, error) {
	var sep int
	for _, r := range str {
		if !(unicode.IsDigit(r) || r == '.' || r == ',') {
			break
		}

		sep = sep + 1
	}

	var f float64

	if s := strings.Replace(str[:sep], ",", "", -1); len(s) > 0 {
		var err error

		f, err = strconv.ParseFloat(s, 64)
		if err != nil {
			return 0, err
		}
	}

	m, err := ParseByteUnit(str[sep:])
	if err != nil {
		return 0, err
	}

	f = f * float64(m)
	if f >= math.MaxUint64 {
		return 0, errors.New("number of bytes too large")
	}
	return uint64(f), nil
}
156508
func sliceBits64(x uint64, high, low uint8) uint64 {
	return (x << (63 - high)) >> (low + (63 - high))
}
809533
func PutInt64(v int64) []byte {
	b := make([]byte, 8)
	binary.LittleEndian.PutUint64(b, uint64(v))
	return b
}
347905
func uint64ToBytes(n uint64) []byte {
	return []byte{
		byte(n),
		byte(n >> 8),
		byte(n >> 16),
		byte(n >> 24),
		byte(n >> 32),
		byte(n >> 40),
		byte(n >> 48),
		byte(n >> 56),
	}
}
1114193
func UInt32() (i uint32) {
	randomBits(r)
	buf := bytes.NewBuffer(r)
	binary.Read(buf, binary.LittleEndian, &i)
	return i
}
745928
func uint32Bytes(i uint32) []byte {
	bytes := make([]byte, 4)
	binary.BigEndian.PutUint32(bytes, i)
	return bytes
}
572085
func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 {
	p := new(uint64)
	f.Uint64Var(p, name, value, usage)
	return p
}
1287834
func BytesToUint64(b []byte) (uint64, error) {
	if len(b) != 8 {
		return 0, fmt.Errorf("invalid data, must 8 bytes, but %d", len(b))
	}

	return binary.BigEndian.Uint64(b), nil
}
1190076
func Uint64Slice(src []uint64) []*uint64 {
	dst := make([]*uint64, len(src))
	for i := 0; i < len(src); i++ {
		dst[i] = &(src[i])
	}
	return dst
}
613505
func bytesToUintLittleEndian(b []byte) (res uint64) {
	mul := uint64(1)
	for i := 0; i < len(b); i++ {
		res += uint64(b[i]) * mul
		mul *= 256
	}
	return res
}
376673
func PackU64ToBytesInline(val uint64, ret []byte) {
	ret[7] = byte(val & (0xFF << 56) >> 56)
	ret[6] = byte(val & (0xFF << 48) >> 48)
	ret[5] = byte(val & (0xFF << 40) >> 40)
	ret[4] = byte(val & (0xFF << 32) >> 32)
	ret[3] = byte(val & (0xFF << 24) >> 24)
	ret[2] = byte(val & (0xFF << 16) >> 16)
	ret[1] = byte(val & (0xFF << 8) >> 8)
	ret[0] = byte(val & (0xFF << 0) >> 0)
}
676248
func (e *Event) Uints64(key string, i []uint64) *Event {
	if e == nil {
		return e
	}
	e.buf = enc.AppendUints64(enc.AppendKey(e.buf, key), i)
	return e
}
659921
func (tr Row) Uint64(nn int) (val uint64) {
	val, err := tr.Uint64Err(nn)
	if err != nil {
		panic(err)
	}
	return
}
611394
func uint64FromNetwork(u uint64) uint64 {
	b := *(*[8]byte)(unsafe.Pointer(&u))
	return binary.BigEndian.Uint64(b[:])
}
20300
func HashUint64(f func() hash.Hash64) func(uint64) uint64 {
	return func(u uint64) uint64 {
		b := [8]byte{}
		binary.BigEndian.PutUint64(b[:], u)
		h := f()
		h.Write(b[:])
		return h.Sum64()
	}
}
510103
func Max3Uint64(a, b, c uint64) uint64 {
	max := a
	if b > max {
		max = b
	}
	if c > max {
		max = c
	}
	return max
}