Rafael Nadal reaches Stuttgart semis after struggle with Bernard Tomic