ir_flatten function

Converts objects of class ir to objects of class ir_flat