// clampInt returns the number closest to x within the range min..max.
515214
func clampInt(x, min, max int) int {
	if x < min {
		return min
	}
	if x > max {
		return max
	}
	return x
}
941157
func (l *Limiter) GetMax() float64 {
	l.RLock()
	defer l.RUnlock()
	return l.max
}
592927
func (k *Key) RangeInt64(defaultVal, min, max int64) int64 {
	val := k.MustInt64()
	if val < min || val > max {
		return defaultVal
	}
	return val
}
372987
func valToInt(i interface{}) (int, bool) {
	i64, ok := valToInt64(i)
	if !ok {
		return -1, false
	}
	if i64 > MaxInt || i64 < MinInt {
		return -1, false
	}
	return int(i64), true
}
1317512
func (s *regexFcd) popInt() int {
	s.intDepth--
	return s.intStack[s.intDepth]
}
804336
func clamp(o float64, x0, x1 int) int {
	x := int(o + 0.5)
	if x < x0 {
		return x0
	}
	if x > x1 {
		return x1
	}
	return x
}
187712
func clamp(x float64) uint8 {
	v := int64(x + 0.5)
	if v > 255 {
		return 255
	}
	if v > 0 {
		return uint8(v)
	}
	return 0
}
678418
func clamp(x, x0, x1 float64) float64 {
	if x < x0 {
		return x0
	}
	if x > x1 {
		return x1
	}
	return x
}
1360377
func (lr *LockedRand) Int() (n int) {
	lr.lk.Lock()
	n = lr.r.Int()
	lr.lk.Unlock()
	return
}
1277588
func Int63nRange(min, max int64) int64 {
	rng.Lock()
	defer rng.Unlock()
	return rng.rand.Int63n(max-min) + min
}
6499
func (p *PortList) PopInt() int {
	i, err := strconv.Atoi(p.Pop())
	if err != nil {
		panic(err)
	}
	return i
}
375758
func FetchInt(vars map[string]interface{}, tags string) int {
	val, _ := FetchVal(vars, tags).(float64)
	return int(val)
}
212852
func Integer() *IntegerConstraint {
	c := &IntegerConstraint{}
	c.applyMinimum = false
	c.applyMaximum = false
	return c
}
782231
func (d *MyDecimal) FromInt(val int64) *MyDecimal {
	var uVal uint64
	if val < 0 {
		d.negative = true
		uVal = uint64(-val)
	} else {
		uVal = uint64(val)
	}
	return d.FromUint(uVal)
}
1006405
func (d *Context) PushInt(val int) {
	C.duk_push_int(d.duk_context, C.duk_int_t(val))
}
836967
func (cm *circuitMap) NumOpen() int {
	cm.mtx.RLock()
	defer cm.mtx.RUnlock()

	return len(cm.opened)
}
208839
func Clamp(_min, _max, v int) int {
	return Max(_min, Min(_max, v))
}