lightrec: Move lightrec_code_inv() out of glue code