// Unread n bytes from the current position.
345547
func (r *ByteReader) Unread(n int) {
	if r.off >= n {
		r.off -= n
	} else {
		r.off = 0
	}
}
77420
func (cb *CountBytes) Bytes() int64 {
	cb.mu.Lock()
	defer cb.mu.Unlock()
	return cb.bytes
}
981551
func (r *ByteReader) ReadByte() (byte, error) {
	if r.off >= len(r.buf) {
		return 0, io.EOF
	}
	return r.readByte(), nil
}
877514
func Bytes(n int) []byte {
	b := make([]byte, n)
	Read(b)
	return b
}
462500
func (s Bytes) Unset(i int) {
	s[uint(i)>>byteShift] &^= 1 << (uint(i) & byteModMask)
}
107830
func (c *transfer) N() (n int64) {
	if c == nil {
		return 0
	}
	n = atomic.LoadInt64(&c.n)
	return
}
474139
func (b *BitReader) ReadByte() (byte, error) {

	if b.count == 0 {
		n, err := b.r.Read(b.b[:])
		if n != 1 || (err != nil && err != io.EOF) {
			b.b[0] = 0
			return b.b[0], err
		}
		// mask io.EOF for the last byte
		if err == io.EOF {
			err = nil
		}
		return b.b[0], err
	}

	byt := b.b[0]

	var n int
	var err error
	n, err = b.r.Read(b.b[:])
	if n != 1 || (err != nil && err != io.EOF) {
		return 0, err
	}

	byt |= b.b[0] >> b.count

	b.b[0] <<= (8 - b.count)

	return byt, err
}
724529
func (r *buffer) Read(b []byte) (int, error) {
	if r.off >= r.size {
		return 0, io.EOF
	}
	if n := r.size - r.off; len(b) > n {
		b = b[:n]
	}
	n := copy(b, r.data[r.off:])
	r.off += n
	return n, nil
}
118773
func (b *ByteBuf) ReadBytes(n int) (int, []byte, error) {
	data := make([]byte, n)
	n, err := b.Read(data)
	return n, data, err
}
720767
func (r *Rand) Bytes(n int) []byte {
	// cRandBytes isn't guaranteed to be fast so instead
	// use random bytes generated from the internal PRNG
	bs := make([]byte, n)
	for i := 0; i < len(bs); i++ {
		bs[i] = byte(r.Int() & 0xFF)
	}
	return bs
}
1240987
func RemoveByte(data []byte, c byte) []byte {
	j := bytes.IndexByte(data, c)
	if j == -1 {
		return data
	}

	n := len(data) - 1

	// If character is present, than allocate slice with n-1 capacity. That is,
	// resulting bytes could be at most n-1 length.
	result := make([]byte, n)
	k := copy(result, data[:j])

	for i := j + 1; i < n; {
		j = bytes.IndexByte(data[i:], c)
		if j != -1 {
			k += copy(result[k:], data[i:i+j])
			i = i + j + 1
		} else {
			k += copy(result[k:], data[i:])
			break
		}
	}

	return result[:k]
}
1098154
func (c *ChannelsHistoryCall) Unreads(unreads bool) *ChannelsHistoryCall {
	c.unreads = unreads
	return c
}
1274529
func (r *unsynchroniser) Read(p []byte) (int, error) {
	b := make([]byte, 1)
	i := 0
	for i < len(p) {
		if n, err := r.Reader.Read(b); err != nil || n == 0 {
			return i, err
		}
		if r.ff && b[0] == 0x00 {
			r.ff = false
			continue
		}
		p[i] = b[0]
		i++
		r.ff = (b[0] == 0xFF)
	}
	return i, nil
}
1006988
func (r *Reader) Unread(p Packet) {
	r.q = append(r.q, p)
}
1233060
func (pr *Reader) Flush() (int64, error) {
	if pr.bufRd == nil {
		return pr.Offset, nil
	}

	// Update the number of total bits to discard.
	pr.discardBits += int(pr.fedBits - pr.numBits)
	pr.fedBits = pr.numBits

	// Discard some bytes to update read offset.
	var err error
	nd := (pr.discardBits + 7) / 8 // Round up to nearest byte
	nd, err = pr.bufRd.Discard(nd)
	pr.discardBits -= nd * 8 // -7..0
	pr.Offset += int64(nd)

	// These are invalid after Discard.
	pr.bufPeek = nil
	return pr.Offset, err
}
1173563
func (r *OffsetReaderAt) ReadMemory(buf []byte, addr uintptr) (n int, err error) {
	return r.reader.ReadAt(buf, int64(addr-r.offset))
}
722222
func (r *Reader) ReadNumBytesString(n int) (string, error) {
	b, err := r.ReadNumBytes(n)
	return string(b), err
}