In the chloroplast, chlorophyll traps light energy and uses it to turn CO₂ and water into glucose, releasing oxygen.
In the mitochondrion, glucose is broken down using oxygen to release energy as ATP, giving off CO₂ and water.
With no oxygen, cells respire anaerobically for a little ATP: muscle → lactic acid (fatigue); yeast → ethanol + CO₂ (fermentation, used in bread & brewing).
What photosynthesis makes (glucose + O₂) is what respiration uses; what respiration makes (CO₂ + water) is what photosynthesis reuses. Matter cycles — but energy flows one way, from the Sun to heat.