How do companies find out how many calories are in their food? In the United States, virtually every food that I buy from a grocery store has Nutrition Facts on it that contain the calorie count on it. For instance, the label on a granola bar might say that it has 150 Calories.

According to Wikipedia, a Calorie (with a capital C, also called a kilocalorie) is the amount of energy needed to raise the temperature of one kilogram of water by one degree. However, it's not clear to me how companies would figure out how this translates to the Calorie count of their granola bar. I presume they don't just incinerate the food. Also, I'm guessing that they could ship off packaged foods somewhere to have it measured, but that wouldn't work for restaurant prepared foods.

There was a similar question titled How to calculate the calorie content of cooked food?, but it was focused on home food and relied on estimation. I presume that companies need to be much more precise in order to meet regulations.

So how do companies find out how many calories are in their food?
These days, mostly software. In the good/bad old days, by actually burning it (or having a laboratory do that for them). Software is much simpler (unless you are writing it, though it is probably more tedious than complex.)

Input ingredients and quantities, out comes calories. For a restaurant that assumes that the recipe used for calculation matches the actual recipe used.

Here is a USDA database, for instance. Tedious to use, but gives the idea.
http://ndb.nal.usda.gov/ndb/nutrients/index