Marissa Mayer could get up to $37 million if Yahoo gets sold

Marissa Mayer's tenure at Yahoo could be wrapping up soon. But if she plays her cards right, she could make out like a bandit.

Rumors are heating up about a deal to sell Yahoo. If there is a sale, Mayer could get ousted. In that case, she would take home about $37 million, according to the terms of her employment contract.

This would trigger the release of all her stock awards. In virtually any other scenario, Mayer would have needed to stay at Yahoo for a certain period of time in order to cash out those rewards.

She would get to take home three years salary ($3 million), roughly $9.5 million in stock awards that are scheduled to vest over the course of 2016 and about $24.5 million worth of awards that are scheduled to vest down the road.

But Mayer could get fired before Yahoo is sold, in which case her payout would be significantly less.

In that case, Mayer would take home $12.5 million: $1 million in salary, a $2 million cash bonus and $9.5 million in stock that would vest in 2016.

In either scenario, her golden parachute will be worth significantly less now than it was a year ago.

Yahoo's(YHOO) stock price has fallen 23% over the past 12 months. She was granted a huge chunk of stock awards as a kind of signing bonus at the beginning of her employment in July 2012, the bulk of which have already been released into her account.

A year ago, Mayer would have taken home $110 million had she lost her job because of Yahoo's sale and $26 million if she was fired without a sale.

That wouldn't necessarily impact Mayer's job as CEO, but Starboard has expressed strong dissatisfaction with Mayer's efforts to turn around the company.

Mayer's hefty pay package has been the subject of shareholder ire. She made $42 million in cash and stock in 2014, despite being docked $13 million for the company's poor performance. Mayer's 2015 compensation is due to be reported next month.

CNBC reported Monday that Yahoo is in the early stages of negotiating a sale with an unnamed bidder. Verizon(VZ) and private-equity firm TPG Capital are rumored to have expressed interest.

Microsoft(MSFT) isn't interested in buying Yahoo outright anymore (it made an unsolicited $45 million takeover offer in 2008), but it would like to help back a potential deal, in an effort to salvage its lucrative search and advertising deal with Yahoo, according to Re/code.

A spokeswoman from Yahoo declined to comment on the rumors or on Mayer's potential golden parachute.