Pfizer, the large American pharmaceutical company, formally announced on Monday that it will buy Allergan, an Irish company with about one-tenth Pfizer's revenue. Except legally speaking, Allergan is going to be buying Pfizer. And legally speaking, the new company's headquarters is going to be in Dublin even though its "operational" headquarters will be in New York — right where Pfizer is located today.

The reason? Tax avoidance. Having Pfizer become an Irish company will reduce its tax bill a decent amount in practice and a huge amount in accounting terms, making it easier for money to flow out of the corporate treasury and into the pockets of shareholders.

Hillary Clinton denounced the deal as a rip-off for US taxpayers, and in a statement Bernie Sanders went even further and said, "The Obama administration has the authority to stop this merger, and it should exercise this authority."

Hillary Clinton blasts Pfizer-Allergan Merger: These kind of deals "will leave U.S. taxpayers holding the bag." — Alex Seitz-Wald (@aseitzwald) November 23, 2015

Welcome to the exciting world of what are known as "tax inversions" — an increasingly common practice whereby American companies become foreign ones in order to evade the grasp of the IRS.

How and why tax inversions work

One key motivation for tax inversions is that the United States, unlike other developed countries, attempts to tax US-based corporations on all their profits regardless of where in the world the profits were earned. Companies get to deduct the corporate income tax they pay to foreign governments for their foreign profits, but since the US has a higher corporate income tax rate than most foreign countries, that generally leaves a residual tax bill.

So if a US-based company can become a subsidiary of a company headquartered in a low-tax jurisdiction like Ireland, then it can avoid paying a bunch of taxes on sales made in foreign countries.

Pharmaceutical companies can do a lot of dodgy tax stuff

For some companies, the inversion story is a pretty basic case of taxes paid on foreign sales. But for companies in a handful of industries — most notably pharmaceuticals and high tech — there are additional gains.

That's because a huge share of the value of a pharmaceutical company is tied up with its drug patents. By assigning ownership of the patent to a subsidiary located in a low-tax jurisdiction and then having subsidiaries in higher-tax jurisdictions license the patent from it, a pharmaceutical company can ensure that profits accumulate in low-tax countries even if sales happen in high-tax countries.

The US treats "offshore" profits in a weird way

In theory, the US taxes all profits, whether they are earned at home or abroad. But there's a catch: The tax is only due to the US Treasury Department when the money is actually "brought home" from the foreign subsidiary back into the US-based parent company. Before that, the cash is considered to be offshore (note that the money may well actually be in a US bank account or other financial institution — it's a question of ownership, not location), and the taxes owed may be deferred.

Companies generally hold money offshore because they are hoping some future Congress will cut corporate income tax rates or pass some kind of repatriation amnesty that will let them bring the money back onshore at a low tax rate.

But as long as the taxes are being deferred, for accounting purposes the company has to act as if it eventually plans to pay the full taxes due on its foreign profits. By becoming an Irish company, Allergan can dispense with that pretext and fully make its paper earnings look vastly larger. But it also makes a difference in a practical sense. Before Pfizer can hand cash to its shareholders in the form of dividends, it needs to bring it onshore and pay taxes. An inversion will cut taxes on money used for that purpose, as well as improve the company's paper profits in accounting terms.

The White House has a plan to curb inversions

The White House actually wrote an inversion proposal into the budget it released in March 2014. The original proposal would have made inversions more or less impossible and would have retroactively penalized inversions completed earlier in the year. But those proposals would have required legislation to pass Congress, and the Republicans who run Congress have no interest in raising taxes on American businesses.

Last fall, Treasury instead released a broad suite of new rules and interpretations of rules that make inversions more difficult. These rules generally would make it harder for an inverting entity to shift funds around various subsidiaries for tax purposes, and would also strengthen enforcement of anti-inversion rules adopted in previous decades.

But as the Pfizer-Allergan deal makes clear, absent new legislation this sort of thing is going to keep happening.

Corporate income tax reform is the dream that never dies

The United States has more or less the highest official corporate income tax rate in the world, but it's so full of loopholes that very few companies pay anything close to the official rate. This is widely regarded as a lamentable situation, and there is overwhelming political consensus around the idea that the corporate income tax code should be reformed. The broad idea is that the rate should be brought down but loopholes should be closed. The resulting system would treat different companies more similarly and should help US-based firms compete in global markets.

Corporate tax reform keeps not happening, however, for two reasons.

One is that there's big-picture ideological disagreement between Republicans and Democrats over whether the goal of reform should be to raise more tax revenue or less. Everyone agrees that the current code is bad. But absent consensus about revenue targets, it's hard to build a coalition for reform. The other is that while it's easy for everyone to agree on the idea of "closing loopholes," it's very difficult to agree on exactly which loopholes should be closed.

Were broad corporate tax reform to pass, it would likely reduce the incentive for inversions somewhat. On the other hand, depending on exactly which loopholes were closed, it might create more incentive for inversions in certain sectors. Either way, inversions themselves are a huge loophole that companies will almost certainly continue to exploit unless they are specifically restrained from doing so.