// PutUint8 encodes a uint8 into b.
// If b is not exactly 1 byte in length, PutUint8 will panic.
425705
func PutUint8(b []byte, v uint8) {
	if l := len(b); l != 1 {
		panic(fmt.Sprintf("PutUint8: unexpected byte slice length: %d", l))
	}

	b[0] = v
}
1315396
func EncodeUint64(i uint64) string {
	enc := make([]byte, 2, 10)
	copy(enc, "0x")
	return string(strconv.AppendUint(enc, i, 16))
}
1272328
func MinUint8N(v ...uint8) uint8 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinUint8(v[0], v[1])
	default:
		l := len(v) / 2
		return MinUint8N(MinUint8N(v[:l]...), MinUint8N(v[l:]...))
	}
}
880330
func (enc *Encoder) AddUint8Key(key string, v uint8) {
	enc.Uint64Key(key, uint64(v))
}
232539
func Uint8(b []byte) uint8 {
	if l := len(b); l != 1 {
		panic(fmt.Sprintf("Uint8: unexpected byte slice length: %d", l))
	}

	return b[0]
}
507026
func AddUint64(h uint64, u uint64) uint64 {
	h = h + u + constant
	h = (h<<shift | h>>(64-shift)) ^ u
	h = ((h<<shift | h>>(64-shift)) ^ constant) + u
	return h
}
1344053
func (e Encoder) AppendUint8(dst []byte, val uint8) []byte {
	return e.AppendUint(dst, uint(val))
}
788444
func (c Context) Uints8(key string, i []uint8) Context {
	c.l.context = enc.AppendUints8(enc.AppendKey(c.l.context, key), i)
	return c
}
149517
func (m *Manager) GetUint8(key string) uint8 {
	return cast.ToUint8(m.Get(key))
}
1137356
func extractUint8(r io.Reader) (uint8, error) {
	buf := make([]byte, 1)
	_, err := io.ReadFull(r, buf)
	if err != nil {
		return 0, err
	}
	return buf[0], nil
}
740817
func (cmd *baseCommand) WriteUint16(num uint16) (int, error) {
	binary.BigEndian.PutUint16(cmd.dataBuffer[cmd.dataOffset:cmd.dataOffset+2], num)
	cmd.dataOffset += 2
	return 2, nil
}
290047
func PutUint32(b []byte, v uint32) {
	if l := len(b); l != 4 {
		panic(fmt.Sprintf("PutUint32: unexpected byte slice length: %d", l))
	}

	*(*uint32)(unsafe.Pointer(&b[0])) = v
}
845314
func ReadUInt8(
	clientAddr chan<- protocol.Addr,
	clientData <-chan protocol.ReadData,
	bufferedAccess bool,
	readAddr uintptr) uint8 {

	// Issue read request.
	go func() {
		clientAddr <- protocol.Addr{
			Addr:  readAddr,
			Size:  [3]bool{false, false, false},
			Burst: [2]bool{true, false},
			Cache: [4]bool{bufferedAccess, true, false, false}}
	}()

	// Select data from 64-bit read result.
	readResp := <-clientData
	var readData uint8
	switch byte(readAddr) & 0x7 {
	case 0x0:
		readData = uint8(readResp.Data)
	case 0x1:
		readData = uint8(readResp.Data >> 8)
	case 0x2:
		readData = uint8(readResp.Data >> 16)
	case 0x3:
		readData = uint8(readResp.Data >> 24)
	case 0x4:
		readData = uint8(readResp.Data >> 32)
	case 0x5:
		readData = uint8(readResp.Data >> 40)
	case 0x6:
		readData = uint8(readResp.Data >> 48)
	default:
		readData = uint8(readResp.Data >> 56)
	}
	// TODO: return !readResp.Resp[1], readData
	return readData
}
1341817
func WriteUInt32(w io.Writer, byteOrder binary.ByteOrder, value uint32) error {
	var buf [4]byte
	byteOrder.PutUint32(buf[:], value)
	_, err := w.Write(buf[:])
	return err
}
1338279
func WriteUint(u uint64, buffer *WriterAsBuffer) {
	var a [64 + 1]byte
	i := len(a)

	if ^uintptr(0)>>32 == 0 {
		for u > uint64(^uintptr(0)) {
			q := u / 1e9
			us := uintptr(u - q*1e9)
			for j := 9; j > 0; j-- {
				i--
				qs := us / 10
				a[i] = byte(us - qs*10 + '0')
				us = qs
			}
			u = q
		}
	}

	us := uintptr(u)
	for us >= 10 {
		i--
		q := us / 10
		a[i] = byte(us - q*10 + '0')
		us = q
	}

	i--
	a[i] = byte(us + '0')
	buffer.Write(a[i:])
}
294082
func EncodeUint(b []byte, v uint64) []byte {
	var data [8]byte
	binary.BigEndian.PutUint64(data[:], v)
	return append(b, data[:]...)
}
557376
func ConvertUint8(str string) (uint8, error) {
	i, err := strconv.ParseUint(str, 10, 8)
	if err != nil {
		return 0, err
	}
	return uint8(i), nil
}