/	Copyright (c) 1984, 1986, 1987, 1988 AT&T
/	  All Rights Reserved

/	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
/	The copyright notice above does not evidence any
/	actual or intended publication of such source code.
	.file	"strrchr.s"

	.ident	"@(#)libc-i386:libc-i386/gen/strrchr.s	1.2"

	.globl	strrchr
	.align	4

strrchr:
	MCOUNT
	pushl	%edi		/ save register variable

	movl	8(%esp),%edi	/ %edi = address of string
	xorl	%eax,%eax	/ %eax = 0 (search for null)
	movl	$-1,%ecx	/ %ecx = a very long string
	repnz ; scab

	decl	%edi		/ post-incremented past null
	notl	%ecx		/ %ecx = length of string
	movb	12(%esp),%al	/ %esi = char sought
	std ; repnz ; scab ; cld / search backward at least one char

	jnz	.notfound
	movl	%edi,%eax
	incl	%eax		/ postdecremented.
	popl	%edi		/ restore register variable
	ret

.notfound:
	xorl	%eax,%eax
	popl	%edi
	ret
