From stellar nucleosynthesis
Among the elements found naturally on Earth the so-called primordial elementsthose heavier than boron were created by stellar nucleosynthesis and by supernova nucleosynthesis.
In order to create a terrestrial planet like the Earth and life on such a planetenough of the heavy elements have to be created in previous generations of stars and then concentrated in the interstellar clouds to collect into sizable chunks around forming stars.
At this stage Hydrogen occupies the outer layer which expands because of temperature increase. Stars around the mass of our Sun can synthesize helium, carbon, and oxygen.
Monthly Notices of the Royal Astronomical Society Despite the name, stars on a blue loop from the red giant branch are typically not blue in color, but are rather yellow giants, possibly Cepheid variables.