So first i assign edx = y by doing movl 12(%ebp) %edx.
why does leal (%edx, %edx, 2) , %edx
= edx = 3*y
LEA
is short for "Load Effective Address". (In AT&T syntax, it is spelled "leal" for 32-bit operands.) Basically it takes the address that it calculates given the stuff in parentheses, and instead of reading or writing memory, assigns the address itself to the destination operand.
It's often used for doing address calculations, but just as often used for multiplication by certain integer constants (3, 5, and 9) by pretending a number is an address. (Addresses are just numbers, so it's not at all hard.)