// FixInt returns a fixed size int64
971334
func (r *Reply) FixInt() (int64, error) {
	if r.Type() == ReplyNil {
		return 0, ErrNil
	}
	if r.Type() != ReplyString {
		return 0, ErrType
	}
	return ToFixInt(r.stringValue)
}
271107
func (cache *Cache) SetInt(key int64, value []byte, expireSeconds int) (err error) {
	var bKey [8]byte
	binary.LittleEndian.PutUint64(bKey[:], uint64(key))
	return cache.Set(bKey[:], value, expireSeconds)
}
336063
func (w *huffmanBitWriter) fixedSize(extraBits int) int {
	return 3 +
		fixedLiteralEncoding.bitLength(w.literalFreq) +
		fixedOffsetEncoding.bitLength(w.offsetFreq) +
		extraBits
}
510956
func (c *ConfigFile) Int64(section, key string) (int64, error) {
	value, err := c.GetValue(section, key)
	if err != nil {
		return 0, err
	}
	return strconv.ParseInt(value, 10, 64)
}
654114
func (it *Fixed) Size() (int64, bool) {
	return int64(len(it.values)), true
}
950341
func readInt(b string) uint64 {
	switch len(b) {
	case 8: // 64 bit
		return uint64(uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
			uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56)
	}

	panic(fmt.Sprintf("mc: don't know how to parse string with %d bytes", len(b)))
}
1185397
func DivUintWithInt(a uint64, b int64) (uint64, error) {
	if b < 0 {
		if a != 0 && uint64(-b) <= a {
			return 0, errors.Trace(ErrArithOverflow)
		}

		return 0, nil
	}

	return a / uint64(b), nil
}
391360
func AddInt64(a int64, b int64) (int64, error) {
	if (a > 0 && b > 0 && math.MaxInt64-a < b) ||
		(a < 0 && b < 0 && math.MinInt64-a > b) {
		return 0, ErrOverflow.GenWithStackByArgs("BIGINT", fmt.Sprintf("(%d, %d)", a, b))
	}

	return a + b, nil
}
752109
func (c *Distconf) Int(key string, defaultVal int64) *Int {
	c.grabInfo(key)
	s := &intConf{
		defaultVal: defaultVal,
		Int: Int{
			currentVal: defaultVal,
		},
	}
	// Note: in race conditions 's' may not be the thing actually returned
	ret, okCast := c.createOrGet(key, s).(*intConf)
	if !okCast {
		c.Logger.Log(logkey.DistconfKey, key, "Registering key with multiple types!  FIX ME!!!!")
		return nil
	}
	return &ret.Int
}
935925
func (l *Locking) Int31() (v int32) {
	l.Lock()
	v = l.R.Int31()
	l.Unlock()
	return
}
74164
func (self *Config) Int(section string, option string) (value int, err error) {
	sv, err := self.String(section, option)
	if err == nil {
		value, err = strconv.Atoi(sv)
	}

	return value, err
}
210539
func (p *allocator) ReleaseInt(item int) {
	if len(p.allocate) == cap(p.allocate) || item == 0 {
		return
	}

	p.allocate <- item
}
383662
func Int(args []string, index int, def int) (int, error) {
	if len(args) <= index {
		return def, nil
	}

	return strconv.Atoi(args[index])
}
978535
func (e *Encoder) EncodeInt(n int64) error {
	if n >= 0 {
		return e.EncodeUint(uint64(n))
	}
	if n >= int64(int8(codes.NegFixedNumLow)) {
		return e.w.WriteByte(byte(n))
	}
	if n >= math.MinInt8 {
		return e.EncodeInt8(int8(n))
	}
	if n >= math.MinInt16 {
		return e.EncodeInt16(int16(n))
	}
	if n >= math.MinInt32 {
		return e.EncodeInt32(int32(n))
	}
	return e.EncodeInt64(int64(n))
}
538290
func (iter *Iterator) ReadInt() int {
	if strconv.IntSize == 32 {
		return int(iter.ReadInt32())
	}
	return int(iter.ReadInt64())
}
164152
func (m MetricType) resolveInt(val interface{}) interface{} {
	if vi, isInt := val.(int); isInt {
		switch m {
		case Int64Type:
			return int64(vi)
		case Uint32Type:
			return uint32(vi)
		case Uint64Type:
			return uint64(vi)
		}
		return int32(val.(int))
	}

	if vui, isUint := val.(uint); isUint {
		if m == Uint64Type {
			return uint64(vui)
		}
		return uint32(vui)
	}

	return val
}
780008
func RatioInt(x1, y1, x2, y2 int) (int, int) {
	if x2 > 0 && y2 > 0 {
		return x2, y2
	} else if x2 <= 0 && y2 <= 0 {
		return x1, y1
	} else if x2 <= 0 {
		return int((float64(x1) / float64(y1)) * float64(y2)), y2
	} else if y2 <= 0 {
		return x2, int((float64(y1) / float64(x1)) * float64(x2))
	}
	return x2, y2
}