Source: Apple.

Apple (AAPL -2.19%) shares are approaching their all-time high as the company prepares to release its latest and greatest iPhone in what will very likely be a record launch. This situation might be giving many Apple investors a sinking feeling of deja vu.

Almost two years ago, Apple stock was on the same trajectory ahead of the launch of the iPhone 5. Shares peaked at about $705 (pre-split) on the Friday in September 2012 that the new device went on sale. The following Monday, when Apple reported that it had sold 5 million units, marked the beginning of a 45% pullback over the following seven months.

Shares have now hit $100 (the equivalent of $700 pre-split) for the first time in almost two years. The good news is that a lot has changed over that time, and it's not too late to buy this stock.

It's not such a tough margin comparison anymore
It's no secret that Wall Street can be fickle and shortsighted at times, which can happen when you construct discounted cash flow models based on forecasting estimates in perpetuity (as in, forever) to arrive at a 12-month price target. I don't know about you, but I'm generally not good at forecasting until the end of time, so I don't even try.

On top of that, two years ago Apple faced an extremely tough comparison, as most metrics are typically compared on a year-over-year basis. Apple was coming off a long string of increasingly profitable quarters. So profitable, in fact, that the figures simply weren't sustainable. No consumer electronics company with meaningful hardware operations should be able to sustain a gross margin approaching 50%, but Apple got pretty close.

Source: SEC filings. Calendar quarters shown.

Investors like to look at trends, and in that sense Apple's gross margin was heading the wrong way. That's not to say the gross margin was bad by any means, just less juicy. Still, it was enough to rattle investors. Here's how things have changed since then.

Source: SEC filings. Calendar quarters shown.

Gross margin has largely stabilized and is now climbing higher once again. Apple took some margin hits in revamping its warranty policies in China and giving more software away for free, among other moves. While its gross margin may never reach 47% again, the worst appears to be behind the company. Longer term, Apple has posted an average quarterly gross margin of 38.6% since the beginning of 2007, a level that all of its hardware rivals would kill for.

Apple's gross margin now has some notable tailwinds as we head into the fall product cycle. The company expects commodity prices to remain favorable; it will gain operating leverage as revenue ramps up seasonally; the iWatch could help overall profitability; and the iPhone 6 could even see a price increase to capture value from demand for larger displays.

Speaking of the iPhone 6...
Another possible reason why the iPhone 5 ended disappointed investors was that the increase to a 4-inch display could have been perceived as a stopgap solution to shifting consumer preferences. In 2012, Google Android devices were already approaching 5-inch displays, such as Samsung's 4.8-inch Galaxy S III. Moving the iPhone display from 3.5 inches to 4 inches might have appeared insufficient, even as Apple played the "one-handed use" angle fairly successfully.

Quite frankly, there's probably not much I can say about the iPhone 6 specifications that you aren't already familiar with, thanks to Apple's active rumor mill and leaky supply chain. I'll just remind investors that the move to larger displays will substantially broaden Apple's addressable market in key regions such as China, while simultaneously triggering a massive upgrade cycle within the tech giant's current user base for those itching for a bigger iPhone.

Apple's repurchase program by any other name would be just as accretive
Easily the most financially significant difference between now and 2012 is Apple's massive capital return program, which didn't start out nearly as massive. Apple announced the program six months before the iPhone 5 launch, and the first dividend was paid during the same quarter.

So when the company's pullback started in September 2012, investors were under the impression that Apple planned to return $45 billion to them over the following three years, via $10 billion in share repurchases and $35 billion in dividends. What they didn't know is that Apple would soon nearly triple that total to $130 billion. The vast majority of those increases have been dedicated to share repurchases, and investors also couldn't have fully appreciated how accretive these buybacks would be since they hadn't begun yet.

There are two common criticisms of share repurchase programs. On average, companies have a poor track record with timing repurchase activity, and buybacks sometimes merely offset stock-based compensation while failing to actually reduce outstanding shares. On both counts, Apple's repurchase program has been a success.

Supplementing open market purchases, Apple has selectively used accelerated share repurchases to take advantage of slumping stock prices. Of course, this is all in hindsight; if shares drop again, the timing won't look so favorable.

Source: SEC filings and Wolfram Alpha. ASR = accelerated share repurchases. Calendar quarters shown.

Shares outstanding have undeniably decreased in a big way since the program started. The net result is significant earnings accretion as Apple's net profits are split among fewer shareholders.

Source: SEC filings. Calendar quarters shown.

Most of Apple's growth in earnings per share is being driven by these buybacks. While some will call this "financial engineering," whatever you call it, buybacks deliver an undeniable benefit to individual shareholders. Semantics aside, that's what matters at the end of the day.