Weaker oil and gas prices continued to weigh on Devon Energy (DVN 0.19%) during the second quarter. The oil company's earnings and cash flow plummeted compared to the prior-year period when pricing was much higher. That left it with less cash to return to investors via dividends and share repurchases.

The decline in earnings and shareholder returns has weighed on Devon's shares, which currently sit 35% below their 52-week high. That sell-off has pushed the oil stock into bargain territory. Here's a closer look at the company's valuation, which suggests it's extremely cheap right now. 

Drilling down into Devon Energy's results

Compared to last year, Devon had a rough quarter financially:

A graphic of Devon Energy's second-quarter income statement.

Image source: Motley Fool.

As that graphic of Devon Energy's income statement shows, its revenue plunged nearly 39% while its net earnings cratered 64% compared to last year's second quarter. Meanwhile, total operating cash flow fell 47.5% to $1.4 billion, while free cash flow plunged 84.5% to $326 million.

The culprit was a meaningful decline in commodity prices. Devon only realized an average of $71.74 per barrel of oil, $17.79 per barrel of natural gas liquids, and $1.66 per Mcf of natural gas in this year's second quarter. That's down from $84.38 (15% lower), $34.44 (48% less), and $5.83 (71.5% less), respectively, in the year-ago period.

The steep slide in commodity prices offset a strong operational quarter for Devon Energy. The company produced a record 323,000 barrels of oil per day, an 8% increase from the year-ago period. Meanwhile, its operating costs declined by 6% on a per-barrel-of-oil-equivalent basis.

A bottom-of-the-barrel valuation

While Devon Energy's earnings plunged during the second quarter, it's still making a solid profit. Overall, the company earned $1.07 per share in the period and has hauled in $7.31 per share of net earnings over the past 12 months. With shares recently trading around $50 a piece, Devon has a price-to-earnings ratio of less than 7 times. That's dirt cheap compared to the broader market. The S&P 500 currently trades at more than 20 times earnings, while the Nasdaq-100 is approaching 35 times earnings.

Devon Energy is still pretty cheap even if you normalized its earnings for the second quarter's commodity price level. If you annualize the $1.07 per share earned during the quarter, it trades at less than 12 times earnings.

The company is also cheap on a free-cash-flow basis:

A slide showing Devon Energy's 2023 outlook and free cash flow yields at various oil price points.

Image source: Devon Energy.

As that slide showcases, Devon trades at about a 7% free-cash-flow yield based on the free cash it could produce at $70 oil (which it realized during the second quarter). That's higher than most stocks, which trade at a low-single-digit free-cash-flow yield, suggesting Devon has a lower valuation.  

Meanwhile, Devon is even cheaper at higher oil prices, which is the current environment. Oil has rebounded sharply over the past month, recently hitting $80 per barrel. Many Wall Street analysts see even higher oil prices coming. For example, Goldman Sachs set its 12-month price target for the global benchmark oil price (Brent) at $93 per barrel, about $10 above the current price. Several other banks also have price targets in the $90s. Analysts see strong demand and tight supplies causing a deficit, which should drive prices higher. 

Devon Energy certainly believes its stock is cheap. The oil company spent another $200 million to opportunistically repurchase nearly 4 million shares during the second quarter. That brought its year-to-date total to $750 million. At its current pace, Devon will repurchase about 9% of its outstanding shares by the end of next year, given how cheap they are these days. 

A dirt cheap oil stock

Shares of Devon Energy are a super bargain, especially in light of the recent rise in commodity prices. Higher prices will enable the company to produce more cash, allowing it to buy back more of its dirt cheap shares. That should eventually boost its valuation, which, along with the potential for a rebounding dividend, could give Devon the fuel to produce strong total returns from here.