Two-gap model for underdoped cuprate superconductors