// A rope is balanced if its length <= fib(depth).
481013
func (r Rope) isBalanced() bool {
	if r.node == nil || r.node == emptyNode {
		return true
	}

	len := r.Len()
	maxDepth := reverseFib(len)
	return int(r.node.depth()) <= maxDepth
}
159103
func Equal(fid1, fid2 FID) bool {
	return fid1.IDLow == fid2.IDLow && fid1.IDHigh == fid2.IDHigh
}
563294
func Fib() func() time.Duration {
	a, b := 0, 1
	return func() time.Duration {
		a, b = b, a+b
		return time.Duration(a) * time.Second
	}
}
1127953
func Fibonacci() func() int {
	a, b := 0, 1
	return func() int {
		a, b = b, a+b
		return a
	}
}
511669
func (r Rope) Repeat(count int64) Rope {
	// Special cases:
	switch count {
	case 0:
		return emptyRope
	case 1:
		return r
	}

	// General case:
	orig := r
	r = r.Repeat(count / 2)
	r = r.Append(r)
	if count%2 == 1 {
		return r.Append(orig)
	}
	return balanced(r)
}
1364224
func (f Flipper) Flip(s string) string {
	return string(f) + UpsideDown(s)
}
3054
func New(arg string) Rope {
	if len(arg) == 0 {
		return emptyRope
	}
	return Rope{
		node: leaf(arg),
	}
}
640147
func (s *SkeinMac) DoFinal() (hash []byte) {
    hash = s.skein.DoFinal()
    s.Reset()
    return
}
875668
func Div(a, b []float32) {
	b = b[:len(a)]
	for i, v := range a {
		if b[i] == 0 {
			a[i] = math32.Inf(0)
			continue
		}

		a[i] = v / b[i]
	}
}
433721
func (o *AroundRadiusOption) Equal(o2 *AroundRadiusOption) bool {
	if o2 == nil {
		return !o.isAll && o.meters == 0
	}
	return reflect.DeepEqual(o, o2)
}
657457
func (api *KrakenApi) Balance() (*BalanceResponse, error) {
	resp, err := api.queryPrivate("Balance", url.Values{}, &BalanceResponse{})
	if err != nil {
		return nil, err
	}

	return resp.(*BalanceResponse), nil
}
1164623
func fibonacci() func() int {
	f, g := 1, 0
	return func() int {
		f, g = g, f+g
		return f
	}
}
1038050
func (tree *MutableTree) balance(node *Node) (newSelf *Node, orphaned []*Node) {
	if node.persisted {
		panic("Unexpected balance() call on persisted node")
	}
	balance := node.calcBalance(tree.ImmutableTree)

	if balance > 1 {
		if node.getLeftNode(tree.ImmutableTree).calcBalance(tree.ImmutableTree) >= 0 {
			// Left Left Case
			newNode, orphaned := tree.rotateRight(node)
			return newNode, []*Node{orphaned}
		}
		// Left Right Case
		var leftOrphaned *Node

		left := node.getLeftNode(tree.ImmutableTree)
		node.leftHash = nil
		node.leftNode, leftOrphaned = tree.rotateLeft(left)
		newNode, rightOrphaned := tree.rotateRight(node)

		return newNode, []*Node{left, leftOrphaned, rightOrphaned}
	}
	if balance < -1 {
		if node.getRightNode(tree.ImmutableTree).calcBalance(tree.ImmutableTree) <= 0 {
			// Right Right Case
			newNode, orphaned := tree.rotateLeft(node)
			return newNode, []*Node{orphaned}
		}
		// Right Left Case
		var rightOrphaned *Node

		right := node.getRightNode(tree.ImmutableTree)
		node.rightHash = nil
		node.rightNode, rightOrphaned = tree.rotateRight(right)
		newNode, leftOrphaned := tree.rotateLeft(node)

		return newNode, []*Node{right, leftOrphaned, rightOrphaned}
	}
	// Nothing changed
	return node, []*Node{}
}
399232
func (r *Router) depth() int {
	max := 0
	for _, child := range r.children {
		childDepth := child.depth()
		if childDepth > max {
			max = childDepth
		}
	}
	return max + 1
}
632387
func (c *compaction) trivial() bool {
	return len(c.levels[0]) == 1 && len(c.levels[1]) == 0 && c.gp.size() <= c.maxGPOverlaps
}
1314002
func (swap *Swap) Balance() int {
	defer swap.lock.Unlock()
	swap.lock.Lock()
	return swap.balance
}
398181
func IncrPow(a, b, incr []float64) {
	b = b[:len(a)]
	incr = incr[:len(a)]
	for i, v := range a {
		switch b[i] {
		case 0:
			incr[i]++
		case 1:
			incr[i] += v
		case 2:
			incr[i] += v * v
		case 3:
			incr[i] += v * v * v
		default:
			incr[i] += math.Pow(v, b[i])
		}
	}
}