You use shadow catchers-- the catch is, in C2 at least, and I think in C3 too, shadow catching doesn't work with anything but standard light sources (spot, bulb...). You create a rough approximation of the environment in 3d, on the properties tab, switch 'shadow catcher' on for every object that simulates a surface, and set the textures on the objects to be black with no highlight-- else the shadows will look odd. You can get a pretty nice composite with it, but as I said, I don't think it will work with the HDRI lighting. The image shows a composite I did entirely in Carrara, which turned out decent-- a wire frame of the scene, the background image, and the result.
EMC