	.section	.text
	.intel_syntax
	.global	strcpy
	.type	strcpy, @function
strcpy:
	push	%ebp
	mov	%ebp, %esp
	push	%esi			# Must preserve %esi and %edi
	push	%edi
	mov	%esi, [%ebp + 12]	# source
	mov	%ecx, [%esi - 4]	# Length of source
	mov	%edi, [%ebp + 8]	# destination
	mov	[%edi - 4], %ecx	# Set length of destination
	add	%ecx, 1			# Increase length by one for null byte
	test	%ecx, 1
	jz	strcpy.even		# lowest bit clear
	mov	%al, [%esi]
	mov	[%edi], %al		# *destination = *source
	add	%esi, 1			# source = source + 1
	add	%edi, 1			# destination = destination + 1
strcpy.even:
	shr	%ecx, 1			# Divide by two
	cld				# Clear DF for up-memory write
	rep	movsw			# Blast the string into the buffer
	pop	%edi			# Restore saved registers
	pop	%esi
	pop	%ebp
	ret
