func (o *Buffer) dec_int64(p *Properties, base uintptr, sbase uintptr) error {
	u, err := p.valDec(o)
	if err != nil {
		return err
	}
	v := (**int64)(unsafe.Pointer(base + p.offset))
	x := (*int64)(unsafe.Pointer(sbase + p.scratch))
	*x = int64(u)
	*v = x
	return nil
}
Decode an int64.
package proto
import (
	"errors"
	"fmt"
	"io"
	"os"
	"reflect"
	"runtime"
	"unsafe"
)
var ErrWrongType = errors.New("field/encoding mismatch: wrong type for field")
func DecodeVarint(buf []byte) (x uint64, n int) {
	for shift := uint(0); ; shift += 7 {
		if n >= len(buf) {
			return 0, 0
		}
		b := uint64(buf[n])
		n++
		x |= (b & 0x7F) << shift
		if (b & 0x80) == 0 {
			break
		}
	}
	return x, n
}
func (p *Buffer) DecodeVarint() (x uint64, err error) {
	i := p.index
	l := len(p.buf)
	for shift := uint(0); ; shift += 7 {
		if i >= l {
			err = io.ErrUnexpectedEOF
			return
		}
		b := p.buf[i]
		i++
		x |= (uint64(b) & 0x7F) << shift
		if b < 0x80 {
			break
		}
	}
	p.index = i
	return
}
func (p *Buffer) DecodeFixed64() (x uint64, err error) {
	i := p.index + 8
	if i > len(p.buf) {
		err = io.ErrUnexpectedEOF
		return
	}
	p.index = i
	x = uint64(p.buf[i-8])
	x |= uint64(p.buf[i-7]) << 8
	x |= uint64(p.buf[i-6]) << 16
	x |= uint64(p.buf[i-5]) << 24
	x |= uint64(p.buf[i-4]) << 32
	x |= uint64(p.buf[i-3]) << 40
	x |= uint64(p.buf[i-2]) << 48
	x |= uint64(p.buf[i-1]) << 56
	return
}
func (p *Buffer) DecodeFixed32() (x uint64, err error) {
	i := p.index + 4
	if i > len(p.buf) {
		err = io.ErrUnexpectedEOF
		return
	}
	p.index = i
	x = uint64(p.buf[i-4])
	x |= uint64(p.buf[i-3]) << 8
	x |= uint64(p.buf[i-2]) << 16
	x |= uint64(p.buf[i-1]) << 24
	return
}
func (p *Buffer) DecodeZigzag64() (x uint64, err error) {
	x, err = p.DecodeVarint()
	if err != nil {
		return
	}
	x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63)
	return
}
func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
	x, err = p.DecodeVarint()
	if err != nil {
		return
	}
	x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31))
	return
}
func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) {
	n, err := p.DecodeVarint()
	if err != nil {
		return
	}
	nb := int(n)
	if p.index+nb > len(p.buf) {
		err = io.ErrUnexpectedEOF
		return
	}
	if !alloc {
		buf = p.buf[p.index : p.index+nb]
		p.index += nb
		return
	}
	buf = make([]byte, nb)
	copy(buf, p.buf[p.index:])
	p.index += nb
	return
}
func (p *Buffer) DecodeStringBytes() (s string, err error) {
	buf, err := p.DecodeRawBytes(false)
	if err != nil {
		return
	}
	return string(buf), nil
}
func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base uintptr) error {
	oi := o.index
	err := o.skip(t, tag, wire)
	if err != nil {
		return err
	}
	x := fieldIndex(t, "XXX_unrecognized")
	if x == nil {
		return nil
	}
	p := propByIndex(t, x)
	ptr := (*[]byte)(unsafe.Pointer(base + p.offset))
	if *ptr == nil {
		*ptr = o.bufalloc()
	}
	obuf := o.buf
	o.buf = *ptr
	o.EncodeVarint(uint64(tag<<3 | wire))
	*ptr = append(o.buf, obuf[oi:o.index]...)
	o.buf = obuf
	return nil
}
func (o *Buffer) skip(t reflect.Type, tag, wire int) error {
	var u uint64
	var err error
	switch wire {
	case WireVarint:
		_, err = o.DecodeVarint()
	case WireFixed64:
		_, err = o.DecodeFixed64()
	case WireBytes:
		_, err = o.DecodeRawBytes(false)
	case WireFixed32:
		_, err = o.DecodeFixed32()
	case WireStartGroup:
		for {
			u, err = o.DecodeVarint()
			if err != nil {
				break
			}
			fwire := int(u & 0x7)
			if fwire == WireEndGroup {
				break
			}
			ftag := int(u >> 3)
			err = o.skip(t, ftag, fwire)
			if err != nil {
				break
			}
		}
	default:
		fmt.Fprintf(os.Stderr, "proto: can't skip wire type %d for %s\n", wire, t)
	}
	return err
}
type Unmarshaler interface {
	Unmarshal([]byte) error
}
func Unmarshal(buf []byte, pb interface{}) error {
	if u, ok := pb.(Unmarshaler); ok {
		return u.Unmarshal(buf)
	}
	return NewBuffer(buf).Unmarshal(pb)
}
func (p *Buffer) Unmarshal(pb interface{}) error {
	if u, ok := pb.(Unmarshaler); ok {
		err := u.Unmarshal(p.buf[p.index:])
		p.index = len(p.buf)
		return err
	}
	mstat := runtime.MemStats.Mallocs
	typ, base, err := getbase(pb)
	if err != nil {
		return err
	}
	err = p.unmarshalType(typ, false, base)
	mstat = runtime.MemStats.Mallocs - mstat
	stats.Dmalloc += mstat
	stats.Decode++
	return err
}
func (o *Buffer) unmarshalType(t reflect.Type, is_group bool, base uintptr) error {
	st := t.Elem()
	prop := GetProperties(st)
	required, reqFields := prop.reqCount, uint64(0)
	sbase := getsbase(prop)  
	var err error
	for err == nil && o.index < len(o.buf) {
		oi := o.index
		var u uint64
		u, err = o.DecodeVarint()
		if err != nil {
			break
		}
		wire := int(u & 0x7)
		if wire == WireEndGroup {
			if is_group {
				return nil  
			}
			return ErrWrongType
		}
		tag := int(u >> 3)
		fieldnum, ok := prop.tags[tag]
		if !ok {
			o.ptr = base
			iv := unsafe.Unreflect(t, unsafe.Pointer(&o.ptr))
			if e, ok := iv.(extendableProto); ok && isExtensionField(e, int32(tag)) {
				if err = o.skip(st, tag, wire); err == nil {
					e.ExtensionMap()[int32(tag)] = Extension{enc: append([]byte(nil), o.buf[oi:o.index]...)}
				}
				continue
			}
			err = o.skipAndSave(st, tag, wire, base)
			continue
		}
		p := prop.Prop[fieldnum]
		if p.dec == nil {
			fmt.Fprintf(os.Stderr, "no protobuf decoder for %s.%s\n", t, st.Field(fieldnum).Name)
			continue
		}
		dec := p.dec
		if wire != WireStartGroup && wire != p.WireType {
			if wire == WireBytes && p.packedDec != nil {
				dec = p.packedDec
			} else {
				err = ErrWrongType
				continue
			}
		}
		err = dec(o, p, base, sbase)
		if err == nil && p.Required {
			if tag <= 64 {
				var mask uint64 = 1 << uint64(tag-1)
				if reqFields&mask == 0 {
					reqFields |= mask
					required--
				}
			} else {
				required--
			}
		}
	}
	if err == nil {
		if is_group {
			return io.ErrUnexpectedEOF
		}
		if required > 0 {
			return &ErrRequiredNotSet{st}
		}
	}
	return err
}
func initSlice(pslice unsafe.Pointer, base uintptr) {
	sp := (*reflect.SliceHeader)(pslice)
	sp.Data = base
	sp.Len = 0
	sp.Cap = startSize
}
func (o *Buffer) dec_bool(p *Properties, base uintptr, sbase uintptr) error {
	u, err := p.valDec(o)
	if err != nil {
		return err
	}
	v := (**uint8)(unsafe.Pointer(base + p.offset))
	x := (*uint8)(unsafe.Pointer(sbase + p.scratch))
	*x = uint8(u)
	*v = x
	return nil
}
func (o *Buffer) dec_int32(p *Properties, base uintptr, sbase uintptr) error {
	u, err := p.valDec(o)
	if err != nil {
		return err
	}
	v := (**int32)(unsafe.Pointer(base + p.offset))
	x := (*int32)(unsafe.Pointer(sbase + p.scratch))
	*x = int32(u)
	*v = x
	return nil
}