Assuming a purely non-optimizing compiler, is there any difference in machine code between initializing a variable and assigning it a value after declaration?
The behavior must be identical, but any differences in the generated code really depend on the compiler.
For example, the compiler could generate this for the initialized variable:
somefunction:
pushl %ebp
movl %esp, %ebp
pushl $2 ; allocate space for x and store 2 in it
...
and this for the uninitialized, but later assigned variable:
somefunction:
pushl %ebp
movl %esp, %ebp
subl $4, %esp ; allocate space for x
...
movl $2, -4(%ebp) ; assign 2 to x
...
The C standard does not mandate the generated code to be identical or non-identical in these cases. It only mandates identical behavior of the program in these two cases. And that identical behavior does not necessarily imply identical machine code.