// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n)
// from the source in the context or the shared global source.
//
// It panics if n <= 0.
193702
func (l *Locking) Int63n(n int64) (v int64) {
	l.Lock()
	v = l.R.Int63n(n)
	l.Unlock()
	return
}
392421
func (ung UniformGenerator) Int32n(n int32) int32 {
	if n <= 0 {
		panic(fmt.Sprintf("Illegal parameter n: %d", n))
	}
	ung.mu.Lock()
	defer ung.mu.Unlock()
	return ung.rd.Int31n(n)
}
659921
func (tr Row) Uint64(nn int) (val uint64) {
	val, err := tr.Uint64Err(nn)
	if err != nil {
		panic(err)
	}
	return
}
405017
func maxInt64(ints ...int64) int64 {
	maxInt := ints[0]
	for i := 1; i < len(ints); i++ {
		if ints[i] > maxInt {
			maxInt = ints[i]
		}
	}

	return maxInt
}
579051
func _int64(i interface{}) (int64, bool) {

	switch v := i.(type) {

	case int:
		return int64(v), true
	case int8:
		return int64(v), true
	case int16:
		return int64(v), true
	case int32:
		return int64(v), true
	case int64:
		return v, true
	case uint:
		return int64(v), true
	case uint8:
		return int64(v), true
	case uint16:
		return int64(v), true
	case uint32:
		return int64(v), true
	case uint64:
		return int64(v), true
	}

	return 0, false
}
1087025
func (tr Row) Int64(nn int) (val int64) {
	val, err := tr.Int64Err(nn)
	if err != nil {
		panic(err)
	}
	return
}
77484
func (r *Rand) Int() int {
	u := uint(r.Int63())
	return int(u << 1 >> 1) // clear sign bit if int == int32
}
1272328
func MinUint8N(v ...uint8) uint8 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinUint8(v[0], v[1])
	default:
		l := len(v) / 2
		return MinUint8N(MinUint8N(v[:l]...), MinUint8N(v[l:]...))
	}
}
20708
func (p *GenParameters) NextInt64() int64 {
	v := p.Rng.Int63()
	if p.NextBool() {
		return -v
	}
	return v
}
1147397
func Min3Int64(a, b, c int64) int64 {
	min := a
	if b < min {
		min = b
	}
	if c < min {
		min = c
	}
	return min
}
1240135
func Uint24(n uint32) []byte {
	out := make([]byte, 3)
	out[2] = byte(n & 0xFF)
	out[1] = byte(n >> 8)
	out[0] = byte(n >> 16)
	return out
}
661233
func MinInt8N(v ...int8) int8 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinInt8(v[0], v[1])
	default:
		l := len(v) / 2
		return MinInt8N(MinInt8N(v[:l]...), MinInt8N(v[l:]...))
	}
}
681530
func randInt() uint32 {
	b := make([]byte, 3)
	if _, err := rand.Reader.Read(b); err != nil {
		panic(fmt.Errorf("xid: cannot generate random number: %v;", err))
	}
	return uint32(b[0])<<16 | uint32(b[1])<<8 | uint32(b[2])
}
401461
func (l *Locking) Int63() (v int64) {
	l.Lock()
	v = l.R.Int63()
	l.Unlock()
	return
}
1274875
func MinUint64N(v ...uint64) uint64 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinUint64(v[0], v[1])
	default:
		l := len(v) / 2
		return MinUint64N(MinUint64N(v[:l]...), MinUint64N(v[l:]...))
	}
}
377766
func RandRangeInt64(min, max int64) int64 {
	if min >= max || min == 0 || max == 0 {
		return max
	}
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	return r.Int63n(max-min) + min
}
322340
func (pcg *Pcg128x64) NextN(bounds uint64) uint64 {
  threshold := (0 - bounds) % bounds
  for {
    result := pcg.Next()
    if result >= threshold {
      return result % bounds;
    }
  }
}