About two years ago, Atmel (Nasdaq: ATML) was in deep trouble. Operations were tanking, shareholders had nothing to cheer about, and just to put a cherry on top of it all the company was about to get torn to pieces by ON Semiconductor (Nasdaq: ONNN) and Microchip Technology (Nasdaq: MCHP) in a very hostile takeover.

Fast-forward to today, and it's a whole new ballgame. ON changed its mind about Atmel's memory controllers, and the whole takeover bid evaporated. Atmel grabbed the bull by the horns and started rebuilding itself around the businesses that were profitable. And today, after reporting solid progress on that transformation plan, Atmel's stock is trading some 27% above that $5 buyout bid per share. That includes a 19% jump today.

Second-quarter sales improved by 38% year over year and 13% sequentially to $393 million, fueled mostly by the microcontroller business that Microchip wanted to buy. Since that division is also highly profitable, gross margins followed suit with a leap from 32% a year ago to 41% today. Non-GAAP earnings also skipped from about breakeven in 2009 to $0.11 per share today.

Things could have been even better if the whole chip industry wasn't constrained by chip foundries such as Taiwan Semiconductor Manufacturing (NYSE: TSM) and United Microelectronics getting swamped under more orders than they can handle. Atmel picked a bad time to sell off most of its own factories and move over to outsourced foundries, and management explained more than once during the earnings call that demand for Atmel's products is higher than the available manufacturing capacity.

The star of this show, the microcontroller division, provides chips that control things such as industrial machinery, smartphone touchscreens, and digital audio streams. The Android platform was held up as a point of strength as Atmel's controllers go into several of the most popular Android phones today. Motorola (NYSE: MOT) uses them in the Droid X, Samsung needs them for its Galaxy S series, they're inside the HTC EVO 4G, and so on. Cypress Semiconductor (Nasdaq: CY) doesn't land all of the sweetest deals here, by the looks of it.

That's curious because both Cypress and rival touchscreen controller  maven Synaptics (Nasdaq: SYNA) are members of the Open Handset Alliance that steers Android development, while Atmel isn't -- yet.

This is a turnaround story with a happy milestone, though it remains to be seen what the ending will look like. Is Atmel still buyout bait or an indie designer with a future? Or will Cypress and others pull the rug out from under Atmel's feet? Weigh in on Atmel -- or any other stock -- with a few well-placed clicks in Motley Fool CAPS.

Fool contributor Anders Bylund holds no position in any of the companies discussed here. Cypress Semiconductor is a Motley Fool Rule Breakers recommendation. Try any of our Foolish newsletters today, free for 30 days. You can check out Anders' holdings and a concise bio if you like, and The Motley Fool is investors writing for investors.