XY model on the circle: Diagonalization, spectrum, and forerunners of the quantum phase transition