Performance of CMS muon reconstruction in cosmic-ray events