more flexible code generation functions

Now the code-gen allows generating reduction functions that may contain more than one input arrays.