Here's the C code:
int baz(int a, int b)
{
return a * 11;
}
That is compiled to the following set of assembly instructions (with -O2 flag):
baz(int, int):
lea eax, [rdi+rdi*4]
lea eax, [rdi+rax*2]
ret
The lea instruction computes the effective address of the second operand (the source operand) and stores it in the first operand. To me, it seems that the first instruction should load an address to the EAX register, but, if so, multiplying RAX by 2 does not make sense in the second lea instruction, so I infer that these two lea instructions do not do quite the same thing.
I was wondering if someone could clarify what exactly is happening here.