There is no way to end up ahead by giving away money in order to pay tax on that money.
So long as the marginal tax rate is <100%, you will always lose more money by giving it away than by keeping it and paying tax on it.
Except for potentially things like moving money into your own foundation, then spending the money on your own interests rather than charity. (Not that that's what's happening here.)