julia> X = Tensor(SparseList(Element(0.0)), [1.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0])
SparseList (0.0) [1:7]
├─ [1]: 1.0
├─ [4]: 3.0
└─ [6]: 2.0

julia> x_min = Scalar(Inf)
Scalar{Inf, Float64}(Inf)
julia> x_max = Scalar(-Inf)
Scalar{-Inf, Float64}(-Inf)
julia> x_sum = Scalar(0.0)
Scalar{0.0, Float64}(0.0)
julia> x_var = Scalar(0.0)
Scalar{0.0, Float64}(0.0)
julia> @finch_code begin
        for i = _
            let x = X[i]
                x_min[] << min >>= x
                x_max[] << max >>= x
                x_sum[] += x
                x_var[] += x * x
            end
        end
    end
quote
    X_lvl = (ex.bodies[1]).body.rhs.tns.bind.lvl
    X_lvl_ptr = X_lvl.ptr
    X_lvl_idx = X_lvl.idx
    X_lvl_val = X_lvl.lvl.val
    x_min = ((ex.bodies[1]).body.body.bodies[1]).lhs.tns.bind
    x_min_val = x_min.val
    x_max = ((ex.bodies[1]).body.body.bodies[2]).lhs.tns.bind
    x_max_val = x_max.val
    x_sum = ((ex.bodies[1]).body.body.bodies[3]).lhs.tns.bind
    x_sum_val = x_sum.val
    x_var = ((ex.bodies[1]).body.body.bodies[4]).lhs.tns.bind
    x_var_val = x_var.val
    result = nothing
    X_lvl_q = X_lvl_ptr[1]
    X_lvl_q_stop = X_lvl_ptr[1 + 1]
    if X_lvl_q < X_lvl_q_stop
        X_lvl_i1 = X_lvl_idx[X_lvl_q_stop - 1]
    else
        X_lvl_i1 = 0
    end
    phase_stop = min(X_lvl_i1, X_lvl.shape)
    if phase_stop >= 1
        i = 1
        if X_lvl_idx[X_lvl_q] < 1
            X_lvl_q = Finch.scansearch(X_lvl_idx, 1, X_lvl_q, X_lvl_q_stop - 1)
        end
        while true
            X_lvl_i = X_lvl_idx[X_lvl_q]
            if X_lvl_i < phase_stop
                cond = 1 <= -i + X_lvl_i
                if cond
                    x_min_val = min(0.0, x_min_val)
                    x_max_val = max(0.0, x_max_val)
                end
                X_lvl_2_val = X_lvl_val[X_lvl_q]
                x_min_val = min(X_lvl_2_val, x_min_val)
                x_max_val = max(X_lvl_2_val, x_max_val)
                x_sum_val = X_lvl_2_val + x_sum_val
                x_var_val = X_lvl_2_val * X_lvl_2_val + x_var_val
                X_lvl_q += 1
                i = X_lvl_i + 1
            else
                phase_stop_3 = min(X_lvl_i, phase_stop)
                if X_lvl_i == phase_stop_3
                    cond_2 = 1 <= -i + phase_stop_3
                    if cond_2
                        x_min_val = min(0.0, x_min_val)
                        x_max_val = max(0.0, x_max_val)
                    end
                    X_lvl_2_val = X_lvl_val[X_lvl_q]
                    x_min_val = min(X_lvl_2_val, x_min_val)
                    x_max_val = max(X_lvl_2_val, x_max_val)
                    x_sum_val = X_lvl_2_val + x_sum_val
                    x_var_val = X_lvl_2_val * X_lvl_2_val + x_var_val
                    X_lvl_q += 1
                else
                    cond_3 = 1 <= 1 + -i + phase_stop_3
                    if cond_3
                        x_min_val = min(0.0, x_min_val)
                        x_max_val = max(0.0, x_max_val)
                    end
                end
                i = phase_stop_3 + 1
                break
            end
        end
    end
    phase_start_3 = max(1, 1 + X_lvl_i1)
    phase_stop_4 = X_lvl.shape
    if phase_stop_4 >= phase_start_3
        cond_4 = 1 <= 1 + -phase_start_3 + phase_stop_4
        if cond_4
            x_min_val = min(0.0, x_min_val)
            x_max_val = max(0.0, x_max_val)
        end
    end
    result = ()
    x_var.val = x_var_val
    x_sum.val = x_sum_val
    x_max.val = x_max_val
    x_min.val = x_min_val
    result
end

