All plants are capable of producing their own organic material in the form of sugars (carbohydrate), from water, carbon dioxide and light energy. This is photosynthesis.
The rejected dioxygen is a byproduct of photosynthetic reactions. These are produced in the leaves, at the cellular level which contain numerous specialised organelles: the chloroplasts.
Water drawn by the roots is transported by the raw sap to the leaves, while the synthesized sugars in the leaves are transported to other plant organs by the phloem. Carbon dioxide from the air enters the leave through small orifices called stomata. This is where the dioxygen produced is rejected into the air.