Here's what happens:
1. Ling Yao's Soul: Ling Yao's soul is contained within a Philosopher's Stone. This stone is then consumed by Father, who integrates Ling Yao's soul into his being.
2. Greed's Body: Greed's original body was a Homunculus, a being created by Father. He was created with the "power of greed" and a desire for possessions. However, he rebelled against Father and was sealed away.
3. Ling Yao's Possession: When Father absorbs Ling Yao's soul, he effectively "possesses" Greed's body. This allows Father to use Greed's physical form and powers, with Ling Yao's personality and soul inhabiting it.
4. The Reunion: Greed's body is later retrieved by the Elric brothers, and the soul of the original Greed (who was imprisoned within his own body) is reunited with it. This effectively frees Ling Yao's soul, allowing him to return to his own body in the afterlife.
In summary:
* Ling Yao's soul is consumed by Father, and his soul is integrated into Father's being.
* Ling Yao then utilizes Greed's body and powers, with his own personality and soul inhabiting it.
* Ling Yao's soul is later freed, and he is able to return to his own body in the afterlife.
It's important to note that Ling Yao never becomes Greed, although he does temporarily inhabit Greed's body. He is a separate entity, and Greed is also a distinct entity, even though they were both intertwined by Father's actions.