Hamlin wins Talladega after last-lap wreck