#include "DEFS.h"
WEAK_ALIAS(rindex, strrchr)
ENTRY(strrchr)
RETGUARD_SETUP(strrchr, r11)
movzbq %sil,%rcx
xorq %rax,%rax
.Lalign:
testb $7,%dil
je .Lword_aligned
movb (%rdi),%dl
cmpb %cl,%dl
cmoveq %rdi,%rax
incq %rdi
testb %dl,%dl
jne .Lalign
jmp .Ldone
.Lword_aligned:
movb %cl,%ch
movq %rcx,%rdx
salq $16,%rcx
orq %rdx,%rcx
movq %rcx,%rdx
salq $32,%rcx
orq %rdx,%rcx
movabsq $0x0101010101010101,%r8
movabsq $0x8080808080808080,%r9
_ALIGN_TEXT
.Lloop:
movq (%rdi),%rdx
addq $8,%rdi
movq %rdx,%rsi
subq %r8,%rdx
xorq %rcx,%rsi
subq %r8,%rsi
orq %rsi,%rdx
testq %r9,%rdx
je .Lloop
movb -8(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -8(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -7(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -7(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -6(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -6(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -5(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -5(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -4(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -4(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -3(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -3(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -2(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -2(%rdi),%rax
1: testb %dl,%dl
je .Ldone
movb -1(%rdi),%dl
cmpb %cl,%dl
jne 1f
leaq -1(%rdi),%rax
1: testb %dl,%dl
jne .Lloop
.Ldone:
RETGUARD_CHECK(strrchr, r11)
ret
END_STRONG(strrchr)