// Deserialize takes some Flatbuffer serialized bytes and deserializes them as
// loadavg.LoadAvg.
554924
func Deserialize(p []byte) l.LoadAvg {
	flatLA := structs.GetRootAsLoadAvg(p, 0)
	var la l.LoadAvg
	la.Timestamp = flatLA.Timestamp()
	la.Minute = flatLA.Minute()
	la.Five = flatLA.Five()
	la.Fifteen = flatLA.Fifteen()
	la.Running = flatLA.Running()
	la.Total = flatLA.Total()
	la.PID = flatLA.PID()
	return la
}
678442
func (ba *bitArray) Serialize() ([]byte, error) {
	w := new(bytes.Buffer)

	var identifier uint8 = 'B'
	err := binary.Write(w, binary.LittleEndian, identifier)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.lowest)
	if err != nil {
		return nil, err
	}
	err = binary.Write(w, binary.LittleEndian, ba.highest)
	if err != nil {
		return nil, err
	}

	var encodedanyset uint8
	if ba.anyset {
		encodedanyset = 1
	} else {
		encodedanyset = 0
	}
	err = binary.Write(w, binary.LittleEndian, encodedanyset)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.blocks)
	if err != nil {
		return nil, err
	}
	return w.Bytes(), nil
}
124365
func Deserialize(p []byte) *mem.Info {
	infoFlat := structs.GetRootAsInfo(p, 0)
	info := &mem.Info{}
	info.Timestamp = infoFlat.Timestamp()
	info.Active = infoFlat.Active()
	info.ActiveAnon = infoFlat.ActiveAnon()
	info.ActiveFile = infoFlat.ActiveFile()
	info.AnonHugePages = infoFlat.AnonHugePages()
	info.AnonPages = infoFlat.AnonPages()
	info.Bounce = infoFlat.Bounce()
	info.Buffers = infoFlat.Buffers()
	info.Cached = infoFlat.Cached()
	info.CommitLimit = infoFlat.CommitLimit()
	info.CommittedAS = infoFlat.CommittedAS()
	info.DirectMap4K = infoFlat.DirectMap4K()
	info.DirectMap2M = infoFlat.DirectMap2M()
	info.Dirty = infoFlat.Dirty()
	info.HardwareCorrupted = infoFlat.HardwareCorrupted()
	info.HugePagesFree = infoFlat.HugePagesFree()
	info.HugePagesRsvd = infoFlat.HugePagesRsvd()
	info.HugePagesSize = infoFlat.HugePagesSize()
	info.HugePagesSurp = infoFlat.HugePagesSurp()
	info.HugePagesTotal = infoFlat.HugePagesTotal()
	info.Inactive = infoFlat.Inactive()
	info.InactiveAnon = infoFlat.InactiveAnon()
	info.InactiveFile = infoFlat.InactiveFile()
	info.KernelStack = infoFlat.KernelStack()
	info.Mapped = infoFlat.Mapped()
	info.MemAvailable = infoFlat.MemAvailable()
	info.MemFree = infoFlat.MemFree()
	info.MemTotal = infoFlat.MemTotal()
	info.Mlocked = infoFlat.Mlocked()
	info.NFSUnstable = infoFlat.NFSUnstable()
	info.PageTables = infoFlat.PageTables()
	info.Shmem = infoFlat.Shmem()
	info.Slab = infoFlat.Slab()
	info.SReclaimable = infoFlat.SReclaimable()
	info.SUnreclaim = infoFlat.SUnreclaim()
	info.SwapCached = infoFlat.SwapCached()
	info.SwapFree = infoFlat.SwapFree()
	info.SwapTotal = infoFlat.SwapTotal()
	info.Unevictable = infoFlat.Unevictable()
	info.VmallocChunk = infoFlat.VmallocChunk()
	info.VmallocTotal = infoFlat.VmallocTotal()
	info.VmallocUsed = infoFlat.VmallocUsed()
	info.Writeback = infoFlat.Writeback()
	info.WritebackTmp = infoFlat.WritebackTmp()
	return info
}
451308
func Serialize(v interface{}, simple bool) []byte {
	return NewWriter(simple).Serialize(v).Bytes()
}
26473
func Deserialize(data []byte) (*Key, error) {
	if len(data) != 82 {
		return nil, ErrSerializedKeyWrongSize
	}
	var key = &Key{}
	key.Version = data[0:4]
	key.Depth = data[4]
	key.FingerPrint = data[5:9]
	key.ChildNumber = data[9:13]
	key.ChainCode = data[13:45]

	if data[45] == byte(0) {
		key.IsPrivate = true
		key.Key = data[46:78]
	} else {
		key.IsPrivate = false
		key.Key = data[45:78]
	}

	// validate checksum
	cs1, err := checksum(data[0 : len(data)-4])
	if err != nil {
		return nil, err
	}

	cs2 := data[len(data)-4:]
	for i := range cs1 {
		if cs1[i] != cs2[i] {
			return nil, ErrInvalidChecksum
		}
	}
	return key, nil
}
1243069
func (j JSONStateSerializer) Deserialize(serialized string, state interface{}) error {
	err := json.NewDecoder(strings.NewReader(serialized)).Decode(state)
	return err
}
1348956
func deserializeVLQ(serialized []byte) (uint64, int) {
	var n uint64
	var size int
	for _, val := range serialized {
		size++
		n = (n << 7) | uint64(val&0x7f)
		if val&0x80 != 0x80 {
			break
		}
		n++
	}

	return n, size
}
533789
func UnitSerialize(opts []*unit.UnitOption) io.Reader {
	var buf bytes.Buffer

	if len(opts) == 0 {
		return &buf
	}

	idx := map[string][]*unit.UnitOption{}
	for _, opt := range opts {
		idx[opt.Section] = append(idx[opt.Section], opt)
	}

	// CHANGED HERE: Output in the following order:
	// - Unit
	// - Service
	// - Install
	// rather than just iterating over the map in random order.
	for _, curSection := range []string{"Unit", "Service", "Install"} {
		curOpts, found := idx[curSection]
		if !found {
			continue
		}
		writeSectionHeader(&buf, curSection)
		writeNewline(&buf)

		for _, opt := range curOpts {
			writeOption(&buf, opt)
			writeNewline(&buf)
		}
		writeNewline(&buf)
	}

	return &buf
}
28981
func Unserialize(b []byte, p interface{}, simple bool) {
	reader := AcquireReader(b, simple)
	defer ReleaseReader(reader)
	reader.Unserialize(p)
}
346729
func (e NopEncoder) Deserialize(src []byte, dst interface{}) error {
	if dat, ok := dst.(*[]byte); ok {
		*dat = src
		return nil
	}
	return errValueNotBytePtr
}
236511
func GobSerialize(store Store) ([]byte, error) {
	w := new(bytes.Buffer)
	err := GobEncode(store, w)
	return w.Bytes(), err
}
1281854
func (b *BaseKvdb) DeserializeAll(out []byte) (kvdb.KVPairs, error) {
	var kvps kvdb.KVPairs
	if err := json.Unmarshal(out, &kvps); err != nil {
		return nil, err
	}
	return kvps, nil
}
533615
func Deserialize(p []byte) (*procs.Processors, error) {
	proc := &procs.Processors{}
	err := json.Unmarshal(p, proc)
	if err != nil {
		return nil, err
	}
	return proc, nil
}
1160001
func Deserialize(p []byte) *structs.DiskUsage {
	u := &structs.DiskUsage{}
	devF := &flat.Device{}
	uF := flat.GetRootAsDiskUsage(p, 0)
	u.Timestamp = uF.Timestamp()
	u.TimeDelta = uF.TimeDelta()
	len := uF.DeviceLength()
	u.Device = make([]structs.Device, len)
	for i := 0; i < len; i++ {
		var dev structs.Device
		if uF.Device(devF, i) {
			dev.Major = devF.Major()
			dev.Minor = devF.Minor()
			dev.Name = string(devF.Name())
			dev.ReadsCompleted = devF.ReadsCompleted()
			dev.ReadsMerged = devF.ReadsMerged()
			dev.ReadSectors = devF.ReadSectors()
			dev.ReadingTime = devF.ReadingTime()
			dev.WritesCompleted = devF.WritesCompleted()
			dev.WritesMerged = devF.WritesMerged()
			dev.WrittenSectors = devF.WrittenSectors()
			dev.WritingTime = devF.WritingTime()
			dev.IOInProgress = devF.IOInProgress()
			dev.IOTime = devF.IOTime()
			dev.WeightedIOTime = devF.WeightedIOTime()
		}
		u.Device[i] = dev
	}
	return u
}
40538
func (s *MessagePackSerializer) Deserialize(data []byte) (Message, error) {
	var arr []interface{}
	if err := codec.NewDecoderBytes(data, new(codec.MsgpackHandle)).Decode(&arr); err != nil {
		return nil, err
	} else if len(arr) == 0 {
		return nil, fmt.Errorf("Invalid message")
	}

	var msgType MessageType
	if typ, ok := arr[0].(int64); ok {
		msgType = MessageType(typ)
	} else {
		return nil, fmt.Errorf("Unsupported message format")
	}

	return apply(msgType, arr)
}
880521
func (h *BlockHeader) Deserialize(r io.Reader) error {
	// At the current time, there is no difference between the wire encoding
	// at protocol version 0 and the stable long-term storage format.  As
	// a result, make use of readBlockHeader.
	return readBlockHeader(r, 0, h)
}
915550
func (e JSONEncoder) Deserialize(src []byte, dst interface{}) error {
	dec := json.NewDecoder(bytes.NewReader(src))
	if err := dec.Decode(dst); err != nil {
		return cookieError{cause: err, typ: decodeError}
	}
	return nil
}