That's the killer question.

In a credit crunch, investors and employees alike replace their dreams of pie in the sky with concerns about food on the table.

And when people fear mass bankruptcies, panic sets in and drives down the price of everything, justified or not.

For example, we're seeing low-debt superstar Coca-Cola (NYSE:KO) trading close to 30% below where it was 10 years ago (and that's after the recent rally). Now, that doesn't necessarily mean it's a value, but it's a shocking piece of data nonetheless.

While the strong have been punished, the weak have been absolutely throttled. I count 100 companies on major U.S. exchanges trading for less than the cash on their books, even after netting out debt.

Still, in many of those cases, the punishment is justified, and the danger of bankruptcy is real. So how can we tell the difference between panic and prudence?

The first warning sign of bankruptcy
A company goes bankrupt when it runs out of cash to pay its obligations. Besides its regular operational obligations (paying rent, employees, vendors, etc.), a company has financing obligations (i.e. debt).

In good times, debt does wonders for shareholders' returns. Instead of diluting shareholders by cranking out more equity, issuing debt (at reasonable interest rates, of course) allows shareholders to keep the excess profits to themselves.

However, debt is referred to as leverage for a reason -- it leverages up returns in good times, and leverages up risk in bad times. A debt-laden company that suddenly faces declining sales can cut its dividend -- but it still has to make its interest payments, and eventually its principal repayment.

Worse still, when the economy goes bad, access to additional financing gets tight -- meaning "prohibitively expensive" or "totally unavailable."

In other words, the first thing to look at when assessing bankruptcy risk is a company's debt position.

How much debt is too much?
There's no clear rule of thumb on debt, because acceptable debt positions vary by industry.

For example, IBM (NYSE:IBM), Target, and Yum! Brands (NYSE:YUM) all have debt-to-capital ratios greater than 50%. That wouldn't be out of the norm for a Steady Eddie utility that has predictable cash flows, but it is certainly cause for further investigation in a tech firm, a retailer, or a restaurant chain -- all of whose cash flows can vary widely, based on economic and competitive fluctuations.

But you can compare debt within an industry. While IBM, Target, and Yum! Brands are all stable, profitable companies, they're also taking on more balance sheet risk than lower-leveraged competitors Accenture (NYSE:ACN), Wal-Mart, and McDonald's (NYSE:MCD). That difference doesn't necessarily make one set of companies better than the other, but it does change the risk/reward trade-off.

Regardless of industry, properly assessing the risk of bankruptcy requires us to put a company's debt position in the context of its cash -- what it currently has on its balance sheet, and what it can generate. Ideally, a company can pay any debt due in the next year with cash on hand, and make its interest payments many times over with its free cash flow. (That's cash flow from operations, minus its capital expenditures.)

Remember, though, to focus on future cash flow prospects. Unless the resulting figure is a good proxy for future cash flows, we don't really care what a company generated last year -- because that's already reflected in its cash balance. That's especially true in a struggling economy, when this year's results can vary wildly from last year's.

But that's not all ...
Even a solid cash and debt position can be undermined by other red flags.

There are the corporate landmines to watch out for: Does the company have an underfunded pension plan? Is it invested in risky derivatives? Does it perform in an industry that is susceptible to rapid obsolescence?

And then there's plain old corporate stupidity: Is the company buying back shares with money it should be saving to ride out the recession? Similarly, is it propping up its stock price by paying dividends, when it's clear that it needs that cash to fight for its life?

Missteps like these can push an otherwise solvent company right into the arms of bankruptcy court.

Big bucks in bankruptcy
In general, it's a good idea to stay away from the stocks of companies that are likely to end up filing for bankruptcy. By definition, they aren't stocks you can hold for the long term, and their underlying businesses have clearly experienced some missteps.

At the same time, finding a company that's priced for bankruptcy, but likely to survive, can lead to huge gains. See the multibagger returns of Sirius XM Radio (NASDAQ:SIRI) and MGM Grand (NYSE:MGM), as investors' fears of imminent bankruptcy softened earlier this year.

Still, be careful -- betting on bankruptcy is playing with fire. If you're wrong, and the company goes down, you lose it all (less whatever shareholders can eke out of a fire sale or bankruptcy court). For grisly proof, see various examples from the auto and financial industries.

In any market, it's good to keep an eye on debt, cash, and red flags before buying any stock. In a market like this one, it's essential, regardless of how cheap that stock looks. Otherwise, you'll be gambling, rather than investing.

Our Motley Fool Inside Value team spends its time separating the bargains from the bankruptcies. You can see all their recommendations by clicking here for a free 30-day trial. There's no obligation to subscribe.

Already subscribe to Inside Value? Log in here.

Anand Chokkavelu owns shares of McDonald's, Sirius XM Radio, and Accenture. Accenture, Coca-Cola, and Wal-Mart Stores are Motley Fool Inside Value selections. Coca-Cola is an Income Investor recommendation. The Fool has a disclosure policy.