In the following example:

```
int main(void) {
    int a=7;
    {
        int a=8;
    }
}

```

The generated assembly would be something like this (from Compiler Explorer) without optimizations:

```
main:
        pushq   %rbp
        movq    %rsp, %rbp
        movl    $7, -4(%rbp)   // outer scope: int a=7
        movl    $8, -8(%rbp)   // inner scope: int a=8 
        movl    $0, %eax
        popq    %rbp
        ret

```

How does the compiler know where the variable is if there are duplicately-named variables? That is, when in the inner scope, the memory address is at `%rbp-8` and when in the outer scope the address is at `%rbp-4`.