Which is where hybrid drive trains and PWM comes in. Run the engine at its ideal and only at its ideal with no care for the actual load requested.
Furthermore I mentioned CNG - ie methane. Methane has more energy per CO2 gram than any hydrocarbon and has an insanely high octane number -> it can run an Otto cycle at diesel compression ratios.
Run it as a miller cycle and the thermal efficiency starts to go up even highed.
Really my 40% is a low ball of what is possible in ICEs to not offend anyone's preconceptions. F1 claims to have achieved >50% thermal efficiency in a race engine but Im usually loath to mention that because of their secrecy and therefore lack of indee verification.
And no one talks that lines and transmission is lossy. No one talks that dispach-able power is often coal or oil. No one talks about the environmental and social cost of batteries.
Hybrids ameliorate (the most, btw) just about every aspect of this while minimizing external costs