Simplify function in C extension