.include "macros.inc"

.section .text, "ax"

.global memcmp
memcmp:
/* 8038D87C 0038A7DC  38 C3 FF FF */	addi r6, r3, -1
/* 8038D880 0038A7E0  38 E4 FF FF */	addi r7, r4, -1
/* 8038D884 0038A7E4  38 85 00 01 */	addi r4, r5, 1
/* 8038D888 0038A7E8  48 00 00 30 */	b lbl_8038D8B8
lbl_8038D88C:
/* 8038D88C 0038A7EC  8C 66 00 01 */	lbzu r3, 1(r6)
/* 8038D890 0038A7F0  8C 07 00 01 */	lbzu r0, 1(r7)
/* 8038D894 0038A7F4  7C 03 00 40 */	cmplw r3, r0
/* 8038D898 0038A7F8  41 82 00 20 */	beq lbl_8038D8B8
/* 8038D89C 0038A7FC  88 86 00 00 */	lbz r4, 0(r6)
/* 8038D8A0 0038A800  38 60 00 01 */	li r3, 1
/* 8038D8A4 0038A804  88 07 00 00 */	lbz r0, 0(r7)
/* 8038D8A8 0038A808  7C 04 00 40 */	cmplw r4, r0
/* 8038D8AC 0038A80C  4C 80 00 20 */	bgelr
/* 8038D8B0 0038A810  38 60 FF FF */	li r3, -1
/* 8038D8B4 0038A814  4E 80 00 20 */	blr
lbl_8038D8B8:
/* 8038D8B8 0038A818  34 84 FF FF */	addic. r4, r4, -1
/* 8038D8BC 0038A81C  40 82 FF D0 */	bne lbl_8038D88C
/* 8038D8C0 0038A820  38 60 00 00 */	li r3, 0
/* 8038D8C4 0038A824  4E 80 00 20 */	blr

.global __memrchr
__memrchr:
/* 8038D8C8 0038A828  54 84 06 3E */	clrlwi r4, r4, 0x18
/* 8038D8CC 0038A82C  7C 63 2A 14 */	add r3, r3, r5
/* 8038D8D0 0038A830  38 A5 00 01 */	addi r5, r5, 1
/* 8038D8D4 0038A834  48 00 00 10 */	b lbl_8038D8E4
lbl_8038D8D8:
/* 8038D8D8 0038A838  8C 03 FF FF */	lbzu r0, -1(r3)
/* 8038D8DC 0038A83C  7C 00 20 40 */	cmplw r0, r4
/* 8038D8E0 0038A840  4D 82 00 20 */	beqlr
lbl_8038D8E4:
/* 8038D8E4 0038A844  34 A5 FF FF */	addic. r5, r5, -1
/* 8038D8E8 0038A848  40 82 FF F0 */	bne lbl_8038D8D8
/* 8038D8EC 0038A84C  38 60 00 00 */	li r3, 0
/* 8038D8F0 0038A850  4E 80 00 20 */	blr

.global memchr
memchr:
/* 8038D8F4 0038A854  54 84 06 3E */	clrlwi r4, r4, 0x18
/* 8038D8F8 0038A858  38 63 FF FF */	addi r3, r3, -1
/* 8038D8FC 0038A85C  38 A5 00 01 */	addi r5, r5, 1
/* 8038D900 0038A860  48 00 00 10 */	b lbl_8038D910
lbl_8038D904:
/* 8038D904 0038A864  8C 03 00 01 */	lbzu r0, 1(r3)
/* 8038D908 0038A868  7C 00 20 40 */	cmplw r0, r4
/* 8038D90C 0038A86C  4D 82 00 20 */	beqlr
lbl_8038D910:
/* 8038D910 0038A870  34 A5 FF FF */	addic. r5, r5, -1
/* 8038D914 0038A874  40 82 FF F0 */	bne lbl_8038D904
/* 8038D918 0038A878  38 60 00 00 */	li r3, 0
/* 8038D91C 0038A87C  4E 80 00 20 */	blr

