A few weeks ago, there was a boozy party on the rooftop of the Empire Hotel, which overlooks Lincoln Center on the west side of Manhattan.

Waitresses in heels, tights, and short dresses served plates of sliders to guests. Some of the walls had been painted pink, while the rest of the venue was bathed in a pinkish hue from a series of spotlights dotted along the floor. A DJ played dance music mixed with some top-40 tunes. There was an open bar.

But the party attendees didn't match the clubby vibe. The rooftop was full of men in blazers, slacks, and dress shirts. Women wore business casual skirts and blouses. Company people and nine-to-fivers. I saw one guy sit alone and choke down two plates of sliders. It was like watching a bunch of nerds socialize after being asked out for the first time.

The party was sponsored by T-Mobile, a way for the carrier to court its B2B customers with plenty of booze and free food. And the star of the event wasn't Mark Messier, the Hall of Fame hockey player T-Mobile hired to make an appearance. It was T-Mobile's CEO John Legere. The stuffy B2B customers ate him up. They posed for selfies. They talked about wonky topics like wireless spectrum and data usage overseas. They told him how much they loved his tweets.

I watched Legere, wearing his trademark uniform of a black jacket over a pink T-Mobile shirt, jeans, and pink Converse All Star sneakers play the crowd with a mix of swagger and legitimate concern for his customers. If one had a question or interesting idea, he would whip out a stack of business cards, which include his personal cellphone number, and give one out.

"Email me," he'd say.

In the year and a half since Legere took over as CEO, T-Mobile, which was on the verge of collapse and at risk of being stripped down and sold for spectrum, has made a remarkable turnaround. It's growing faster than its competitors in terms of revenue and subscribers. And there's a very good chance it'll soon get scooped up in a merger with Sprint, making the combined company a strong contender to AT&T and Verizon.

It'd also make Legere very, very rich.

After Legere (pronounced ledge-er) schmoozed with customers for a bit, we took the elevator down to a hotel room on the ninth floor for a chat. He took off his jacket, sipped on his beer, and pointed out the window to a swanky apartment building across the street.

"That's my place," he said.

It's that kind of boasting and showmanship that has helped turn T-Mobile into a branding story just as much as it is the story of a company coming back from the brink of collapse. Whether Legere's gratuitous swearing, toying with the press, and public shaming of his competitors is a gimmick or not is almost irrelevant. The company has the spotlight now, the allure of a scrappy startup trying to disrupt two giants that have done nothing but annoy their customers with confusing contracts, overage charges, and painful device upgrade cycles.

Since Legere took over in late 2012, his plan has been to pick apart those annoyances one at a time in what the company calls its "uncarrier" moves. Contracts? Gone. Want a new phone? Upgrade whenever you want, as long as you've paid off your first device. Tired of getting a massive bill every time you travel overseas? Free 2G data and texting should help.

Those changes, Legere said, didn't come out of nowhere. T-Mobile listened to what the market wanted and gave it to them. The plan is to pick off complaints consumers have with their carriers one by one. More changes are coming, too. On June 18, T-Mobile will announce "Uncarrier 5," its fifth major offer designed to lure in customers. Legere told me at least "two or three more" such changes are coming after that.

"People always think we're going to announce highly elaborate things," Legere said. "I'll tell you that when we announce what we're going to do next, it's going to be right in front of you. They're the most obvious, right-in-front-of-your-face things that when we do them, it's highly elegant and it works."

Legere bragged that he doesn't even need a plan. In theory, he could announce a change is coming, then analyze the social media and blog chatter to see what customers want. (That's probably an oversell from Legere, but it does demonstrate that the carrier's short-term strategy is to rapidly draw in new subscribers by framing its plans and offers as hassle-free alternatives to what AT&T, Sprint, and Verizon sell.)

T-Mobile may be the annoying mosquito buzzing in its competitors' ears, but the competitors keep swatting at it. And anything that makes Verizon and AT&T, which combined own nearly 70% of the U.S. wireless market, twitch is going to be good for consumers.

And the competition appears to be following T-Mobile's lead. In the months since T-Mobile eliminated service contracts and created a program that lets you effectively lease your smartphone through monthly payments, AT&T, Verizon, and Sprint each launched similar plans. For many though, T-Mobile is an attractive option. Its network isn't as robust as AT&T or Verizon's, but its plans are cheaper and easier to understand. (Verizon and AT&T still have so many caveats, extras, asterisks, and options that you need an encyclopedia to decipher it all.)

T-Mobile

Industry insiders I've spoken to aren't bullish on T-Mobile's long-term prospects. The carrier's moves may be good for consumers, but not the company's bottom line. Despite reporting impressive revenue and subscriber growth for the first quarter of the year, it's still losing money. Part of that is because T-Mobile launched a new promotion in January that will pay the cost to terminate your contract with your old carrier if you make the switch to T-Mobile. Those early termination fees (ETFs) can be several hundred dollars per user, depending on how long the contract has been in effect.

In essence, T-Mobile is buying customers away from its competitors. Legere said most customers who switched using the ETF deal cost the company about $200 a pop. But the offer is working, and T-Mobile is growing faster than its own lofty projections, Legere said. T-Mobile added about 2 million subscribers in the first quarter of this year alone.

