Codimension-two integral cycles and $S^1$-valued functions with bounded higher variation