// DecodeInt64 unhashes the string passed to an array of int64.
// It is symmetric with EncodeInt64 if the Alphabet and Salt are the same ones which were used to hash.
// MinLength has no effect on DecodeInt64.
348962
func (h *HashID) DecodeInt64WithError(hash string) ([]int64, error) {
	hashes := splitRunes([]rune(hash), h.guards)
	hashIndex := 0
	if len(hashes) == 2 || len(hashes) == 3 {
		hashIndex = 1
	}

	result := make([]int64, 0, 10)

	hashBreakdown := hashes[hashIndex]
	if len(hashBreakdown) > 0 {
		lottery := hashBreakdown[0]
		hashBreakdown = hashBreakdown[1:]
		hashes = splitRunes(hashBreakdown, h.seps)
		alphabet := duplicateRuneSlice(h.alphabet)
		buffer := make([]rune, len(alphabet)+len(h.salt)+1)
		for _, subHash := range hashes {
			buffer = buffer[:1]
			buffer[0] = lottery
			buffer = append(buffer, h.salt...)
			buffer = append(buffer, alphabet...)
			consistentShuffleInPlace(alphabet, buffer[:len(alphabet)])
			number, err := unhash(subHash, alphabet)
			if err != nil {
				return nil, err
			}
			result = append(result, number)
		}
	}

	sanityCheck, _ := h.EncodeInt64(result)
	if sanityCheck != hash {
		return result, fmt.Errorf("mismatch between encode and decode: %s start %s"+
			" re-encoded. result: %v", hash, sanityCheck, result)
	}

	return result, nil
}
292332
func (e *encoding) decode(s string) uint64 {
	x := uint64(0)
	for i := 0; i < len(s); i++ {
		x = (x << 5) | uint64(e.dec[s[i]])
	}
	return x
}
861850
func minUint64(ints ...uint64) uint64 {
	minInt := ints[0]
	for i := 1; i < len(ints); i++ {
		if ints[i] < minInt {
			minInt = ints[i]
		}
	}

	return minInt
}
1175620
func (c Context) Int64(key string, i int64) Context {
	c.l.context = enc.AppendInt64(enc.AppendKey(c.l.context, key), i)
	return c
}
1137509
func (h *HashID) Decode(hash string) []int {
	result, err := h.DecodeWithError(hash)
	if err != nil {
		panic(err)
	}
	return result
}
586675
func decodeInt64(rd *bufio.Reader) (string, Int64, error) {
	// name
	name, err := readCstring(rd)
	if err != nil {
		return "", 0, err
	}

	// value
	i64, err := readInt64(rd)
	if err != nil {
		return "", 0, err
	}
	return name, Int64(i64), nil
}
26956
func (p *Parser) ParseUInt64() (uint64, error) {
	tok, pos, lit := p.ScanIgnoreWhitespace()
	if tok != INTEGER {
		return 0, newParseError(tokstr(tok, lit), []string{"integer"}, pos)
	}

	// Convert string to unsigned 64-bit integer
	n, err := strconv.ParseUint(lit, 10, 64)
	if err != nil {
		return 0, &ParseError{Message: err.Error(), Pos: pos}
	}

	return uint64(n), nil
}
460847
func (dec *Decoder) Uint64(v *uint64) error {
	err := dec.decodeUint64(v)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
349379
func Base64Decode(b []byte) ([]byte, error) {
	buf := make([]byte, base64.RawURLEncoding.DecodedLen(len(b)))
	n, err := base64.RawURLEncoding.Decode(buf, b)
	return buf[:n], err
}
620758
func decodeBase64(s string) ([]byte, error) {
	for i := 0; i < len(s)%4; i++ {
		s += "="
	}
	return base64.URLEncoding.DecodeString(s)
}
632361
func (dec *Decoder) Int64(v *int64) error {
	err := dec.decodeInt64(v)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
20570
func (p *Params) Uint64(key string) (uint64, error) {
	return strconv.ParseUint(p.Get(key), 10, 64)
}
98314
func base64Decode(s string) ([]byte, error) {
	// add back missing padding
	switch len(s) % 4 {
	case 2:
		s += "=="
	case 3:
		s += "="
	}
	return base64.URLEncoding.DecodeString(s)
}
173412
func (r *Encoder) EncodeInt64(x int64) error {
	_, err := r.w.Write([]byte{CHR_INT8})
	if err != nil {
		return err
	}
	return binary.Write(r.w, binary.BigEndian, x)
}
169820
func (enc *Encoder) Decode(id string) (uint64, error) {

	if id == "" {
		return 0, errors.New("base58: id should not be empty")
	}

	var n uint64
	for i := range id {
		u := enc.decodeMap[id[i]]
		if u < 0 {
			return 0, errors.New("base58: invalid character - " + string(id[i]))
		}
		n = n*58 + uint64(u)
	}

	return n, nil
}
479387
func Decode(h int64) (int32, int32) {
	var ry, rx int64
	var x, y int32
	t := h

	for s := int64(1); s < int64(n); s *= 2 {
		rx = 1 & (t / 2)
		ry = 1 & (t ^ rx)
		rotate(int32(s), int32(rx), int32(ry), &x, &y)
		x += int32(s * rx)
		y += int32(s * ry)
		t /= 4
	}

	return x, y
}
453435
func ReverseInt64(s []int64) []int64 {
	for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}