example code for tail recursion and verification of its optimization