#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 */
int slen(unsigned char const *);
int strcmp(const unsigned char *x, const unsigned char *y) {
  unsigned int length = slen(x) - 1;
  int i = 0;
  while (i < length) {
    if (x[i] != y[i])
      return 0;
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <slen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    117c <strcmp+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     116e <strcmp+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    1183 <strcmp+0x73>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1136 <strcmp+0x26>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <slen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
add    $0xffffffff,%ecx
je     1148 <strcmp+0x38>
mov    %ecx,%ecx
xor    %edx,%edx
movzbl (%r15,%rdx,1),%ebx
cmp    (%r14,%rdx,1),%bl
jne    1146 <strcmp+0x36>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1130 <strcmp+0x20>
jmp    1148 <strcmp+0x38>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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