The bugleg is split into several parts, for finding foot and knee positions.
Foot positions are calculated through a couple of macros which differ in the treatment of the leg as it is moved off of the ground.
There are macros for the calculation of knees given foot and hip positions. Either one or two knee positions can be found for a leg.