#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 stringLength_a(char *);
int strcmp_a(char str1[], char str2[]) {
  printf("string1 = %s \t string2 = %s \n", str1, str2);
  int str1Length = stringLength_a(str1);
  int str2Length = stringLength_a(str2);
  int index = 0;
  int result = 0;
  if (str1Length != str2Length) {
    return result;
  } else {
    while (index < str1Length) {
      if (str1[index] != str2[index]) {
        return result;
      } else {
        index++;
      }
    }
  }
  result = 1;
  return result;
}


x86 assembly (clang, -O0):
<strcmp_a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <stringLength_a@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <stringLength_a@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1181 <strcmp_a+0x61>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11dd <strcmp_a+0xbd>
jmp    1186 <strcmp_a+0x66>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11cb <strcmp_a+0xab>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11bd <strcmp_a+0x9d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11dd <strcmp_a+0xbd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <strcmp_a+0x66>
jmp    11d0 <strcmp_a+0xb0>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_a>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xecf(%rip),%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
mov    %rbp,%rdi
call   1040 <stringLength_a@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <stringLength_a@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%ebx
jne    1188 <strcmp_a+0x68>
mov    $0x1,%eax
test   %ebx,%ebx
jle    1188 <strcmp_a+0x68>
mov    %ebx,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x0(%rbp,%rdx,1),%ebx
cmp    (%r14,%rdx,1),%bl
jne    1186 <strcmp_a+0x66>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1170 <strcmp_a+0x50>
jmp    1188 <strcmp_a+0x68>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"string1 = %s \09 string2 = %s \0A\00"
define i32 @strcmp_a(i8* %0, i8* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%4 = tail call i32 @stringLength_a(i8* %0)
%5 = tail call i32 @stringLength_a(i8* %1)
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %21
9: ; preds = %7
%10 = zext i32 %4 to i64
br label %13
11: ; preds = %13
%12 = icmp eq i64 %20, %10
br i1 %12, label %21, label %13
13: ; preds = %9, %11
%14 = phi i64 [ 0, %9 ], [ %20, %11 ]
%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 %11, label %21
21: ; preds = %13, %11, %7, %2
%22 = phi i32 [ 0, %2 ], [ 1, %7 ], [ 0, %13 ], [ 1, %11 ]
ret i32 %22
}