Catastrophic rearrangement of a compact star due to the quark core formation