1/* Highly optimized version for ix86, x>=6.
2   Copyright (C) 1999-2022 Free Software Foundation, Inc.
3   This file is part of the GNU C Library.
4
5   The GNU C Library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   The GNU C Library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with the GNU C Library; if not, see
17   <https://www.gnu.org/licenses/>.  */
18
19#include <sysdep.h>
20#include "asm-syntax.h"
21
22#define PARMS	4		/* no space for saved regs */
23#define STR1	PARMS
24#define STR2	STR1+4
25
26        .text
27ENTRY (strcmp)
28
29	movl	STR1(%esp), %ecx
30	movl	STR2(%esp), %edx
31
32L(oop):	movb	(%ecx), %al
33	cmpb	(%edx), %al
34	jne	L(neq)
35	incl	%ecx
36	incl	%edx
37	testb	%al, %al
38	jnz	L(oop)
39
40	xorl	%eax, %eax
41	/* when strings are equal, pointers rest one beyond
42	   the end of the NUL terminators.  */
43	ret
44
45L(neq):	movl	$1, %eax
46	movl	$-1, %ecx
47	cmovbl	%ecx, %eax
48
49	ret
50END (strcmp)
51libc_hidden_builtin_def (strcmp)
52