#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 /*<<< orphan*/ printf(char *, char *, char *);
int compareString(char *string1, char *string2) {
  int i;
  for (i = 0; i < string1[i] != '\0' && string2[i] != '\0'; i++) {
    if (string1[i] != string2[i]) {
      printf("%s is not the same as %s", string1, string2);
      return 0;
    }
  }
  printf("%s is the same as %s\n", string1, string2);
  return 1;
}


x86 assembly (clang, -O0):
<compareString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
setl   %al
and    $0x1,%al
movzbl %al,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     1163 <compareString+0x53>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1173 <compareString+0x63>
jmp    11c6 <compareString+0xb6>
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     11b3 <compareString+0xa3>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <compareString+0xd1>
jmp    11b8 <compareString+0xa8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <compareString+0x17>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareString>:
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    (%rdi),%dil
test   %dil,%dil
jle    114c <compareString+0x3c>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rdx,%rcx,1),%eax
test   %al,%al
je     114c <compareString+0x3c>
cmp    %al,%dil
jne    115f <compareString+0x4f>
movsbq 0x1(%rsi,%rcx,1),%rdi
add    $0x1,%rcx
cmp    %rdi,%rcx
jl     1130 <compareString+0x20>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%s is not the same as %s\00"
@.str.1 = [22 x i8] c"%s is the same as %s\0A\00"
define i32 @compareString(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
br label %7
7: ; preds = %47, %2
%8 = load i32, i32* %6
%9 = load i8*, i8** %4
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp slt i32 %8, %14
%16 = zext i1 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %7
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br label %26
26: ; preds = %18, %7
%27 = phi i1 [ false, %7 ], [ %25, %18 ]
br i1 %27, label %28, label %50
28: ; preds = %26
%29 = load i8*, i8** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i8*, i8** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %34, %40
br i1 %41, label %42, label %46
42: ; preds = %28
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %43, i8* %44)
store i32 0, i32* %3
br label %54
46: ; preds = %28
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %7
50: ; preds = %26
%51 = load i8*, i8** %4
%52 = load i8*, i8** %5
%53 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %52)
store i32 1, i32* %3
br label %54
54: ; preds = %50, %42
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s is not the same as %s\00"
@.str.1 = [22 x i8] c"%s is the same as %s\0A\00"
define i32 @compareString(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp sgt i8 %3, 0
br i1 %4, label %10, label %21
5: ; preds = %16
%6 = getelementptr inbounds i8, i8* %0, i64 %18
%7 = load i8, i8* %6
%8 = sext i8 %7 to i64
%9 = icmp slt i64 %18, %8
br i1 %9, label %10, label %21
10: ; preds = %2, %5
%11 = phi i64 [ %18, %5 ], [ 0, %2 ]
%12 = phi i8 [ %7, %5 ], [ %3, %2 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %11
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %10
%17 = icmp eq i8 %12, %14
%18 = add nuw nsw i64 %11, 1
br i1 %17, label %5, label %19
19: ; preds = %16
%20 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %23
21: ; preds = %10, %5, %2
%22 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ 0, %19 ], [ 1, %21 ]
ret i32 %24
}