How does dynamic memory-allocation exactly work?
Consider the following code:

int a = 8;
a = a+1;


On my system, this snippet compiles to the following code:

movl    $8, -20(%rbp)
movl    -20(%rbp), %edi
addl    $1, %edi
movl    %edi, -20(%rbp)


The register rbp points at the top of stack. The variable a is located 20 bytes below the top of stack.

The first assembly line about implements the C line int a = 8, and the rest implement a = a+1 by first loading a into the register edi, then increasing edi by 1, and then storing edi back at a.

If you want to try it out, use the following command:

cc -O0 -S &lt;progname&gt;.c


The assembly will appear in &lt;progname&gt;.s.