How borders are drawn and enforced has far-reaching consequences, whether we live on either side of them or halfway across the world.

You can’t get mad at a company for doing every legal thing possible to make a buck, right?

That’s the typical response when companies like Burger King or Chiquita Banana use tax loopholes to take their companies overseas (at least on paper), or when firms like Apple, Google, or General Electric find ways avoid taxes on billions of dollars of global income. It may be bad for US taxpayers but, hey, blame lawmakers for doing such a crappy job; the companies are just following the rules that have been created for them.

But this is a naive way to think about how companies and legislators interact. Congress doesn’t fill the tax code with loopholes on a whim or even on accident—it does so because companies and their lobbyists spend millions of dollars influencing legislators to write, and maintain, a tax code that suits them. That means protecting loopholes that allow companies to defer taxes on foreign income (and allows them to define as much of their income as possible as foreign). These structures, in turn, have created the stockpiles of offshore cash that make a merger-related move to a foreign jurisdiction so lucrative, and so tempting.

Lobbying is a roughly $3.2 billion-a-year industry in the US capital, according to data collected from lobbying disclosures by the Center for Responsive Politics. Just in the first half of this year, 1,802 different parties hired lobbyists to talk to Congress just about the tax code; it was the second-highest lobbied issue, after spending and appropriations. That number isn’t all corporations—some of it reflects public interest lobbying—but the bulk of lobbying expenditures comes from large companies and their representatives.

Disclosure requirements for lobbying are not very tight—lobbyists write their own disclosures and need not break out individual issues—so it’s nearly impossible to say how much money was spent on tax matters alone. But we can look through the data to find a few key points that otherwise might get lost in the obfuscation.

Pfizer, which attempted a tax inversion earlier this year, paid $80,000 this year to the Washington Tax & Public Policy Group so that Gregory Nickerson, formerly a top staffer on the House of Representatives’ tax committee, would lobby Congress about international tax issues on their behalf; Coca-Cola paid the firm $50,000 for the same services in the same period. And Microsoft alone spent nearly $1.2 million in the first half of the year lobbying Congress on matters including international tax issues.

Covidien, a Dublin-based medical-supply company that merged with US firm Medtronic in a tax inversion earlier this year, paid one lobbyist $80,000 to monitor international tax issues in the US Congress this year. In the same period, Medtronic spent $350,000 to hire five different lobbying firms to fight the “Stop Corporate Inversions Act of 2014,” while also deploying its own, in-house lobbyist. AbbVie, a pharmaceutical firm that just sealed a tax inversion deal, has spent more than $210,000 this year on lobbying, with international tax issues high on the agenda.

Are you starting to see the pattern?

Of course, this influence has limits. The existing corporate tax code is not what the companies would have created were it entirely up to them, and many politicians are pushing (albeit in vain, it appears) for reforms that would raise taxes on corporations. And though we haven’t reached a tipping point yet, the public backlash against companies that capitalize on politically unpopular allowances is building.

But for all their muddied complaints about competitiveness, there is little evidence that US multinationals are at a disadvantage to firms in other countries, and so they are happy to kill a tax code overhaul as long as the current system allows them to slip their cash—and, increasingly, their entire companies—out of the United States.