Replace call to `functor/3` + `arg/3` with `=../2`, which seems to be faster nowadays for most backend Prolog compilers