Coverted the code to use LoopPass instead of FunctionPass