def METHOD_NAME(points, means, labels):
    def loop_kernel(labels):
        # assign cluster
        with hcl.for_(0, N, name="n") as n:
            min_dist = hcl.scalar(100000)
            new_label = hcl.scalar(labels[n])
            with hcl.for_(0, K) as k:
                dist = hcl.scalar(0)
                with hcl.for_(0, dim) as d:
                    dist_ = hcl.scalar(points[n, d] - means[k, d], "temp")
                    dist.v += dist_.v * dist_.v
                with hcl.if_(dist.v < min_dist.v):
                    min_dist.v = dist.v
                    new_label[0] = k
            labels[n] = new_label
        # update mean
        num_k = hcl.compute((K,), lambda x: 0, "num_k")
        sum_k = hcl.compute((K, dim), lambda x, y: 0, "sum_k")
        def calc_sum(n):
            num_k[labels[n]] += 1
            with hcl.for_(0, dim) as d:
                sum_k[labels[n], d] += points[n, d]
        hcl.mutate((N,), lambda n: calc_sum(n), "calc_sum")
        hcl.update(means, lambda k, d: sum_k[k, d] // num_k[k], "update_mean")
    hcl.mutate((niter,), lambda _: loop_kernel(labels), "main_loop")