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

Gilead Science, the drug maker widely criticized for pricing a life-saving anti-viral drug beyond the reach of many patients, has also used a controversial tax strategy to to keep nearly $28.5 billion in profit out of reach of the US Treasury.

Hepatitis C virus (HCV) is a blood-borne pathogen that attacks the liver. It has infected more than three million Americans and is the leading cause for liver transplants. Sovaldi, the drug developed by Gilead, was the first truly effective treatment for the disease with limited side-effects, and a full dosage cycle costs $84,000, despite estimated manufacturing costs of just $1,400.

In 2014 alone, the US public spent almost $5 billion on Sovaldi through government health programs, but just 16,000 of the nearly 700,000 Medicaid-qualified recipients of the drug received it due to rationing over price.

A US senate investigation completed in 2015 found the company didn’t base the price of the drug on its research investments or manufacturing costs; instead, they set the price based on what they determined was the most they could charge while still avoiding bad publicity. Meanwhile, they were preparing for an even more expensive next-generation anti-HVC drug.

“While publicly saying it prioritized patient access, Gilead set Sovaldi’s price at a level where ultimately many patients would not receive treatment,” the Senate investigation (pdf) concluded.

Analyses of Gilead’s financial disclosures under CEO John Milligan show that the company’s zeal for maximizing revenues is matched by its passion for seeking lower taxes by attributing revenue to foreign subsidiaries. Gilead declined to comment on its tax planning.

Americans for Tax Fairness, a non-profit watchdog group, published a report noting a suspicious pattern: In 2013, the year that Sovaldi was approved, Gilead transferred its intellectual property to an Irish subsidiary. As the drug took off in 2014 and 2015, Gilead’s revenues grew by $20 billion, driven primarily by US sales. In that same time period, the company’s offshore profits rose $17 billion. In both years, the company’s non-US profits far exceeded its non-US revenue—in 2015, for example, Gilead reported $13.7 billion in foreign profit on just $11.4 billion in foreign revenue.

In 2012, Gilead changed the corporate status of its Irish shell companies so they would not need to file further public financial disclosures, so we can’t say for sure whether or how much of Sovaldi’s profits have flowed to them in the past few years.

However, Gilead has reported accumulating $28.5 billion in untaxed foreign profits through 2015—and told the Securities and Exchange Commission it was able to defer $9.7 billion in US tax payments on those profits, while effectively paying just 1% tax on its foreign earnings.

This suggests Gilead is sending US income in the form of royalties to the Irish subsidiary that owns the rights to Sovaldi. That subsidiary can then exploit a quirk in Irish tax law that allows it to avoid local taxes by claiming that its main center of business is in a third, low-tax country.

Thanks to this tax scheme—sometimes called the ”double Irish”—the global effective tax rate for Gilead and its subsidiaries has fallen every year since 2012, from just under 30% to 16.4% today.

Paul O’Donoghue, a reporter in Ireland, found evidence that Gilead has used this tax scheme before. He discovered that Gilead Biopharma Ireland, a Gilead subsidiary that reported no employees in 2006, disclosed $6.2 billion in profit between 2006 and 2012. It paid no tax in Ireland because it was technically “domiciled” in the Bahamas. At the time, Gilead’s parent company reported $7.2 billion in untaxed foreign earnings, the bulk of which appear to be in that Irish subsidiary.

This cushy set-up won’t last forever: Ireland announced last year it will phase out the “double Irish” by 2020 after complaints from the US and European Union, who say the current Irish tax policy is an unfair subsidy that drains their own treasuries. Notoriously, tech companies like Apple have used Irish subsidiaries to avoid billions in taxes.

This is a conscious strategy; Ireland’s financial sector benefits from fees generated by tax optimization, and while companies pay limited taxes, they often invest in operation centers in Ireland that otherwise would not be constructed. However, the country’s lawmakers are developing alternate strategies to help multinational firms avoid (or lessen) taxes, including a so-called “knowledge box,” or a special tax rate on intellectual property.

In the US, though, Gilead’s strategy is sure to lead to calls for more aggressive government negotiations with pharmaceutical companies over publicly-funded treatments and tougher rules around shifting profits overseas.