generating IR code for loop statement