Take one set of European profits, one phantom headquarters and two companies and there you have it: Apple's recipe for avoiding tax.

The deal that Brussels on Tuesday ruled illegal and ordered the tech giant to pay 13 billion euros in back taxes for is relatively simple despite the huge sums involved.

Double Irish

The deal was made possible by two "tax rulings" in 1991 and 2007 granted by Ireland as it tried to make itself competitive in attracting international firms.

The deals made it possible for companies to redistribute profits internally, and for whatever money was left to be taxed at a low rate of 12.5 percent. Ireland scrapped them in 2015.

Apple first set up two companies incorporated in Ireland: Apple Sales International, which is in charge of selling the group's products in Europe, Africa, the Middle East and India; and Apple Operations Europe, a smaller firm which makes some kinds of hardware.

All profits from Europe—for example from an iPhone sold in London or Paris—therefore go through Ireland.

But under an agreement with the parent company in California, those two companies finance—to the tune of at least two billion euros a year—more than half of Apple's research into intellectual property worldwide.

Under the Irish rules, those expenses can then be offset against Apple's profits from Europe.

Ghost HQ

The next step was to internally allocate most of the profits away from Ireland to a "head office" within Apple Sales International.

The European Commission, however, said that this effectively did not exist.

"The 'so called head office only existed on paper. It had no employees, no premises and no real activities," Competition Commissioner Margrethe Vestager said on Tuesday.

Its only real activity was occasional board meetings, the Commission said.

0.005 percent tax

As a result, in 2011 Apple Sales International recorded $22 billion in profits but was only taxed in Ireland on $50 million, the Commission said, citing figures from US Senate hearings.

By 2014 its profits had risen but the amount of tax paid did not, leading to an effective tax rate of 0.005 percent in 2014, the Commission said.

Brussels said that while the tax rulings were "perfectly legal" in themselves, they amounted to illegal state aid when offered by Irish government to Apple to encourage its investment.

Finally, the Commission added that while Ireland is expected to recover the , it may not get the whole 13 billion: if any other country is found to have made similar illegal state aid offers they may also be forced to claw back some of this overall amount.

Apple by the numbers

The European Union on Tuesday ordered Apple to pay a record 13 billion euros ($14.5 billion) in back taxes in Ireland, but the Silicon Valley technology colossus is on firm financial footing.

Below is a look at Apple by the numbers:

FY 2015

- $53 billion profit for fiscal year 2015.

Apple touted fiscal 2015 as its most successful year ever, with revenue growing 28 percent to nearly $234 billion and net income topping $53 billion.

LAST QUARTER

- $7.8 billion profit in the quarter ending June 25

Apple's most recent quarterly earnings report topped Wall Street expectations despite a 27 percent drop in profit to $7.8 billion on a sharp fall in iPhone sales.

CASH ON HAND

- $231.5 billion in cash plus marketable securities at the end of June.

Of that, $214.8 billion, or 93% of the total, was said to be outside the United States, Apple's chief financial officer Luca Maestri said on the latest earnings call.

iPHONES SOLD

- Apple said in July that it had sold its billionth iPhone. The smartphone launched in 2007 is at the heart of the company's money-making machine.

APPS

- Apple chief executive Time Cook said at a developers conference in June that the online App Store boasted more than two million applications and 130 billion downloads.

SHARE PRICE

- Apple shares were down less than one percent to $105.81 in afternoon trading on the Nasdaq exchange, giving the company a market capitalization of $569.53 billion.

EMPLOYEES

- Apple said in its most recent earnings report that it has 100,000 employees worldwide.