Transformation of the superconducting gap to an insulating pseudogap at a critical hole density in the cuprates