PROF: An LLM-based Reward Code Preference Optimization Framework for Offline Imitation Learning