#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 */
scalar_t__ strlength(char *);
int strcompare(char *str1, char *str2) {
  int result = 0;
  if (strlength(str1) != strlength(str2))
    return result;
  while (*str1 && (result = ((*str1) == (*str2)))) {
    str1++;
    str2++;
  }
  return result;
}


x86 assembly (clang, -O0):
<strcompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlength@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlength@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1158 <strcompare+0x48>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <strcompare+0xb6>
jmp    115d <strcompare+0x4d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     1193 <strcompare+0x83>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x1c(%rbp)
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a3 <strcompare+0x93>
jmp    11c0 <strcompare+0xb0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115d <strcompare+0x4d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcompare>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlength@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlength@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
jne    1158 <strcompare+0x48>
mov    (%rbx),%cl
test   %cl,%cl
je     1158 <strcompare+0x48>
xor    %eax,%eax
xor    %edx,%edx
nop
cmp    (%r14,%rdx,1),%cl
jne    1158 <strcompare+0x48>
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1140 <strcompare+0x30>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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