Electronic structure and x-ray magnetic circular dichroism in uranium compounds. I. UFe2