What is this code doing exactly?

pushl %ebp
movl %esp, %ebp
subl $20, %esp
movl $0, -4(%ebp)
jmp .L2
movl -4(%ebp), %eax
sall $2, %eax
addl 8(%ebp), %eax
movl (%eax), %eax
cmpl 16(%ebp), %eax
jne .L4
movl $1, -20(%ebp)
jmp .L6
addl $1, -4(%ebp)
movl -4(%ebp), %eax
cmpl 12(%ebp), %eax
jl .L3
movl $0, -20(%ebp)
movl -20(%ebp), %eax

Sounds like a class problem.

On a piece of paper create rows

Passed Arguments

Mark which one of these is your return address, and your passed in arguments, your temporary local arguments and then single-step your code!

Anything else before you do that would be doing your homework for you!