// coerce numbers to uint64
199352
func AsUint64Function(env *Zlisp, name string, args []Sexp) (Sexp, error) {
	if len(args) != 1 {
		return SexpNull, WrongNargs
	}

	var val uint64
	switch x := args[0].(type) {
	case *SexpInt:
		val = uint64(x.Val)
	case *SexpFloat:
		val = uint64(x.Val)
	default:
		return SexpNull, fmt.Errorf("Cannot convert %s to uint64", TypeOf(args[0]).SexpString(nil))

	}
	return &SexpUint64{Val: val}, nil
}
573590
func (regs *DwarfRegisters) Uint64Val(idx uint64) uint64 {
	reg := regs.Reg(idx)
	if reg == nil {
		return 0
	}
	return regs.Regs[idx].Uint64Val
}
569446
func (stream *Stream) WriteUint64(val uint64) {
	q1 := val / 1000
	if q1 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[val])
		return
	}
	r1 := val - q1*1000
	q2 := q1 / 1000
	if q2 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[q1])
		stream.buf = writeBuf(stream.buf, digits[r1])
		return
	}
	r2 := q1 - q2*1000
	q3 := q2 / 1000
	if q3 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[q2])
		stream.buf = writeBuf(stream.buf, digits[r2])
		stream.buf = writeBuf(stream.buf, digits[r1])
		return
	}
	r3 := q2 - q3*1000
	q4 := q3 / 1000
	if q4 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[q3])
		stream.buf = writeBuf(stream.buf, digits[r3])
		stream.buf = writeBuf(stream.buf, digits[r2])
		stream.buf = writeBuf(stream.buf, digits[r1])
		return
	}
	r4 := q3 - q4*1000
	q5 := q4 / 1000
	if q5 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[q4])
		stream.buf = writeBuf(stream.buf, digits[r4])
		stream.buf = writeBuf(stream.buf, digits[r3])
		stream.buf = writeBuf(stream.buf, digits[r2])
		stream.buf = writeBuf(stream.buf, digits[r1])
		return
	}
	r5 := q4 - q5*1000
	q6 := q5 / 1000
	if q6 == 0 {
		stream.buf = writeFirstBuf(stream.buf, digits[q5])
	} else {
		stream.buf = writeFirstBuf(stream.buf, digits[q6])
		r6 := q5 - q6*1000
		stream.buf = writeBuf(stream.buf, digits[r6])
	}
	stream.buf = writeBuf(stream.buf, digits[r5])
	stream.buf = writeBuf(stream.buf, digits[r4])
	stream.buf = writeBuf(stream.buf, digits[r3])
	stream.buf = writeBuf(stream.buf, digits[r2])
	stream.buf = writeBuf(stream.buf, digits[r1])
}
809952
func Uint64(v []byte, err error) (uint64, error) {
	if err != nil {
		return 0, err
	} else if v == nil || len(v) == 0 {
		return 0, nil
	} else if len(v) != 8 {
		return 0, errIntNumber
	}

	return binary.LittleEndian.Uint64(v), nil
}
1152237
func (k *Key) Uint64s(delim string) []uint64 {
	vals, _ := k.parseUint64s(k.Strings(delim), true, false)
	return vals
}
581708
func UInt64() (i uint64) {
	randomBits(r)
	buf := bytes.NewBuffer(r)
	binary.Read(buf, binary.LittleEndian, &i)
	return i
}
1074145
func UInt64s(input []uint64) []uint64 {
	u := make([]uint64, 0, len(input))
	m := make(map[uint64]bool)

	for _, val := range input {
		if _, ok := m[val]; !ok {
			m[val] = true
			u = append(u, val)
		}
	}

	return u
}
805159
func parseInt64(d []byte) (n int64) {
	if len(d) == 0 {
		return -1
	}
	for _, dec := range d {
		if dec < ascii_0 || dec > ascii_9 {
			return -1
		}
		n = n*10 + (int64(dec) - ascii_0)
	}
	return n
}
876474
func (f *Forms) Uint64(key string) (uint64, error) {
	return strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64)
}
624984
func ToUint64(v Value) (uint64, error) {
	num, err := newIntegralNumeric(v)
	if err != nil {
		return 0, err
	}
	switch num.typ {
	case Int64:
		if num.ival < 0 {
			return 0, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "negative number cannot be converted to unsigned: %d", num.ival)
		}
		return uint64(num.ival), nil
	case Uint64:
		return num.uval, nil
	}
	panic("unreachable")
}
1174590
func (p *parserMixin) Uint64() (target *uint64) {
	target = new(uint64)
	p.Uint64Var(target)
	return
}
996711
func (s *Session) Uint64(key string) uint64 {
	s.RLock()
	defer s.RUnlock()

	v, ok := s.data[key]
	if !ok {
		return 0
	}

	value, ok := v.(uint64)
	if !ok {
		return 0
	}
	return value
}
777229
func Uint64Tobytes(d uint64) []byte {
	data := make([]byte, 8)
	offset := 7
	for i := 7; i >= 0; i-- {
		data[offset-i] = byte((d >> uint(i*8)) & 0xff)
	}
	return data
}
1249735
func randUint64(r *rand.Rand) uint64 {
	return uint64(r.Uint32())<<32 | uint64(r.Uint32())
}
729659
func CoerceUint(v interface{}) (uint64, error) {
	u64, ok := valToUint64(v)
	if !ok {
		return 0, fmt.Errorf("Could not Coerce %v", v)
	}
	return u64, nil
}
1344689
func (be *BinaryEncoder) WriteInt64(value int64) {
	binary.BigEndian.PutUint64(be.buffer[be.pos:], uint64(value))
	be.pos += 8
}
1185505
func (c *Context) Uint64(name string) uint64 {
	return lookupUint64(name, c.flagSet)
}