#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 strlen(char *);
int strcmp(char *s1, char *s2) {
  int len = strlen(s1);
  if (len != strlen(s2))
    return 1;
  for (int i = 0; i < strlen(s1); i++) {
    if (s1[i] != s2[i])
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
je     1154 <strcmp+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11bd <strcmp+0xad>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11b6 <strcmp+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11a3 <strcmp+0x93>
movl   $0x1,-0x4(%rbp)
jmp    11bd <strcmp+0xad>
jmp    11a8 <strcmp+0x98>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <strcmp+0x4b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    %eax,%r15d
jne    1171 <strcmp+0x61>
mov    %rbp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    116e <strcmp+0x5e>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rbx,1),%eax
cmp    (%r12,%rbx,1),%al
jne    1171 <strcmp+0x61>
add    $0x1,%rbx
mov    %rbp,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <strcmp+0x40>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
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 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %41
15: ; preds = %2
store i32 0, i32* %7
br label %16
16: ; preds = %37, %15
%17 = load i32, i32* %7
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %40
21: ; preds = %16
%22 = load i8*, i8** %4
%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 = sext i8 %26 to i32
%28 = load i8*, i8** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %27, %33
br i1 %34, label %35, label %36
35: ; preds = %21
store i32 1, i32* %3
br label %41
36: ; preds = %21
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %16
40: ; preds = %16
store i32 0, i32* %3
br label %41
41: ; preds = %40, %35, %14
%42 = load i32, i32* %3
ret i32 %42
}

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