An earnings report marred by declining same-store sales earlier this week was just the latest in a string of lackluster performances for Walgreens Boots Alliance (WBA 1.85%). The stock has fallen around 30% over the past three years as investors begin to worry that the enormous retail footprint it's acquired will see more tumbleweeds than customers. 

Quite a few bargain hunters have noticed the company still produces a solid profit that it parcels out in the form of a rising dividend and hefty stock buybacks. Let's examine the case for and against this company to see if the stock is a value opportunity at recent prices or a value trap to be avoided. 

Shopping cart full of pills on a pile of cash money.

Image source: Getty Images.

Reasons for the rout 

Walgreens stock has been sliding for a while, but it really took a tumble when the company reported results for the three months ended May. U.S. pharmacy sales were flat compared to the same period last year and retail sales inside those pharmacies fell 3.8%.

The earnings call wouldn't have been such a disaster if not for a well-timed announcement from Amazon.com (AMZN 2.43%). The online retailer announced it would buy an online pharmacy just before Walgreens held an earnings call with analysts.

Reasons to buy

Several years back, Walgreens made a smart move to boost its purchasing power by forging a partnership with one of America's largest wholesale distributors of prescription drugs, AmerisourceBergen. Earlier, the Alliance Boots merger provided similar access to a large European distributor, in addition to a leading chain of retail outlets.

Profits from the wholesaling segment itself aren't exactly thrilling, but they are significant and rising. The real benefit is lower costs at the source that pushes up total profits, which the company isn't shy about returning to shareholders.

Colorful pills on top of cash money.

Image source: Getty Images.

Walgreens has boosted its dividend for 44 consecutive years. Following a recent 10% bump, it offers a 2.9% yield, and management just announced a $10 billion buyback program that could retire a whopping 17% of outstanding shares at recent prices. The company generated $5.7 billion in free cash flow over the past 12 months, but used just $1.6 billion to make dividend payments over the same time frame. That gives Walgreens plenty of room to raise the payout in the years ahead. 

If profits simply hold steady, investors buying Walgreens shares at recent prices would see a nice return over the long run.

Reason to run

Unfortunately for Walgreens, moving the needle forward in the years ahead could get awfully difficult if margins on retail prescription drug sales get any slimmer. Amazon hasn't announced any specific plans, but America's everything retailer is coming after Walgreens' corner of the healthcare sector and it's bringing some influential friends.

Earlier this year, Amazon, JPMorgan Chase, and Berkshire Hathaway announced the formation of a joint venture tasked with lowering healthcare costs by any means possible. A recently appointed CEO with plenty of experience talking about healthcare didn't provide any clues, but the recent announcement that Amazon would acquire PillPack did.

I think it was a bit mean for Amazon to announce it would acquire a privately held online pharmacy business with licenses to distribute in all 50 states at the same time analysts were digesting Walgreens' latest earnings release. Amazon's already pulling customers away from Walgreens' retail outlets. If the juggernaut makes filling prescriptions as painless as it's made shopping for clothes, Walgreens could be in deep trouble.

Red flag in the wind.

Image source: Getty Images.

And keep running

It looks like Walgreens has painted itself into an increasingly unprofitable corner of America's healthcare sector. The company relies on U.S. retail pharmacy sales for 77% of gross profits. Its main competitor in the retail space, CVS Health (CVS -0.30%), diversified away from retail pharmacy operations but will use the locations as hubs for several businesses that traditionally operate separately. That includes the country's largest pharmacy benefits management business and most likely Aetna, a private insurer CVS intends to acquire that serves around 45 million people.

CVS Health could drive a lot of Aetna patients into its array of more than 1,100 walk-in clinics across the country, and many of those patients will fill prescriptions at connected pharmacies and just maybe buy a roll of toothpaste they can't wait two days to receive from Amazon. Walgreens' efforts to make its stores relevant seem paltry by comparison.

Walgreens has a new strategic partnership with another large insurer, Humana, to offer full-service primary-care clinics at a handful of pilot locations. It's a good place to start, but the project might not go very far. America's third-largest chain of retail pharmacies, WalMart, is reportedly mulling a merger with the private insurer. 

Walgreens might look like a bargain, but it's just too concentrated in a highly competitive space that's about to become even more so. Hopefully, the company will find a way to keep its 13,200 stores relevant in the years ahead, but I don't think that's a bet worth taking.