Profitability has been eroding at an alarming rate at Macy's (NYSE:M) in the past two years, as shoppers have turned away from department stores as a whole. Adjusted earnings per share reached $4.40 in fiscal 2014, but the company expects to report adjusted EPS of just $2.95-$3.10 for the recently ended 2016 fiscal year.

Despite this steep earnings decline, free cash flow has been remarkably consistent at Macy's in recent years -- particularly in the fourth quarter. Additionally, Macy's has continued making progress on real estate sales in recent months.

The Macy's Herald Square store

Macy's has started to sell off a lot of its valuable real estate. Image source: Macy's.

As a result, Macy's probably produced a lot of cash flow last quarter. How it used this cash could say a lot about management's confidence in the future.

Macy's had a lot of cash to deploy in Q4

Retailers typically generate the bulk of their cash flow in the fourth quarter due to the industry's seasonality. Late in the third quarter, most retailers increase their inventory significantly to prepare for the holidays, and they convert that to cash between Black Friday and New Year's Day.

Macy's is no exception. Indeed, the department store giant produced more than 100% of its free cash flow in the fourth quarter last year. For the past few years, Macy's Q4 free cash flow has been fairly steady around $1.4 billion-$1.5 billion.

M Free Cash Flow (Quarterly) Chart

Macy's Free Cash Flow (Quarterly) data by YCharts.

Free cash flow may have dipped slightly from that range last quarter, because Macy's entered the period with lower inventory than a year earlier and sales declined year over year. On the other hand, Macy's sold off hundreds of millions of dollars of real estate during Q4. As a result, it probably had about $1.5 billion-$1.8 billion of cash available to deploy last quarter.

Here's what we know

Looking back to the fourth quarter of fiscal 2015, Macy's generated about $1.5 billion of cash, including the proceeds of real estate sales. It paid out $112 million in dividends and repurchased more than $200 million of stock. Macy's also paid off more than $500 million of short-term debt. The rest of the cash it generated -- $635 million -- replenished the company's cash reserves.

We already know that Macy's paid its regular dividend last quarter, using about $115 million of cash. The company also paid off $577 million of long-term debt that matured in December. It likely paid off $52 million of short-term borrowings around the same time.

Based on the midpoint of the $1.5 billion-$1.8 billion cash flow range I estimated earlier, Macy's would have had another $900 million to deploy after these dividends and debt repayments. Let's take a look at how it might have used that cash.

What should Macy's be doing with its excess cash?

Macy's ended the third quarter with $457 million of cash and cash equivalents. Given that the company often experiences negative free cash flow in the first few quarters of the year, it is prudent for Macy's to increase that cash balance.

However, there's no reason why it should need to begin the new fiscal year with more than $1 billion of cash, as it did a year ago. Macy's still has quite a few real estate sales in the pipeline that should bring in cash in the first half of 2017. Furthermore, the closure of more than 60 stores in the next two months should reduce the company's working capital needs.

A Macy's store

Macy's is closing more than 60 stores this spring. Image source: Macy's.

The other two main ways that Macy's may have used its cash are share buybacks and debt prepayments.

Macy's has an enterprise value of around $17 billion now, which less than some estimates of the company's real estate value alone. Furthermore, the stock trades for just over 10 times earnings. These factors both suggest that Macy's stock may be undervalued, making it a good time for share buybacks. As of the end of Q3, Macy's had authorization from the board to repurchase up to $1.8 billion of stock.

Macy's also may have had attractive debt repurchase opportunities last quarter. Much of its long-term debt trades at a discount to book value. For example, Macy's 4.5% senior notes due in 2034 traded for about 85 cents on the dollar for much of January. Retiring some of that debt at a discount would have improved the balance sheet while reducing future interest expense.

If Macy's executives are confident that the company will bounce back soon, they may have devoted most of its excess cash flow to buybacks. A more likely -- and more prudent -- alternative would have been to split most of the extra cash between share buybacks and debt repurchases. By contrast, a big buildup in Macy's cash balance would be the worst signal for investors, indicating that management is battening down the hatches and preparing for more tough times ahead.

Adam Levine-Weinberg owns shares of Macy's. The Motley Fool has no position in any of the stocks mentioned. The Motley Fool has a disclosure policy.