// ReadInt reads an int value. Returns a decoded value and an error if it occurs.
437245
func (bd *BinaryDecoder) ReadInt() (int32, error) {
	if err := checkEOF(bd.buf, bd.pos, 1); err != nil {
		return 0, EOF
	}
	var value uint32
	var b uint8
	var offset int
	bufLen := int64(len(bd.buf))

	for {
		if offset == maxIntBufSize {
			return 0, IntOverflow
		}

		if bd.pos >= bufLen {
			return 0, InvalidInt
		}

		b = bd.buf[bd.pos]
		value |= uint32(b&0x7F) << uint(7*offset)
		bd.pos++
		offset++
		if b&0x80 == 0 {
			break
		}
	}
	return int32((value >> 1) ^ -(value & 1)), nil
}
106654
func readInteger(typ byte, kind reflect.Kind, b []byte) interface{} {
	switch kind {
	case reflect.Uint8:
		return b[len(b)-1]
	case reflect.Uint16:
		return binary.BigEndian.Uint16(b[len(b)-2:])
	case reflect.Uint32:
		return binary.BigEndian.Uint32(b[len(b)-4:])
	case reflect.Uint64:
		return binary.BigEndian.Uint64(b[len(b)-8:])
	case reflect.Int8:
		return int8(b[len(b)-1])
	case reflect.Int16:
		return int16(binary.BigEndian.Uint16(b[len(b)-2:]))
	case reflect.Int32:
		return int32(binary.BigEndian.Uint32(b[len(b)-4:]))
	case reflect.Int64:
		return int64(binary.BigEndian.Uint64(b[len(b)-8:]))
	default:
		// the only case lefts for integer is int256/uint256.
		// big.SetBytes can't tell if a number is negative, positive on itself.
		// On EVM, if the returned number > max int256, it is negative.
		ret := new(big.Int).SetBytes(b)
		if typ == UintTy {
			return ret
		}

		if ret.Cmp(maxInt256) > 0 {
			ret.Add(maxUint256, big.NewInt(0).Neg(ret))
			ret.Add(ret, big.NewInt(1))
			ret.Neg(ret)
		}
		return ret
	}
}
490102
func ReadVarInt32(r io.Reader) (int32, error) {
	i64, err := ReadVarInt64(r)
	if err != nil {
		return 0, err
	}
	return int32(i64), nil
}
204706
func GetInt(key string) (int, error) {
	value, err := Get(key)
	if err != nil {
		return 0, err
	}
	if v, ok := value.(int); ok {
		return v, nil
	} else if v, ok := value.(string); ok {
		if i, err := strconv.ParseInt(v, 10, 64); err == nil {
			return int(i), nil
		}
	} else if v, err := GetFloat(key); err == nil {
		if float64(int(v)) == v {
			return int(v), nil
		}
	}
	return 0, &InvalidValue{key, "int"}
}
47683
func (c *Config) ReadIntDefault(id string, defaultValue int) int {
	val, err := c.ReadInt(id)
	if err != nil {
		return defaultValue
	}
	return val
}
765458
func (reader *PluginConfigReader) GetInt(key string, defaultValue int64) int64 {
	value, err := reader.WithError.GetInt(key, defaultValue)
	reader.Errors.Push(err)
	return value
}
852071
func (reader PluginConfigReaderWithError) GetInt(key string, defaultValue int64) (int64, error) {
	key = reader.config.registerKey(key)
	if reader.HasValue(key) {
		if strVal, err := reader.config.Settings.String(key); err == nil {
			return tstrings.AtoI64(strVal) // Allow string to number conversion
		}
		return reader.config.Settings.Int(key)
	}
	return defaultValue, nil
}
1025648
func ToInt(in interface{}) (int, error) {
	if val, err := cast.ToIntE(in); err == nil {
		return val, nil
	}
	return 0, ErrBadType
}
239906
func (enc *Encoder) encodeInt(n int) ([]byte, error) {
	enc.buf = strconv.AppendInt(enc.buf, int64(n), 10)
	return enc.buf, nil
}
1298450
func (v *Value) StoreInt(i int) {
	*v = Value{t: reflect.Int, i: i}
}
538290
func (iter *Iterator) ReadInt() int {
	if strconv.IntSize == 32 {
		return int(iter.ReadInt32())
	}
	return int(iter.ReadInt64())
}
247814
func (c *Config) GetInt(s string) int {
	return c.config.GetInt(s)
}
487678
func ReadInt(r io.Reader) (int, error) {
	var b [4]byte

	bs := b[:4]

	_, err := io.ReadFull(r, bs)
	if err != nil {
		return 0, err
	}
	return int(ByteOrder.Uint32(bs)), nil
}
48544
func (iter *Iterator) ReadUint() uint {
	if strconv.IntSize == 32 {
		return uint(iter.ReadUint32())
	}
	return uint(iter.ReadUint64())
}
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)
	}
}
1029564
func (node *Node) GetInt(key string) int {
	n, _ := strconv.Atoi(node.Values.Get(key))
	return n
}
640745
func (c *Config) ReadInt(id string) (int, error) {
	val, ok := c.Options[id]
	if !ok {
		return 0, fmt.Errorf("Specified config is missing from options")
	}
	ival, err := strconv.Atoi(val)
	if err != nil {
		return 0, fmt.Errorf("Failed to parse %s as int: %s", val, err)
	}
	return ival, nil
}