#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 strlen1(char *);
int strcmp1(char *str1, char *str2) {
  int i, j;
  if (strlen1(str1) != strlen1(str2))
    return 0;
  for (i = 0; i < strlen1(str1); ++i) {
    if (str1[i] != str2[i])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<strcmp1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen1@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen1@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
je     114e <strcmp1+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <strcmp1+0xa7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen1@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11b0 <strcmp1+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     119d <strcmp1+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <strcmp1+0xa7>
jmp    11a2 <strcmp1+0x92>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <strcmp1+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen1@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen1@plt>
xor    %r15d,%r15d
cmp    %eax,%ebp
jne    1172 <strcmp1+0x62>
mov    %rbx,%rdi
call   1030 <strlen1@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    1172 <strcmp1+0x62>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%rbx,%rbp,1),%eax
cmp    (%r14,%rbp,1),%al
jne    116f <strcmp1+0x5f>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen1@plt>
cltq
cmp    %rax,%rbp
jl     1150 <strcmp1+0x40>
jmp    1172 <strcmp1+0x62>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strcmp1(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 @strlen1(i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @strlen1(i8* %10)
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %40
14: ; preds = %2
store i32 0, i32* %6
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %6
%17 = load i8*, i8** %4
%18 = call i32 @strlen1(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %39
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %26, %32
br i1 %33, label %34, label %35
34: ; preds = %20
store i32 0, i32* %3
br label %40
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %15
39: ; preds = %15
store i32 1, i32* %3
br label %40
40: ; preds = %39, %34, %13
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @strcmp1(i8* %0, i8* %1) {
%3 = tail call i32 @strlen1(i8* %0)
%4 = tail call i32 @strlen1(i8* %1)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = tail call i32 @strlen1(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %13, label %21
9: ; preds = %13
%10 = tail call i32 @strlen1(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 [ 0, %2 ], [ 1, %6 ], [ 0, %13 ], [ 1, %9 ]
ret i32 %22
}