Given that the RDI is a pointer to the beginning of the structure (the first parameter of the function), the next line gets the value s->aand puts it in the temporary EAX register.
mov (%rdi),%eax
It is permissible that this may be int x = s->a. This line:
lea (%rax,%rax,2),%eax
, temp 3, RAX + RAX * 2 = 3 * RAX ( , s- > a * 3). , :
int x = s->a * 3;
mov %eax,(%rdi) x s- > a, :
s->a = x;
addl $0x7,0x4(%rdi) 7 4 (RDI). 4 (RDI) - s- > b. s->b += 7;.
, ? EAX, EAX - , , x = s->a * 3;. , x.
:
int mystery(struct my_struct *s)
{
int x = s->a * 3;
s->a = x;
s->b += 7;
return x;
}
GCC 4.9.x godbolt -O1, :
mystery:
movl (%rdi), %eax
leal (%rax,%rax,2), %eax
movl %eax, (%rdi)
addl $7, 4(%rdi)
ret
, . GCC 4.9.x, , , .
. - SO mystery, GCC 4.9.x -O1 , . , , .
share