Look at these three companies' margin histories and current price-to-earnings ratios, and tell me which is the best deal:

You probably picked McDonald's (MCD 0.37%), or maybe Chipotle Mexican Grill (CMG -1.34%), but definitely not CEC Entertainment (CEC.DL). You would probably be wrong, though. CEC's operations may not be in the best shape, but its capital allocation makes it a hidden bargain.

You could be forgiven for picking McDonald's. It is the world's leading fast food company and still has opportunities to expand abroad. The company generates gobs of free cash flow from lucrative franchise arrangements around the world and has increased earnings per share at a whopping 18% per year over the last decade.

The restaurant business is tough, even for a wide-moat company like McDonald's. The company's same-store sales have been getting hammered over the last two years and earnings growth is hard to come by all of a sudden. In fact, the company has been struggling recently, but new product roll outs like the popular McCafe products that were introduced in 2009 provided new growth amid declining core sales.

Lousy operations, but great stock
Things are not any easier for CEC. The owner of Chuck E. Cheese restaurants has been in decline for more than a decade; its margins have decreased nearly every year since the turn of the millennium, and the trend is unlikely to change direction any time soon.

Remarkably, the stock has returned 8.3% per year since 2000 vs the S&P 500's 3.4% (both figures include dividends). It achieved this outperformance through regular share repurchases. Investors who bought CEC in 2003 and held through today now own twice as much of the company as they had originally purchased.

It is this incredible effect -- that of increasing value per share even as the value of the entire company declines -- that makes CEC a special investment. It continues to increase earnings per share even as its absolute earnings decline.

There may be more upside hidden in the stock. With nationwide scale, CEC has a tremendous advantage over its competitors, typically local putt putt operators, ice skating rinks, and community pools. The company is working to improve profitability by reworking its cost structure; CEO Mike Magusiak noted on the second-quarter conference call that the company improved its margin after reducing food prices (to draw in customers) and increasing token prices.

The company is also ramping up advertising throughout 2013 after relatively low spending in a lackluster 2012; its 2013 advertising spending is running at about 5.5% of sales compared to less than 4% of sales in 2012. If these initiatives can successfully stem the company's long-term margin decline, then shareholders could be in for significant upside.

Even if CEC's earnings decline does not reverse, the stock is still a better bargain than many companies that have growing earnings. Chipotle is a tempting buy because it is one of the most promising concepts in the fast-casual space. Unlike CEC, Chipotle's niche is growing, which provides a forgiving operating environment should the company make a minor mistake. The company is also riding the wave of the natural ingredients and health food craze.

Even companies that have the best prospects can be too expensive. Purchasing Chipotle at 44 times a strong trailing earnings figure is speculative at best and offers a low return if the company does not live up to expectations. If the company does not grow earnings, long-term investors will receive a 2.2% annual return from the stock (one divided by 44). Of course, earnings will grow, but investors are exchanging their money for very little value today in the hope of much more value in the future.

CEC, on the other hand, changes hands at a price that assumes earnings per share will remain in decline, even though it is more likely to increase. In addition to recent initiatives by management to stabilize margins, the company has $20.2 million in cash on its balance sheet -- as much cash as it has ever had in its history of significant share repurchase. As a result, the company's future earnings per share is more likely to increase rather than decrease.

Bottom line
McDonald's and Chipotle are in much better operating positions than CEC, but they may not be better investments. McDonald's is scrambling to shore up same-store sales and Chipotle has a lot of growing to do before investors receive enough value to justify today's price. Meanwhile, CEC has unexciting future prospects, but continues to increase value per share outperforming the S&P 500.

It is usually a better idea to buy today's earnings than to hope for earnings in the future. Investors who share this sentiment should take a closer look at CEC Entertainment.