// ToInt convert the input string to an integer, or 0 if the input is not an integer.
16982
func ToInt(str string) (int64, error) {
	res, err := strconv.ParseInt(str, 0, 64)
	if err != nil {
		res = 0
	}
	return res, err
}
833244
func Int(v interface{}, err error) (int64, error) {
	if err != nil {
		return 0, err
	}
	vi, ok := v.(int64)
	if ok {
		return vi, nil
	}

	vbi, ok := v.(*big.Int)
	if ok {
		if vbi.BitLen() <= 63 {
			return vbi.Int64(), nil
		}
	}

	return 0, newWrongTypeError(v, vi)

}
1189108
func NumberToInt(n ast.Number) (*big.Int, error) {
	r, ok := new(big.Int).SetString(string(n), 10)
	if !ok {
		return nil, fmt.Errorf("illegal value")
	}
	return r, nil
}
247814
func (c *Config) GetInt(s string) int {
	return c.config.GetInt(s)
}
553722
func getInt(unk interface{}) int64 {
	switch i := unk.(type) {
	case int64:
		return i
	case float64:
		return int64(i)
	case string:
		v, err := strconv.ParseInt(i, 10, 64)
		if err != nil {
			return int64(0)
		}
		return v
	default:
		return int64(0)
	}
}
502368
func TryToInt(i interface{}) (r int, err error) {
	switch t := i.(type) {
	case nil:
		r = 0
	case int:
		r = t
	case *int:
		r = *t
	case int8:
		r = int(t)
	case int16:
		r = int(t)
	case int32:
		r = int(t)
	case int64:
		r = int(t)
	case uint:
		r = int(t)
	case uint8:
		r = int(t)
	case uint16:
		r = int(t)
	case uint32:
		r = int(t)
	case uint64:
		r = int(t)
	case float32:
		r = int(t)
	case float64:
		r = int(t)
	case bool:
		if t {
			r = 1
		}
	case string:
		r, err = strconv.Atoi(t)
	default:
		err = castError(i, "int")
	}
	return
}
693672
func (l *Locking) Int() (v int) {
	l.Lock()
	v = l.R.Int()
	l.Unlock()
	return
}
174808
func Int(short string, long string, value int, usage string) *int {
	flagVar := value
	return IntVar(&flagVar, short, long, value, usage)
}
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
}
954540
func IsInt(s string) bool {
	for i, c := range s {
		if (c < '0' || c > '9') && (c != '-' || i != 0) {
			return false
		}
	}
	return true
}
675909
func ConvertToInt(target string, def int) int {
	fo, err := strconv.Atoi(target)
	if err != nil {
		return def
	}
	return fo
}
1298857
func (num Number) Int() (int, bool) {
	i, err := json.Number(num).Int64()
	if err != nil {
		return 0, false
	}
	return int(i), true
}
633309
func Int(base int, min int, max int) Validator {
	return func(args []string) int {
		if len(args) == 0 {
			return -1
		}
		i, err := strconv.ParseInt(args[0], base, 0)
		if err != nil || int(i) < min || int(i) > max {
			return -1
		}
		return 1
	}
}
293641
func Int() gopter.Gen {
	return Int64Range(math.MinInt32, math.MaxInt32).
		Map(int64ToInt).
		WithShrinker(IntShrinker)
}
257853
func ToInt(n int) [4]byte {
	s := make([]byte, 4)
	binary.LittleEndian.PutUint32(s, uint32(n))
	a := [4]byte{}
	copy(a[:], s[:4])
	return a
}
337550
func (s *Session) Int(key string) int {
	s.RLock()
	defer s.RUnlock()

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

	value, ok := v.(int)
	if !ok {
		return 0
	}
	return value
}
363286
func stringToInt(b []byte) int {
	val := 0
	for i := range b {
		val *= 10
		val += int(b[i] - 0x30)
	}
	return val
}