Complex poles and spectral function of Yang-Mills theory