The only solution is f(x)=3x.
When f(x)=3x, we have
f(3x−1−f(x))=f(−1)=−3=3(−1)=3(f(x)−1−3x).
Also, xf(x)=3 is a constant. So f(x)=3x is a solution.
Now, we show that this is the only solution. Let g(x)=3x−1−f(x) for any x∈R. If g(x)=0 and x=0, then f(x)=3x−1 and so xf(x)=3−x1. By condition (i), there are finitely many x such that g(x)=0.
For those x∈R with g(x)=0, we rewrite condition (ii) as follows:
g(x)f(g(x))=3x−1−f(x)3(f(x)−1−3x)=−3−3x−1−f(x)6=−3−g(x)6.
By condition (i), the left-hand side only takes finitely many values. This implies g(x) only takes finitely many values (possibly 0).
Consider any y∈R such that ∣f(y)−3y∣=∣g(y)+1∣ is maximized. For this y, we use (ii) to obtain
f(g(y))−3g(y)=3(f(y)−1−3y)−3(3y−1−f(y))=6(f(y)−3y).
This implies ∣f(g(y))−3g(y)∣=6∣f(y)−3y∣. By the choice of y, we must have f(y)−3y=0. Since y is chosen to maximize ∣f(y)−3y∣, we can only have f(x)=3x for any x∈R.