func ReadIntfBytes(b []byte) (interface{}, []byte, error) {
	if len(b) < 1 {
		return nil, b, ErrShortBytes
	}
	k := NextType(b)
	switch k {
	case MapType:
		return ReadMapStrIntfBytes(b, nil)
	case ArrayType:
		sz, o, err := ReadArrayHeaderBytes(b)
		if err != nil {
			return nil, o, err
		}
		i := make([]interface{}, int(sz))
		for d := range i {
			i[d], o, err = ReadIntfBytes(o)
			if err != nil {
				return i, o, err
			}
		}
		return i, o, nil
	case Float32Type:
		return ReadFloat32Bytes(b)
	case Float64Type:
		return ReadFloat64Bytes(b)
	case IntType:
		return ReadInt64Bytes(b)
	case UintType:
		return ReadUint64Bytes(b)
	case BoolType:
		return ReadBoolBytes(b)
	case TimeType:
		return ReadTimeBytes(b)
	case Complex64Type:
		return ReadComplex64Bytes(b)
	case Complex128Type:
		return ReadComplex128Bytes(b)
	case ExtensionType:
		t, err := peekExtension(b)
		if err != nil {
			return nil, b, err
		}
		f, ok := extensionReg[t]
		if ok {
			e := f()
			o, err := ReadExtensionBytes(b, e)
			return e, o, err
		}
		e := RawExtension{}
		e.Type = int8(t)
		o, err := ReadExtensionBytes(b, &e)
		return &e, o, err
	case NilType:
		o, err := ReadNilBytes(b)
		return nil, o, err
	case BinType:
		return ReadBytesBytes(b, nil)
	case StrType:
		return ReadStringBytes(b)
	default:
		return nil, b[1:], InvalidPrefixError(b[0])
	}
}
ReadIntfBytes reads the next object out of b as a raw interface{} and returns any remaining bytes.
package msgp
import (
	"bytes"
	"encoding/binary"
	"math"
	"time"
)
var big = binary.BigEndian
func NextType(b []byte) Type {
	if len(b) == 0 {
		return InvalidType
	}
	spec := sizes[b[0]]
	t := spec.typ
	if t == ExtensionType && len(b) > int(spec.size) {
		var tp int8
		if spec.extra == constsize {
			tp = int8(b[1])
		} else {
			tp = int8(b[spec.size-1])
		}
		switch tp {
		case TimeExtension:
			return TimeType
		case Complex128Extension:
			return Complex128Type
		case Complex64Extension:
			return Complex64Type
		default:
			return ExtensionType
		}
	}
	return t
}
func IsNil(b []byte) bool {
	return len(b) > 0 && b[0] == mnil
}
type Raw []byte
func (r Raw) MarshalMsg(b []byte) ([]byte, error) {
	i := len(r)
	if i == 0 {
		return AppendNil(b), nil
	}
	o, l := ensure(b, i)
	copy(o[l:], []byte(r))
	return o, nil
}
func (r *Raw) UnmarshalMsg(b []byte) ([]byte, error) {
	l := len(b)
	out, err := Skip(b)
	if err != nil {
		return b, err
	}
	rlen := l - len(out)
	if cap(*r) < rlen {
		*r = make(Raw, rlen)
	} else {
		*r = (*r)[0:rlen]
	}
	copy(*r, b[:rlen])
	return out, nil
}
func (r Raw) EncodeMsg(w *Writer) error {
	if len(r) == 0 {
		return w.WriteNil()
	}
	_, err := w.Write([]byte(r))
	return err
}
func (r *Raw) DecodeMsg(f *Reader) error {
	*r = (*r)[:0]
	return appendNext(f, (*[]byte)(r))
}
func (r Raw) Msgsize() int {
	l := len(r)
	if l == 0 {
		return 1  
	}
	return l
}
func appendNext(f *Reader, d *[]byte) error {
	amt, o, err := getNextSize(f.R)
	if err != nil {
		return err
	}
	var i int
	*d, i = ensure(*d, int(amt))
	_, err = f.R.ReadFull((*d)[i:])
	if err != nil {
		return err
	}
	for o > 0 {
		err = appendNext(f, d)
		if err != nil {
			return err
		}
		o--
	}
	return nil
}
func (r *Raw) MarshalJSON() ([]byte, error) {
	var buf bytes.Buffer
	_, err := UnmarshalAsJSON(&buf, []byte(*r))
	return buf.Bytes(), err
}
func ReadMapHeaderBytes(b []byte) (uint32, []byte, error) {
	l := len(b)
	if l < 1 {
		return 0, b, ErrShortBytes
	}
	lead := b[0]
	if isfixmap(lead) {
		return uint32(rfixmap(lead)), b[1:], nil
	}
	switch lead {
	case mmap16:
		if l < 3 {
			return 0, b, ErrShortBytes
		}
		return uint32(big.Uint16(b[1:])), b[3:], nil
	case mmap32:
		if l < 5 {
			return 0, b, ErrShortBytes
		}
		return big.Uint32(b[1:]), b[5:], nil
	default:
		return 0, b, badPrefix(MapType, lead)
	}
}
func ReadMapKeyZC(b []byte) ([]byte, []byte, error) {
	o, b, err := ReadStringZC(b)
	if err != nil {
		if tperr, ok := err.(TypeError); ok && tperr.Encoded == BinType {
			return ReadBytesZC(b)
		}
	}
	return o, b, err
}
func ReadArrayHeaderBytes(b []byte) (uint32, []byte, error) {
	if len(b) < 1 {
		return 0, nil, ErrShortBytes
	}
	lead := b[0]
	if isfixarray(lead) {
		return uint32(rfixarray(lead)), b[1:], nil
	}
	switch lead {
	case marray16:
		if len(b) < 3 {
			return 0, b, ErrShortBytes
		}
		return uint32(big.Uint16(b[1:])), b[3:], nil
	case marray32:
		if len(b) < 5 {
			return 0, b, ErrShortBytes
		}
		return big.Uint32(b[1:]), b[5:], nil
	default:
		return 0, b, badPrefix(ArrayType, lead)
	}
}
func ReadNilBytes(b []byte) ([]byte, error) {
	if len(b) < 1 {
		return nil, ErrShortBytes
	}
	if b[0] != mnil {
		return b, badPrefix(NilType, b[0])
	}
	return b[1:], nil
}
func ReadFloat64Bytes(b []byte) (float64, []byte, error) {
	if len(b) < 5 {  
		return 0, b, ErrShortBytes
	}
	if b[0] != mfloat64 {
		if b[0] == mfloat32 {
			f32, b, err := ReadFloat32Bytes(b)
			return float64(f32), b, err
		}
		return 0, b, badPrefix(Float64Type, b[0])
	}
	return math.Float64frombits(getMuint64(b)), b[9:], nil
}
func ReadFloat32Bytes(b []byte) (float32, []byte, error) {
	if len(b) < 5 {
		return 0, b, ErrShortBytes
	}
	if b[0] != mfloat32 {
		return 0, b, TypeError{Method: Float32Type, Encoded: getType(b[0])}
	}
	return math.Float32frombits(getMuint32(b)), b[5:], nil
}
func ReadBoolBytes(b []byte) (bool, []byte, error) {
	if len(b) < 1 {
		return false, b, ErrShortBytes
	}
	switch b[0] {
	case mtrue:
		return true, b[1:], nil
	case mfalse:
		return false, b[1:], nil
	default:
		return false, b, badPrefix(BoolType, b[0])
	}
}
func ReadInt64Bytes(b []byte) (int64, []byte, error) {
	l := len(b)
	if l < 1 {
		return 0, nil, ErrShortBytes
	}
	lead := b[0]
	if isfixint(lead) {
		return int64(rfixint(lead)), b[1:], nil
	}
	if isnfixint(lead) {
		return int64(rnfixint(lead)), b[1:], nil
	}
	switch lead {
	case mint8, muint8:
		if l < 2 {
			return 0, b, ErrShortBytes
		}
		if lead == mint8 {
			return int64(getMint8(b)), b[2:], nil
		}
		return int64(getMuint8(b)), b[2:], nil
	case mint16, muint16:
		if l < 3 {
			return 0, b, ErrShortBytes
		}
		if lead == mint16 {
			return int64(getMint16(b)), b[3:], nil
		}
		return int64(getMuint16(b)), b[3:], nil
	case mint32, muint32:
		if l < 5 {
			return 0, b, ErrShortBytes
		}
		if lead == mint32 {
			return int64(getMint32(b)), b[5:], nil
		}
		return int64(getMint32(b)), b[5:], nil
	case mint64, muint64:
		if l < 9 {
			return 0, b, ErrShortBytes
		}
		if lead == mint64 {
			return getMint64(b), b[9:], nil
		}
		num := getMuint64(b)
		if num > math.MaxInt64 {
			return 0, b, UintOverflow{num, 64}
		}
		return int64(num), b[9:], nil
	}
	return 0, b, badPrefix(IntType, lead)
}
func ReadInt32Bytes(b []byte) (int32, []byte, error) {
	i, o, err := ReadInt64Bytes(b)
	if i > math.MaxInt32 || i < math.MinInt32 {
		return 0, o, IntOverflow{Value: i, FailedBitsize: 32}
	}
	return int32(i), o, err
}
func ReadInt16Bytes(b []byte) (int16, []byte, error) {
	i, o, err := ReadInt64Bytes(b)
	if i > math.MaxInt16 || i < math.MinInt16 {
		return 0, o, IntOverflow{Value: i, FailedBitsize: 16}
	}
	return int16(i), o, err
}
func ReadInt8Bytes(b []byte) (int8, []byte, error) {
	i, o, err := ReadInt64Bytes(b)
	if i > math.MaxInt8 || i < math.MinInt8 {
		return 0, o, IntOverflow{Value: i, FailedBitsize: 8}
	}
	return int8(i), o, err
}
func ReadIntBytes(b []byte) (int, []byte, error) {
	if smallint {
		i, b, err := ReadInt32Bytes(b)
		return int(i), b, err
	}
	i, b, err := ReadInt64Bytes(b)
	return int(i), b, err
}
func ReadUint64Bytes(b []byte) (uint64, []byte, error) {
	l := len(b)
	if l < 1 {
		return 0, nil, ErrShortBytes
	}
	lead := b[0]
	if isfixint(lead) {
		return uint64(rfixint(lead)), b[1:], nil
	}
	switch lead {
	case muint8:
		if l < 2 {
			return 0, b, ErrShortBytes
		}
		return uint64(getMuint8(b)), b[2:], nil
	case muint16:
		if l < 3 {
			return 0, b, ErrShortBytes
		}
		return uint64(getMuint16(b)), b[3:], nil
	case muint32:
		if l < 5 {
			return 0, b, ErrShortBytes
		}
		return uint64(getMuint32(b)), b[5:], nil
	case muint64:
		if l < 9 {
			return 0, b, ErrShortBytes
		}
		return getMuint64(b), b[9:], nil
	default:
		return 0, b, badPrefix(UintType, lead)
	}
}
func ReadUint32Bytes(b []byte) (uint32, []byte, error) {
	v, o, err := ReadUint64Bytes(b)
	if v > math.MaxUint32 {
		return 0, nil, UintOverflow{Value: v, FailedBitsize: 32}
	}
	return uint32(v), o, err
}
func ReadUint16Bytes(b []byte) (uint16, []byte, error) {
	v, o, err := ReadUint64Bytes(b)
	if v > math.MaxUint16 {
		return 0, nil, UintOverflow{Value: v, FailedBitsize: 16}
	}
	return uint16(v), o, err
}
func ReadUint8Bytes(b []byte) (uint8, []byte, error) {
	v, o, err := ReadUint64Bytes(b)
	if v > math.MaxUint8 {
		return 0, nil, UintOverflow{Value: v, FailedBitsize: 8}
	}
	return uint8(v), o, err
}
func ReadUintBytes(b []byte) (uint, []byte, error) {
	if smallint {
		u, b, err := ReadUint32Bytes(b)
		return uint(u), b, err
	}
	u, b, err := ReadUint64Bytes(b)
	return uint(u), b, err
}
func ReadByteBytes(b []byte) (byte, []byte, error) {
	return ReadUint8Bytes(b)
}
func ReadBytesBytes(b []byte, scratch []byte) ([]byte, []byte, error) {
	data, remaining, err := ReadBytesZC(b)
	if err != nil {
		return nil, b, err
	}
	l := len(data)
	if cap(scratch) >= l {
		scratch = scratch[0:l]
	} else {
		scratch = make([]byte, l)
	}
	copy(scratch, data)
	return scratch, remaining, nil
}
func ReadBytesZC(b []byte) ([]byte, []byte, error) {
	l := len(b)
	if l < 1 {
		return nil, b, ErrShortBytes
	}
	var dataLen int
	switch lead := b[0]; lead {
	case mbin8:
		if l < 2 {
			return nil, b, ErrShortBytes
		}
		dataLen = int(b[1])
		b = b[2:]
	case mbin16:
		if l < 3 {
			return nil, b, ErrShortBytes
		}
		dataLen = int(big.Uint16(b[1:]))
		b = b[3:]
	case mbin32:
		if l < 5 {
			return nil, b, ErrShortBytes
		}
		dataLen = int(big.Uint32(b[1:]))
		b = b[5:]
	default:
		return nil, b, badPrefix(BinType, lead)
	}
	if len(b) < dataLen {
		return nil, b, ErrShortBytes
	}
	return b[0:dataLen], b[dataLen:], nil
}
func ReadExactBytes(b []byte, dst []byte) ([]byte, error) {
	l := len(b)
	if l < 1 {
		return b, ErrShortBytes
	}
	var read uint32  
	var skip int     
	switch lead := b[0]; lead {
	case mbin8:
		if l < 2 {
			return b, ErrShortBytes
		}
		read = uint32(b[1])
		skip = 2
	case mbin16:
		if l < 3 {
			return b, ErrShortBytes
		}
		read = uint32(big.Uint16(b[1:]))
		skip = 3
	case mbin32:
		if l < 5 {
			return b, ErrShortBytes
		}
		read = big.Uint32(b[1:])
		skip = 5
	default:
		return b, badPrefix(BinType, lead)
	}
	if read != uint32(len(dst)) {
		return b, ArrayError{Wanted: uint32(len(dst)), Got: read}
	}
	return b[skip+copy(dst, b[skip:]):], nil
}
func ReadStringZC(b []byte) ([]byte, []byte, error) {
	l := len(b)
	if l < 1 {
		return nil, b, ErrShortBytes
	}
	lead := b[0]
	var read int
	if isfixstr(lead) {
		read = int(rfixstr(lead))
		b = b[1:]
	} else {
		switch lead {
		case mstr8:
			if l < 2 {
				return nil, b, ErrShortBytes
			}
			read = int(b[1])
			b = b[2:]
		case mstr16:
			if l < 3 {
				return nil, b, ErrShortBytes
			}
			read = int(big.Uint16(b[1:]))
			b = b[3:]
		case mstr32:
			if l < 5 {
				return nil, b, ErrShortBytes
			}
			read = int(big.Uint32(b[1:]))
			b = b[5:]
		default:
			return nil, b, TypeError{Method: StrType, Encoded: getType(lead)}
		}
	}
	if len(b) < read {
		return nil, b, ErrShortBytes
	}
	return b[0:read], b[read:], nil
}
func ReadStringBytes(b []byte) (string, []byte, error) {
	v, o, err := ReadStringZC(b)
	return string(v), o, err
}
func ReadStringAsBytes(b []byte, scratch []byte) ([]byte, []byte, error) {
	tmp, o, err := ReadStringZC(b)
	return append(scratch[:0], tmp...), o, err
}
func ReadComplex128Bytes(b []byte) (c complex128, o []byte, err error) {
	if len(b) < 18 {
		err = ErrShortBytes
		return
	}
	if b[0] != mfixext16 {
		err = badPrefix(Complex128Type, b[0])
		return
	}
	if int8(b[1]) != Complex128Extension {
		err = errExt(int8(b[1]), Complex128Extension)
		return
	}
	c = complex(math.Float64frombits(big.Uint64(b[2:])),
		math.Float64frombits(big.Uint64(b[10:])))
	o = b[18:]
	return
}
func ReadComplex64Bytes(b []byte) (c complex64, o []byte, err error) {
	if len(b) < 10 {
		err = ErrShortBytes
		return
	}
	if b[0] != mfixext8 {
		err = badPrefix(Complex64Type, b[0])
		return
	}
	if b[1] != Complex64Extension {
		err = errExt(int8(b[1]), Complex64Extension)
		return
	}
	c = complex(math.Float32frombits(big.Uint32(b[2:])),
		math.Float32frombits(big.Uint32(b[6:])))
	o = b[10:]
	return
}
func ReadTimeBytes(b []byte) (time.Time, []byte, error) {
	if len(b) < 15 {
		return time.Time{}, b, ErrShortBytes
	}
	if b[0] != mext8 || b[1] != 12 {
		return time.Time{}, b, badPrefix(TimeType, b[0])
	}
	if int8(b[2]) != TimeExtension {
		return time.Time{}, b, errExt(int8(b[2]), TimeExtension)
	}
	sec, nsec := getUnix(b[3:])
	return time.Unix(sec, int64(nsec)).Local(), b[15:], nil
}
func ReadMapStrIntfBytes(b []byte, old map[string]interface{}) (map[string]interface{}, []byte, error) {
	sz, o, err := ReadMapHeaderBytes(b)
	if err != nil {
		return old, o, err
	}
	if old != nil {
		for key := range old {
			delete(old, key)
		}
	} else {
		old = make(map[string]interface{}, int(sz))
	}
	for z := uint32(0); z < sz; z++ {
		if len(o) < 1 {
			return old, o, ErrShortBytes
		}
		var key []byte
		key, o, err = ReadMapKeyZC(o)
		if err != nil {
			return old, o, err
		}
		var val interface{}
		val, o, err = ReadIntfBytes(o)
		if err != nil {
			return old, o, err
		}
		old[string(key)] = val
	}
	return old, o, err
}