#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 */
typedef int /*<<< orphan*/ string2;
typedef int /*<<< orphan*/ string1;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int stringEquals(char *string1, char *string2) {
  if (sizeof(string1) != sizeof(string2)) {
    printf("%s", "not the same size!");
    return 0;
  }
  for (int i = 0; i < sizeof(string1); i++) {
    if (string1[i] != string2[i]) {
      printf("%s", string1);
      printf("%s", " And ");
      printf("%s\n", string2);
      printf("%s", "didn't match");
      return 0;
    }
  }
  printf("%s", string1);
  printf("%s", " And ");
  printf("%s\n", string2);
  printf("%s\n\n", "matched");
  return 0;
}


x86 assembly (clang, -O0):
<stringEquals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x8,%rax
jae    11ba <stringEquals+0xaa>
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     11a7 <stringEquals+0x97>
mov    -0x10(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1207 <stringEquals+0xf7>
jmp    11ac <stringEquals+0x9c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <stringEquals+0x17>
mov    -0x10(%rbp),%rsi
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2f(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
lea    0xe26(%rip),%rdi
lea    0xe24(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringEquals>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rsi
mov    (%rdi),%al
cmp    (%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x1(%rsi),%al
cmp    0x1(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x2(%rsi),%al
cmp    0x2(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x3(%rsi),%al
cmp    0x3(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x4(%rsi),%al
cmp    0x4(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x5(%rsi),%al
cmp    0x5(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x6(%rsi),%al
cmp    0x6(%r15),%al
jne    119e <stringEquals+0x8e>
mov    0x7(%rsi),%al
cmp    0x7(%r15),%al
jne    119e <stringEquals+0x8e>
lea    0xe98(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xe8c(%rip),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
lea    0xe83(%rip),%rsi
jmp    11d5 <stringEquals+0xc5>
lea    0xe5b(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c" And \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [13 x i8] c"didn't match\00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
@.str.5 = [8 x i8] c"matched\00"
define i32 @stringEquals(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 = %33, %2
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 8
br i1 %10, label %11, label %36
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %17, %23
br i1 %24, label %25, label %32
25: ; preds = %11
%26 = load i8*, i8** %4
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %5
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %43
32: ; preds = %11
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %7
36: ; preds = %7
%37 = load i8*, i8** %4
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%40 = load i8*, i8** %5
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %43
43: ; preds = %36, %25
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c" And \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [13 x i8] c"didn't match\00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
@.str.5 = [8 x i8] c"matched\00"
define i32 @stringEquals(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %53
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %8, %10
br i1 %11, label %12, label %53
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 2
%16 = load i8, i8* %15
%17 = icmp eq i8 %14, %16
br i1 %17, label %18, label %53
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %1, i64 3
%22 = load i8, i8* %21
%23 = icmp eq i8 %20, %22
br i1 %23, label %24, label %53
24: ; preds = %18
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %1, i64 4
%28 = load i8, i8* %27
%29 = icmp eq i8 %26, %28
br i1 %29, label %30, label %53
30: ; preds = %24
%31 = getelementptr inbounds i8, i8* %0, i64 5
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %1, i64 5
%34 = load i8, i8* %33
%35 = icmp eq i8 %32, %34
br i1 %35, label %36, label %53
36: ; preds = %30
%37 = getelementptr inbounds i8, i8* %0, i64 6
%38 = load i8, i8* %37
%39 = getelementptr inbounds i8, i8* %1, i64 6
%40 = load i8, i8* %39
%41 = icmp eq i8 %38, %40
br i1 %41, label %42, label %53
42: ; preds = %36
%43 = getelementptr inbounds i8, i8* %0, i64 7
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %1, i64 7
%46 = load i8, i8* %45
%47 = icmp eq i8 %44, %46
br i1 %47, label %48, label %53
48: ; preds = %42
%49 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%50 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%51 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%52 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %58
53: ; preds = %42, %36, %30, %24, %18, %12, %6, %2
%54 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%55 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%56 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%57 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %53, %48
ret i32 0
}