	.section	.text
	.intel_syntax
	.global	strrev
strrev:
	push	%ebp
	mov	%ebp, %esp
	sub	%esp, 16		# Allocate space
	mov	dword ptr [%ebp - 4], 0	# start = 0
	mov	%eax, [%ebp + 8]	# %eax = string
	mov	%eax, [%eax - 4]	# length of string
	dec	%eax
	mov	[%ebp - 8], %eax	# end = length 1 -
	jmp	strrev.compare
strrev.swap:
	mov	%edx, [%ebp + 8]	# %edx = string
	add	%eax, %edx
	mov	%al, [%eax]
	mov	[%ebp - 12], %eax	# temp = string[start]
	mov	%eax, [%ebp - 8]	# %eax = end
	add	%eax, %edx
	mov	%ecx, [%ebp - 4]	# %ecx = start
	add	%ecx, %edx
	mov	%al, [%eax]
	mov	[%ecx], %al		# string[start] = string[end]
	mov	%eax, [%ebp - 8]	# %eax = end
	add	%eax, %edx
	mov	%edx, [%ebp - 12]	# %edx = temp
	mov	[%eax], %dl		# string[end] = temp
	dec	dword ptr [%ebp - 8]	# end = end - 1
	inc	dword ptr [%ebp - 4]	# start = start + 1
strrev.compare:
	mov	%eax, [%ebp - 4]
	cmp	%eax, [%ebp - 8]
	jb	strrev.swap		# end > start
	mov	%esp, %ebp		# Deallocate space
	pop	%ebp
	ret
