Smith rallies to beat McIlroy at British Open for 1st major