Apple Inc.’s (NASDAQ:AAPL) CEO Tim Cook recently sold a portion of his previously restricted stock compensation, earning him $36 million in cash. The CEO revealed in a securities filing that Apple awarded him 1.26 million shares worth about $135 million under a five-year stock compensation plan.

When Apple named Cook as its CEO in 2011, the company granted him 1 million in restricted Apple shares. However, when Apple reached a 7-for-1 stock split, Cook’s restricted stake rose to 7 million shares, with half of those restricted shares intended to vest this year after Cook had remained in the position for five years.

As such, of the total 1.26 million shares awarded to Cook, 980,000 shares came through after Cook had served as CEO to the tech giant for five consecutive years. The other 280,000 shares came on the heels of consistent outperformance, after Apple topped over two-thirds of the companies in the S&P 500-stock index for three years running.

Performance-based compensation

A plan was drawn in 2013 requiring Cook to lead Apple to outperform and beat at least two-thirds of the S&P 500 companies. If he succeeded, Cook was promised 280,000 Apple shares as compensation. However, Apple needed to top two-thirds of S&P 500 for three years between August 25, 2013 and August 24, 2016 for Cook to qualify for the full performance-based stock award.

However, a condition was set in place: if the giant’s performance merely hit middle of the two-thirds, Cook’s stock compensation would subsequently drop by 50%. Moreover, if Apple’s performance was so dismal that the company failed to even make the list of best performers, Cook was to earn zero shares.

Cook met the performance expectation, thus unlocking the shares.

$71 million to cover taxes

Though Cook pocketed $36 million from the sale, he ultimately surrendered shares worth $71 million to cover taxes. However, he will continue holding the rest of his vested shares.

CEO compensation

Apple paid Cook $10 million to cover salary and cash bonus in fiscal 2015. Cook didn’t receive stock awards in that year. However, outside Cook, top five executives at Apple took home $25 million in total compensation in 2015. The amount included $20 million in stock awards and $5 million in salary and bonus.

Though Cook’s 2015 salary and bonus compensation rose 11.5% from the previous year, he ended up being the lowest-paid among Apple’s top executives.

Compensation tied to performance

The bulk of Cook’s stock awards are now tied to the performance of Apple stock, set up after the 2013 amendment of his stock compensation plan.

Cook’s stock award is getting tied more to performance at a time when Apple is struggling with shrinking iPhone sales. Apple’s sales and profits slumped in the June quarter, marking the second quarter in a row that the company’s revenue declined.

In its core smartphone business, Apple now faces challenges including slowing iPhone sales from fierce competition and a saturation of the market in developed countries.

Given that iPhone is Apple’s bread and butter, eyes are on the company as it nears the launch of the new iPhone, the rumored iPhone 7. Analysts have argued that Apple needs to give the iPhone 7 a major design upgrade for it to stand a chance of at least defending its market share.