Number of loops in a region


I was wondering if there is a way to count the number of loops contained in a region.

For example in a program like this:


While not a complete solution, I believe the LoopInfo analysis pass will get you part of the way there.