World number three Simona Halep fought back from a set down to beat Garbine Muguruza in the second round of the Porsche Tennis Grand Prix in Stuttgart.