.global memmove
memmove:
/* 8038D920 0038A880  94 21 FF F0 */	stwu r1, -0x10(r1)
/* 8038D924 0038A884  7C 08 02 A6 */	mflr r0
/* 8038D928 0038A888  28 05 00 20 */	cmplwi r5, 0x20
/* 8038D92C 0038A88C  90 01 00 14 */	stw r0, 0x14(r1)
/* 8038D930 0038A890  93 E1 00 0C */	stw r31, 0xc(r1)
/* 8038D934 0038A894  7C 7F 1B 78 */	mr r31, r3
/* 8038D938 0038A898  7F E6 22 78 */	xor r6, r31, r4
/* 8038D93C 0038A89C  7C C0 00 34 */	cntlzw r0, r6
/* 8038D940 0038A8A0  7F E0 00 30 */	slw r0, r31, r0
/* 8038D944 0038A8A4  54 07 0F FE */	srwi r7, r0, 0x1f
/* 8038D948 0038A8A8  41 80 00 40 */	blt lbl_8038D988
/* 8038D94C 0038A8AC  54 C0 07 BF */	clrlwi. r0, r6, 0x1e
/* 8038D950 0038A8B0  41 82 00 1C */	beq lbl_8038D96C
/* 8038D954 0038A8B4  2C 07 00 00 */	cmpwi r7, 0
/* 8038D958 0038A8B8  40 82 00 0C */	bne lbl_8038D964
/* 8038D95C 0038A8BC  48 00 01 41 */	bl __copy_longs_unaligned
/* 8038D960 0038A8C0  48 00 00 20 */	b lbl_8038D980
lbl_8038D964:
/* 8038D964 0038A8C4  48 00 00 89 */	bl __copy_longs_rev_unaligned
/* 8038D968 0038A8C8  48 00 00 18 */	b lbl_8038D980
lbl_8038D96C:
/* 8038D96C 0038A8CC  2C 07 00 00 */	cmpwi r7, 0
/* 8038D970 0038A8D0  40 82 00 0C */	bne lbl_8038D97C
/* 8038D974 0038A8D4  48 00 02 99 */	bl __copy_longs_aligned
/* 8038D978 0038A8D8  48 00 00 08 */	b lbl_8038D980
lbl_8038D97C:
/* 8038D97C 0038A8DC  48 00 01 E5 */	bl __copy_longs_rev_aligned
lbl_8038D980:
/* 8038D980 0038A8E0  7F E3 FB 78 */	mr r3, r31
/* 8038D984 0038A8E4  48 00 00 54 */	b lbl_8038D9D8
lbl_8038D988:
/* 8038D988 0038A8E8  2C 07 00 00 */	cmpwi r7, 0
/* 8038D98C 0038A8EC  40 82 00 28 */	bne lbl_8038D9B4
/* 8038D990 0038A8F0  38 64 FF FF */	addi r3, r4, -1
/* 8038D994 0038A8F4  38 9F FF FF */	addi r4, r31, -1
/* 8038D998 0038A8F8  38 A5 00 01 */	addi r5, r5, 1
/* 8038D99C 0038A8FC  48 00 00 0C */	b lbl_8038D9A8
lbl_8038D9A0:
/* 8038D9A0 0038A900  8C 03 00 01 */	lbzu r0, 1(r3)
/* 8038D9A4 0038A904  9C 04 00 01 */	stbu r0, 1(r4)
lbl_8038D9A8:
/* 8038D9A8 0038A908  34 A5 FF FF */	addic. r5, r5, -1
/* 8038D9AC 0038A90C  40 82 FF F4 */	bne lbl_8038D9A0
/* 8038D9B0 0038A910  48 00 00 24 */	b lbl_8038D9D4
lbl_8038D9B4:
/* 8038D9B4 0038A914  7C 64 2A 14 */	add r3, r4, r5
/* 8038D9B8 0038A918  7C 9F 2A 14 */	add r4, r31, r5
/* 8038D9BC 0038A91C  38 A5 00 01 */	addi r5, r5, 1
/* 8038D9C0 0038A920  48 00 00 0C */	b lbl_8038D9CC
lbl_8038D9C4:
/* 8038D9C4 0038A924  8C 03 FF FF */	lbzu r0, -1(r3)
/* 8038D9C8 0038A928  9C 04 FF FF */	stbu r0, -1(r4)
lbl_8038D9CC:
/* 8038D9CC 0038A92C  34 A5 FF FF */	addic. r5, r5, -1
/* 8038D9D0 0038A930  40 82 FF F4 */	bne lbl_8038D9C4
lbl_8038D9D4:
/* 8038D9D4 0038A934  7F E3 FB 78 */	mr r3, r31
lbl_8038D9D8:
/* 8038D9D8 0038A938  80 01 00 14 */	lwz r0, 0x14(r1)
/* 8038D9DC 0038A93C  83 E1 00 0C */	lwz r31, 0xc(r1)
/* 8038D9E0 0038A940  7C 08 03 A6 */	mtlr r0
/* 8038D9E4 0038A944  38 21 00 10 */	addi r1, r1, 0x10
/* 8038D9E8 0038A948  4E 80 00 20 */	blr