	.section	.text
	.global	memcmp
	.type	memcmp, %function
memcmp:
	sub	sp, sp, #20
	str	r0, [sp, #12]		@ Save cs
	str	r1, [sp, #8]		@ Save ct
	str	r2, [sp, #4]		@ Save length
	movs	r0, #0
	str	r0, [sp, #16]		@ index = zero
	b	begin
is_cs_less_than_ct:
	ldr	r0, [sp, #12]		@ Load cs
	ldrb	r1, [r0]		@ r1 = *r0
	ldr	r0, [sp, #8]		@ Load ct
	ldrb	r0, [r0]		@ r0 = *r0
	cmp	r1, r0			@ *cs < *ct
	bcs	is_cs_greater_than_ct
	mov	r0, #-1			@ Return negative one
	b	end
is_cs_greater_than_ct:
	ldr	r0, [sp, #12]		@ Load cs
	ldrb	r1, [r0]		@ r1 = *r0
	ldr	r0, [sp, #8]		@ Load ct
	ldrb	r0, [r0]		@ r0 = *r0
	cmp	r1, r0			@ *cs > *ct
	bls	increment
	movs	r0, #1			@ Return one
	b	end
increment:
	ldr	r0, [sp, #16]		@ Load index
	adds	r0, r0, #1
	str	r0, [sp, #16]		@ index++
	ldr	r1, [sp, #12]		@ Load cs
	adds	r1, r1, #1
	str	r1, [sp, #12]		@ cs++
	ldr	r1, [sp, #8]		@ Load ct
	adds	r1, r1, #1
	str	r1, [sp, #8]		@ ct++
begin:
	ldr	r1, [sp, #4]		@ Load length
	cmp	r0, r1			@ index < length
	bcc	is_cs_less_than_ct
	mov	r0, #0			@ Return zero
end:
	add	sp, sp, #20
	mov	pc, lr			@ Return
