1st version of impala port of reverse.c