  The difference in shape between the observed galaxy stellar mass function and
the predicted dark matter halo mass function is generally explained primarily
by feedback processes. Feedback can shape the stellar-halo mass (SHM) relation
by driving gas out of galaxies, by modulating the first-time infall of gas onto
galaxies (i.e., preventative feedback), and by instigating fountain flows of
recycled wind material. We present a novel method to disentangle these effects
for hydrodynamical simulations of galaxy formation. We build a model of linear
coupled differential equations that by construction reproduces the flows of gas
onto and out of galaxies and haloes in the EAGLE cosmological simulation. By
varying individual terms in this model, we isolate the relative effects of star
formation, ejection via outflow, first-time inflow and wind recycling on the
SHM relation. We find that for halo masses $M_{200} < 10^{12} \,
\mathrm{M_\odot}$ the SHM relation is shaped primarily by a combination of
ejection from galaxies and haloes, while for larger $M_{200}$ preventative
feedback is also important. The effects of recycling and the efficiency of star
formation are small. We show that if, instead of $M_{200}$, we use the
cumulative mass of dark matter that fell in for the first time, the evolution
of the SHM relation nearly vanishes. This suggests that the evolution is due to
the definition of halo mass rather than to an evolving physical efficiency of
galaxy formation. Finally, we demonstrate that the mass in the circum-galactic
medium is much more sensitive to gas flows, especially recycling, than is the
case for stars and the interstellar medium.
