// Disassmble an array of words into a byte array.
//
// input
//     The input array.
// output
//     The byte output array.
// byteCount
//     The number of bytes to disassemble, arbitrary length.
//
541705
func (s *Skein) putBytes(input []uint64, output []byte) {
	var j uint
	for i := 0; i < len(output); i++ {
		output[i] = byte(input[i/8] >> j)
		j = (j + 8) & 63
	}
}
1016606
func split(text []byte) [][]byte {
	// count lines (comment text never ends in a newline)
	n := 1
	for _, c := range text {
		if c == '\n' {
			n++
		}
	}

	// split
	lines := make([][]byte, n)
	n = 0
	i := 0
	for j, c := range text {
		if c == '\n' {
			lines[n] = text[i:j] // exclude newline
			i = j + 1            // discard newline
			n++
		}
	}
	lines[n] = text[i:]

	return lines
}
35341
func (c *RPCClient) DisassembleRange(scope api.EvalScope, startPC, endPC uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
	var out DisassembleOut
	err := c.call("Disassemble", DisassembleIn{scope, startPC, endPC, flavour}, &out)
	return out.Disassemble, err
}
64863
func (e *StringEncoder) Bytes() ([]byte, error) {
	// Compress the currently appended bytes using snappy and prefix with
	// a 1 byte header for future extension
	data := snappy.Encode(nil, e.bytes)
	return append([]byte{stringCompressedSnappy << 4}, data...), nil
}
1184298
func BytesSlice(val, sep string) ([][]byte, error) {
	s := strings.Split(val, sep)
	values := make([][]byte, len(s))
	for i, v := range s {
		value, err := Bytes(v)
		if err != nil {
			return values, err
		}
		values[i] = value
	}
	return values, nil
}
1248125
func Deserialize(p []byte) (*mem.Info, error) {
	info := &mem.Info{}
	err := json.Unmarshal(p, info)
	if err != nil {
		return nil, err
	}
	return info, nil
}
515897
func (d *Debugger) Disassemble(scope api.EvalScope, startPC, endPC uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
	d.processMutex.Lock()
	defer d.processMutex.Unlock()

	if _, err := d.target.Valid(); err != nil {
		return nil, err
	}

	if endPC == 0 {
		_, _, fn := d.target.BinInfo().PCToLine(startPC)
		if fn == nil {
			return nil, fmt.Errorf("Address 0x%x does not belong to any function", startPC)
		}
		startPC = fn.Entry
		endPC = fn.End
	}

	g, err := proc.FindGoroutine(d.target, scope.GoroutineID)
	if err != nil {
		return nil, err
	}

	insts, err := proc.Disassemble(d.target, g, startPC, endPC)
	if err != nil {
		return nil, err
	}
	disass := make(api.AsmInstructions, len(insts))

	for i := range insts {
		disass[i] = api.ConvertAsmInstruction(insts[i], insts[i].Text(proc.AssemblyFlavour(flavour), d.target.BinInfo()))
	}

	return disass, nil
}
235094
func (dt *DbfTable) convertToByteSlice(value string, numberOfBytes int) []byte {
	b := []byte(value)
	if len(b) <= numberOfBytes {
		return b
	}
	return b[0:numberOfBytes]
}
1089101
func PrintDisassembled(code string) error {
	script, err := hex.DecodeString(code)
	if err != nil {
		return err
	}

	it := NewInstructionIterator(script)
	for it.Next() {
		if it.Arg() != nil && 0 < len(it.Arg()) {
			fmt.Printf("%05x: %v 0x%x\n", it.PC(), it.Op(), it.Arg())
		} else {
			fmt.Printf("%05x: %v\n", it.PC(), it.Op())
		}
	}
	return it.Error()
}
950976
func (m *M) Bytes(mediatype string, v []byte) ([]byte, error) {
	out := buffer.NewWriter(make([]byte, 0, len(v)))
	if err := m.Minify(mediatype, out, buffer.NewReader(v)); err != nil {
		return v, err
	}
	return out.Bytes(), nil
}
1033661
func ToHexArray(b [][]byte) []string {
	r := make([]string, len(b))
	for i := range b {
		r[i] = ToHex(b[i])
	}
	return r
}
1052520
func Bytes(a, b []byte) []Change {
	return Diff(len(a), len(b), &bytes{a, b})
}
862393
func Split(data []byte, atEOF bool) (advance int, token []byte, err error) {
	return split(false, data, atEOF)
}
798166
func Convert_Slice_byte_To_Slice_byte(in *[]byte, out *[]byte, s Scope) error {
	if *in == nil {
		*out = nil
		return nil
	}
	*out = make([]byte, len(*in))
	copy(*out, *in)
	return nil
}
1121181
func WrapBytes(b []byte, lim int) []byte {
	words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp)
	var lines [][]byte
	for _, line := range WrapWords(words, 1, lim, defaultPenalty) {
		lines = append(lines, bytes.Join(line, sp))
	}
	return bytes.Join(lines, nl)
}
55233
func Deserialize(p []byte) *m.MemInfo {
	infoFlat := structs.GetRootAsMemInfo(p, 0)
	info := &m.MemInfo{}
	info.Timestamp = infoFlat.Timestamp()
	info.TotalRAM = infoFlat.TotalRAM()
	info.FreeRAM = infoFlat.FreeRAM()
	info.SharedRAM = infoFlat.SharedRAM()
	info.BufferRAM = infoFlat.BufferRAM()
	info.TotalSwap = infoFlat.TotalSwap()
	info.FreeSwap = infoFlat.FreeSwap()
	return info
}
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
}