When you restore cracked materia that's on a piece of equipment, does it stay on that item or does the game automatically remove it?

I'm curious because I got a few items dirt cheap off the markets with cracked Tier IV in them, but I'm not sure if I can get the materia from them or not (13k for a Savage Aim IV is pretty baller!)

Otherwise I'll just sell it for the tomestones as they're also worth a fair bit of those.