"From a standpoint of what we set out to do at three-year growth targets, we're ahead," Legere said. "So there is gold in our hills. From the standpoint of this turning into significant operating cash flow, we're dead on track."

Legere seems to be aware of the realities of the business. Recently, T-Mobile raised the price of its top plan, which offers unlimited data, text, and calling, to $80 per month, a $10 increase. Legere knows things can change. Just because T-Mobile offers an unlimited data plan now, doesn't mean it will in the future if the economics of those plans shift out of the company's favor, he said.

"We haven't cast our identity on it," Legere said of unlimited plans. "We reserve the right to change that pricing and/or change whether we offer it or not. Unlimited is an offer for us, not our brand."

If you want to be cynical, you can say T-Mobile's moves over the last year and a half is a play to make the company as attractive as possible for a sale. It's not about building the best wireless carrier, but growing the number of subscribers at a rapid pace so that maybe, soon, someone will come along with an attractive offer.

And some industry insiders I've spoken to have pointed to Legere's past as evidence of that. Before becoming T-Mobile's CEO, Legere was the CEO of the telecommunications company Global Crossing, which like T-Mobile was nearly toast back in the early 2000s. Legere laid off thousands of employees while taking a $1.1 million salary plus a $3.5 million signing bonus. In a testy congressional hearing in 2002, Legere was asked by congresswoman Stephanie Tubs Jones how many Global Crossing jobs could've been saved with that signing bonus alone.

C-SPANLegere at the 2002 congressional hearing on Global Crossing.

Legere had a snarky reply.

"As a rule, I don't do math in public," he told the congresswoman.

Global Crossing survived, and was sold in 2011 (the deal closed in 2012) to Level 3 Communications for $3 billion. Legere said he doesn't regret the moves he made to keep Global Crossing alive, including all the layoffs.

"The company was dead and one of my biggest successes at Global Crossing is I created a path forward for the company to survive," Legere said. "I remember telling the company at the time that it's not probable, but it's possible, and here's how we're going to do it. It was a very long road, ultimately."

There's an obvious echo to what happened under Legere's reign at Global Crossing to what's happening at T-Mobile now. According to several reports, Softbank, the Japanese company that owns a majority stake in Sprint, will announce a formal offer to buy T-Mobile. There are, of course, a bunch of regulatory hoops the carriers will have to jump through before the deal can be approved (AT&T failed to get the government's OK to buy T-Mobile a few years ago, after all), but if it does happen, the combined company will be a strong challenger to the Goliaths AT&T and Verizon.

Legere sees the similarities too.

"If you really went back to my time at AT&T, Dell, and Global Crossing, I've always had a number of tasks that are either defining something new or fixing something broken," he said.

Legere also stands to make a lot of money by preparing T-Mobile for a sale. According to Aaron Boyd, an analyst at Equilar, which specializes in executive compensation, Legere could make over $41 million if T-Mobile sells to Sprint at its current stock price. According to one report from Bloomberg, there's talk that Legere may be the pick to be the CEO of a combined Sprint/T-Mobile.

Naturally, Legere can't comment directly on the potential merger with Sprint, but he did say such a combined venture would be much different than what AT&T wanted to do when it tried to buy T-Mobile. Back then, Legere said, it was all about AT&T snapping up more precious wireless spectrum. With Sprint, spectrum would play a significant part, but it's also about acquiring the team of executives Legere has built to turn T-Mobile around. In theory, that would create a much-needed challenger to keep AT&T and Verizon in check.

"If you took T-Mobile and gave it a huge amount of spectrum and the economic wherewithal and the scale to take on what we're doing, if I was AT&T or Verizon I'd s--- myself over that," Legere said.

But some of Legere's critics have told me in private that much of the company's turnaround is a lot of fluff, a marketing ploy to package the company for a sale after missing out the first time with AT&T. Legere is known for openly swearing in public and on social media. At the Consumer Electronics Show in January, he made a fat joke about Ralph de la Vega, the CEO of AT&T's mobile division. He's picked fights on Twitter with journalists and later deleted the tweets. He once quipped in front a group of journalists that they shouldn't try to hit on his daughter at a press event. And he takes every opportunity he can to troll his competitors with snarky public comments that sometimes contradict themselves.

Plus, he throws lavish parties for the press and customers with celebrities like Mark Messier and the rapper Macklemore.

"I don't walk closely up against the line. I ignore it. It's who I am," Legere said. "I may be a little rough and crude, but I'm much more like my customers and employees than I am an executive. I think employees relate to the way I speak, and customers relate exactly to the way I think I talk. It's part of being connected to what your customers want."

Still, it's working. When you're stuck at the bottom like T-Mobile was when Legere took over, you have to punch up in order to stand out. Otherwise, it's all over.

"This company was dead when I got here and the people needed to believe," Legere said. "I started at the top of the mountain and declared victory, day one."

It was a mission Legere had to sell to his board too: That he was going to be loud in public and relentlessly needle his competitors.

"I needed to change the culture of the owners of my board," Legere said. "I needed to make it clear as to where we could go if they would kind of just let go. And part of that behavior and that independence was a training session for everybody."

I asked Legere if T-Mobile's board had ever given him a slap on the wrist for something he did or said.