Overwrite one of the arrays passed with the result, and return that. That requires main() to allocate enough memory for the array that will be overwritten, so it can hold the result.

Alternately,...