#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char strlen(char *);
char streq(char *x, char *y) {
  char i;
  for (i = 0; i < strlen(x); i++)
    if (x[i] != y[i])
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<streq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,%cl
mov    -0x20(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jge    1181 <streq+0x71>
mov    -0x10(%rbp),%rax
movsbq -0x19(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movsbq -0x19(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     116f <streq+0x5f>
movb   $0x0,-0x1(%rbp)
jmp    1185 <streq+0x75>
jmp    1174 <streq+0x64>
mov    -0x19(%rbp),%al
add    $0x1,%al
mov    %al,-0x19(%rbp)
jmp    1124 <streq+0x14>
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<streq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    $0x1,%r14b
test   %al,%al
jle    1155 <streq+0x45>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rbx,1),%eax
cmp    (%r15,%rbx,1),%al
jne    1152 <streq+0x42>
add    $0x1,%rbx
mov    %rbp,%rdi
call   1030 <strlen@plt>
movsbq %al,%rax
cmp    %rax,%rbx
jl     1130 <streq+0x20>
jmp    1155 <streq+0x45>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @streq(i8* %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 0, i8* %6
br label %7
7: ; preds = %30, %2
%8 = load i8, i8* %6
%9 = sext i8 %8 to i32
%10 = load i8*, i8** %4
%11 = call signext i8 @strlen(i8* %10)
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %33
14: ; preds = %7
%15 = load i8*, i8** %4
%16 = load i8, i8* %6
%17 = sext i8 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8*, i8** %5
%22 = load i8, i8* %6
%23 = sext i8 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %20, %26
br i1 %27, label %28, label %29
28: ; preds = %14
store i8 0, i8* %3
br label %34
29: ; preds = %14
br label %30
30: ; preds = %29
%31 = load i8, i8* %6
%32 = add i8 %31, 1
store i8 %32, i8* %6
br label %7
33: ; preds = %7
store i8 1, i8* %3
br label %34
34: ; preds = %33, %28
%35 = load i8, i8* %3
ret i8 %35
}

LLVM IR (-O2):
define signext i8 @streq(i8* %0, i8* nocapture %1) {
%3 = tail call signext i8 @strlen(i8* %0)
%4 = icmp sgt i8 %3, 0
br i1 %4, label %9, label %17
5: ; preds = %9
%6 = tail call signext i8 @strlen(i8* %0)
%7 = sext i8 %6 to i64
%8 = icmp slt i64 %16, %7
br i1 %8, label %9, label %17
9: ; preds = %2, %5
%10 = phi i64 [ %16, %5 ], [ 0, %2 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %12, %14
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %5, label %17
17: ; preds = %9, %5, %2
%18 = phi i8 [ 1, %2 ], [ 1, %5 ], [ 0, %9 ]
ret i8 %18
}