That's a nice trick against static analysis. I imagine well an
attacker trying to fight against the first part, even if never
executed, assuming he found that this function got executed and
then he assumes that the code get executed from the start.

One of the problems is that "naked" is missing in your assembly.
If you write
asm pure nothrow
{
naked;
mov RAX, 1;
ret;
nop;nop;nop;nop;nop;nop;nop;
mov RAX, 2;
ret;
}
writeln(proc1()) works. Without "naked" dmd generates the
prologue and epilogue for your function. Inside the assembly you
return from the function without restoring the stack. It causes
the segfault. So you have to write the prologue before returning
or use nacked assembly.
With "naked" and "Proc proc2 = cast(Proc) (cast(void*)proc1 +
8);" the example works.

One of the problems is that "naked" is missing in your
assembly. If you write
asm pure nothrow
{
naked;
mov RAX, 1;
ret;
nop;nop;nop;nop;nop;nop;nop;
mov RAX, 2;
ret;
}
writeln(proc1()) works. Without "naked" dmd generates the
prologue and epilogue for your function. Inside the assembly
you return from the function without restoring the stack. It
causes the segfault. So you have to write the prologue before
returning or use nacked assembly.
With "naked" and "Proc proc2 = cast(Proc) (cast(void*)proc1 +
8);" the example works.