Ive done this thought exercise from time to time too. The S65 weighs a shade under 15 kilos more than the N54. But its lower and further back.
My logic goes like this. Both engines were designed for the 3 series chassis. So why would it be difficult to interchange anything? Theoretically its a straight swap. Maybe a hammer needs to be taken to the floor pan and maybe 1 or two clearances are off...but in my head it seems simple.
Find an M3 that was totaled with a rear end collision or a rollover and start from there.
Motorsport Photographer, PM for Pricing on Car Shoots - mattkalish.com