Legumes have an enzyme called phaseolamine that prevents the breakdown of some of the starches in beans (and lentils) to sugars that can be absorbed. So the starches pass to the large intestine where, alas, there are bacteria and fungi that can readily break it down...to sugars, alcohols and then to eruptible CARBON DIOXIDE.
This enzyme is used as a diet aid.
The GOOD part is that we don't get all the calories that are listed for the lentils, some is shared with those around us


...isn't that nice (for us anywway)?