leal
is a way to perform a multiplication by a small constant on a cheap, if the constant is a power of two plus one. The idea is that leal without an offset is equivalent to "Reg1 = Reg2+Reg3*Scale". If Reg2 and Reg3 happen to match, that means "Reg1=Reg2*(Scale+1).
leal
only supports scale factors up to 8, so to multiply by 19, you need two.
The effect of
leal (%eax,%eax,2), %eax
is:
eax = eax + eax*2
which is to say, multiplication by three.
The second two leal
s together perform multiplication by 19:
leal (%ecx,%ecx,8), %edx // edx = ecx+ecx*8
leal (%ecx,%edx,2), %edx // edx = ecx+edx*2 (but edx is already z*9)