	.section	.text
	.global	memcmp
	.type	memcmp, @function
memcmp:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$16, %esp		# Allocate space
	movl	$0, -12(%ebp)		# index = 0
	movl	8(%ebp), %eax
	movl	%eax, -8(%ebp)		# cs = cs_in
	movl	12(%ebp), %eax
	movl	%eax, -4(%ebp)		# ct = ct_in
	jmp	is_index_less
is_cs_less_than_ct:
	movl	-8(%ebp), %eax
	movzbl	(%eax), %edx		# Load *cs
	movl	-4(%ebp), %eax
	movzbl	(%eax), %eax		# Load *ct
	cmpb	%al, %dl
	jge	is_cs_greater_than_ct	# *cs < *ct
	movl	$-1, %eax		# Return negative one
	jmp	end
is_cs_greater_than_ct:
	movl	-8(%ebp), %eax
	movzbl	(%eax), %edx		# Load *cs
	movl	-4(%ebp), %eax
	movzbl	(%eax), %eax		# Load *ct
	cmpb	%al, %dl
	jle	increment_index		# *cs > *ct
	movl	$1, %eax		# Return one
	jmp	end
increment_index:
	addl	$1, -12(%ebp)		# index++
	addl	$1, -8(%ebp)		# cs++
	addl	$1, -4(%ebp)		# ct++
is_index_less:
	movl	-12(%ebp), %eax
	cmpl	16(%ebp), %eax
	jb	is_cs_less_than_ct	# index < len
	movl	$0, %eax		# Return zero
end:
	movl	%ebp, %esp		# "addl $16, %esp" works too
	popl	%ebp
	ret
