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?