You were right the first time.but there's a catch (isn't there always) The amount of energy required to separate the hydrogen from the oxygen is quite large, generally considered more than the energy produced,
So, what if a pack of LiFeP04 batteries were fitted to provide the energy, this could be charged over night on cheap power and used to power the vehicle and the electrolyser while driving.
You will loose more than 1/2 the electrical energy converting it to hydrogen ... and you will loose more than 1/2 of hydrogen's energy burning it in the ICE to get mechanical power.
In short you are proposing a Battery to wheel efficiency of less than 25% ... this is crazy low and wasteful compared to 80% to 90% achievable with real world BEVs ... if you have the electricity ... it is more efficient to move the car with it like a BEV and skip the Hydrogen all together.
If you are not a BEV it would still be more efficient to boost the gasoline ICE with a PHEV system where the electrical energy is being used far more efficiently to provide mechanical power.
Hydrogen is cleaner ... and it is sustainable ... and it is nice for allot of things ... but it's efficiency sucks ... and it's energy per unit volume sucks.