// Convert a string to an int32
196736
func atoi32(s string) (int32, error) {
	n, err := strconv.ParseInt(s, 0, 32)
	if err != nil {
		return 0, err
	}
	return int32(n), nil
}
310433
func (iter *Iterator) ReadInt32() (ret int32) {
	c := iter.nextToken()
	if c == '-' {
		val := iter.readUint32(iter.readByte())
		if val > math.MaxInt32+1 {
			iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
			return
		}
		return -int32(val)
	}
	val := iter.readUint32(c)
	if val > math.MaxInt32 {
		iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
		return
	}
	return int32(val)
}
200706
func (w *Writer) WriteInt32(sample int32) error {
	err := binary.Write(w.sampleBuf, binary.LittleEndian, sample)
	if err != nil {
		return err
	}

	w.bytesWritten += 4

	return err
}
215492
func AsInt32(x Value) (int, error) {
	i, ok := x.(Int)
	if !ok {
		return 0, fmt.Errorf("got %s, want int", x.Type())
	}
	if i.bigint.BitLen() <= 32 {
		v := i.bigint.Int64()
		if v >= math.MinInt32 && v <= math.MaxInt32 {
			return int(v), nil
		}
	}
	return 0, fmt.Errorf("%s out of range", i)
}
628806
func (r *reader) readVarInt32() int32 {
	ux := r.readVarUint32()
	x := int32(ux >> 1)
	if ux&1 != 0 {
		x = ^x
	}
	return x
}
489880
func toInt32(value Value) int32 {
	{
		switch value := value.value.(type) {
		case int8:
			return int32(value)
		case int16:
			return int32(value)
		case int32:
			return value
		}
	}
	floatValue := value.float64()
	if math.IsNaN(floatValue) || math.IsInf(floatValue, 0) {
		return 0
	}
	if floatValue == 0 { // This will work for +0 & -0
		return 0
	}
	remainder := math.Mod(floatValue, float_2_32)
	if remainder > 0 {
		remainder = math.Floor(remainder)
	} else {
		remainder = math.Ceil(remainder) + float_2_32
	}
	if remainder > float_2_31 {
		return int32(remainder - float_2_32)
	}
	return int32(remainder)
}
1358843
func (e *Entity) GetInt32(name string) (int32, bool) {
	x, ok := e.Get(name).(int32)
	return x, ok
}
883042
func (w *ByteWriter) WriteInt32(val int32, offset int) (int, error) {
	return w.WriteVal(val, offset)
}
310598
func (e *Encoder) EncodeInt32(n int32) error {
	return e.write4(codes.Int32, uint32(n))
}
1179719
func varint32(value int) []byte {
	buf := make([]byte, binary.MaxVarintLen32)
	n := binary.PutUvarint(buf, uint64(value))
	return buf[:n]
}
343749
func Convert_Slice_string_To_Slice_int32(in *[]string, out *[]int32, s conversion.Scope) error {
	for _, s := range *in {
		for _, v := range strings.Split(s, ",") {
			x, err := strconv.ParseUint(v, 10, 16)
			if err != nil {
				return fmt.Errorf("cannot convert to []int32: %v", err)
			}
			*out = append(*out, int32(x))
		}
	}
	return nil
}
690274
func (b byteReader) Int32() int32 {
	v3 := int32(b.b[b.off+3])
	v2 := int32(b.b[b.off+2])
	v1 := int32(b.b[b.off+1])
	v0 := int32(b.b[b.off])
	return (v3 << 24) | (v2 << 16) | (v1 << 8) | v0
}
181787
func StringToInt16(from string) (int16, error) {
	val, err := strconv.ParseInt(from, DefeultNumericBase, 16)
	return int16(val), err
}
683987
func convertToInt(val interface{}) (int, error) {
	var intVal int
	var floatVal float64
	var ok bool

	intVal, ok = val.(int)
	if ok {
		return intVal, nil
	}

	floatVal, ok = val.(float64)
	if ok {
		return int(floatVal), nil
	}

	return 0, fmt.Errorf("failed to convert to int value")
}
1339993
func StrInt32(v []byte, err error) (int32, error) {
	if err != nil {
		return 0, err
	} else if v == nil {
		return 0, nil
	} else {
		res, err := strconv.ParseInt(hack.String(v), 10, 32)
		return int32(res), err
	}
}
259065
func (p *TCompactProtocol) readVarint32() (int32, error) {
	// if the wire contains the right stuff, this will just truncate the i64 we
	// read and get us the right sign.
	v, err := p.readVarint64()
	return int32(v), err
}
7225
func (b byteReader) Int32() int32 {
	b2 := b.b[b.off : b.off+4 : b.off+4]
	v3 := int32(b2[3])
	v2 := int32(b2[2])
	v1 := int32(b2[1])
	v0 := int32(b2[0])
	return v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)
}