I think he had an eye on GC from the start, or at the very least wanted it badly after yesterday. He wouldn't have put himself into the red like that if he wasn't very serious about it, and there's no way Nibali, one of the biggest stars in cycling, would have been working like a dog for him if the team didn't think he could do it.
I really don't think he can be written off when he's just three seconds off the win. So no, he'll hardly be crying into his cornflakes with 2 stage wins, 2nd in GC and probably the points jersey, but unless he's wrecked himself entirely trying to cling onto Martin today, I suspect he'll be fighting hard for the GC tomorrow. Also, he needs to contest the final sprint to guarantee Green too.