The transform:
llvm.lifetime.start(%tmp5) llvm.lifetime.memcpy(%arg1, %tmp5)
->
llvm.lifeitme.memcpy(%arg1, %tmp5) llvm.lifetime.start(%arg1)
is wrong, since then lifetime.start doesn't operate on an alloca, and lifetime.start and lifetime.end don't match anymore.