// Detect the highest Z position
961899
func (vm *Machine) FindSafetyHeight() float64 {
	var maxz float64
	for _, m := range vm.Positions {
		if m.Z > maxz {
			maxz = m.Z
		}
	}
	return maxz
}
534317
func Detect(src string) (string, error) {
	// Apparently, golang can't detect bzip mimetype :/

	if isbz2(src) {
		return "application/x-bzip2", nil
	}

	file, err := os.Open(src)
	if err != nil {
		return "", err
	}

	defer file.Close()

	data := make([]byte, 512)

	_, err = file.Read(data)

	if err != nil {
		return "", err
	}

	return http.DetectContentType(data), nil
}
1363050
func (ta *TrackAttributes) MaxMode(mode int) *TrackAttributes {
	ta.intAttributes["max_mode"] = mode
	return ta
}
1066169
func (w *Window) GetPos() (x, y int) {
	var xpos, ypos C.int
	C.glfwGetWindowPos(w.data, &xpos, &ypos)
	panicError()
	return int(xpos), int(ypos)
}
560956
func DefaultPof(max int) func(one, other Val, pos int) (int, bool) {
	return func(one, other Val, pos int) (int, bool) {
		po, eq := proximityOrder(ToBytes(one), ToBytes(other), pos)
		if po >= max {
			eq = true
			po = max
		}
		return po, eq
	}
}
635704
func (db *DB) RetrieveBestBlockHeight() (int64, error) {
	var blockHeight int64
	err := db.QueryRow(db.getBestBlockHeightSQL).Scan(&blockHeight)
	return blockHeight, err
}
623692
func DetectCompression(source []byte) Compression {
	for compression, m := range map[Compression][]byte{
		Bzip2: {0x42, 0x5A, 0x68},
		Gzip:  {0x1F, 0x8B, 0x08},
		Xz:    {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
	} {
		if len(source) < len(m) {
			logrus.Debugf("Len too short")
			continue
		}
		if bytes.Compare(m, source[:len(m)]) == 0 {
			return compression
		}
	}
	return Uncompressed
}
38045
func (c *cmdable) ZIncrXX(key string, member Z) *FloatCmd {
	const n = 4
	a := make([]interface{}, n+2)
	a[0], a[1], a[2], a[3] = "zadd", key, "incr", "xx"
	return c.zIncr(a, n, member)
}
1301236
func (r *Redis) ZScan(key string, cursor uint64, pattern string, count int) (uint64, []string, error) {
	args := packArgs("ZSCAN", key, cursor)
	if pattern != "" {
		args = append(args, "MATCH", pattern)
	}
	if count > 0 {
		args = append(args, "COUNT", count)
	}
	rp, err := r.ExecuteCommand(args...)
	if err != nil {
		return 0, nil, err
	}
	first, err := rp.Multi[0].StringValue()
	if err != nil {
		return 0, nil, err
	}
	next, err := strconv.ParseUint(first, 10, 64)
	if err != nil {
		return 0, nil, err
	}
	list, err := rp.Multi[1].ListValue()
	return next, list, err
}
953581
func (c *Config) MaxStatusHistorySizeMB() uint {
	// Value has already been validated.
	val, _ := utils.ParseSize(c.mustString(MaxStatusHistorySize))
	return uint(val)
}
716519
func (t Type) Upper() byte {
	o := make([]byte, 2)
	binary.BigEndian.PutUint16(o, uint16(t))

	return o[0]
}
1262437
func (db *SQLDB) GetLastBlockHeight() (uint64, error) {
	query := db.DBAdapter.LastBlockIDQuery()
	id := ""

	db.Log.Info("msg", "MAX ID", "query", query)

	if err := db.DB.QueryRow(query).Scan(&id); err != nil {
		db.Log.Info("msg", "Error selecting last block id", "err", err)
		return 0, err
	}
	height, err := strconv.ParseUint(id, 10, 64)
	if err != nil {
		return 0, fmt.Errorf("could not parse height from block ID: %v", err)
	}
	return height, nil
}
1268609
func FuzzReadSubTreesNoProof(data []byte) int {
	buildAndCompareTreesFromFuzz(data, math.MaxUint64)
	if len(data) > 2 {
		return 1
	}
	return 0
}
887673
func (pq *priorityQueue) peakTopPriority() (int64, error) {
	if len(*pq) > 0 {
		return (*pq)[0].priority, nil
	} else {
		return -1, fmt.Errorf("PriorityQueue is empty.  No top priority.")
	}
}
147110
func (window *Window) GetPosition() (x, y int32) {
	var _x, _y C.int
	C.SDL_GetWindowPosition(window.cptr(), &_x, &_y)
	return int32(_x), int32(_y)
}
1156249
func (sc *SpriteContainer) GetZIndex(s *Sprite) (int, error) {
	simlog.FuncIn()
	i, ok := sc.spriteNodePairs.Load(s)
	if !ok {
		return 0, fmt.Errorf("specified sprite [%p] not found", s)
	}
	sn := i.(*spriteNodePair)
	return sn.znode.ZIndex, nil
}
901611
func (p *TCompactProtocol) zigzagToInt32(n int32) int32 {
	u := uint32(n)
	return int32(u>>1) ^ -(n & 1)
}