#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__ length(char *);
scalar_t__ toLower(char);
int equalsIgnoreCase(char *str1, char *str2) {
  if (length(str1) != length(str2)) {
    return 0;
  }
  while (*str1 != '\0') {
    if (toLower(*str1) != toLower(*str2)) {
      return 0;
    }
    str1++;
    str2++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<equalsIgnoreCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <length@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <length@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1162 <equalsIgnoreCase+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <equalsIgnoreCase+0xb3>
jmp    1167 <equalsIgnoreCase+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cc <equalsIgnoreCase+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toLower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toLower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11af <equalsIgnoreCase+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <equalsIgnoreCase+0xb3>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1167 <equalsIgnoreCase+0x47>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equalsIgnoreCase>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <length@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1030 <length@plt>
xor    %r15d,%r15d
cmp    %rax,%rbp
jne    118d <equalsIgnoreCase+0x6d>
mov    (%r12),%al
mov    $0x1,%r15d
test   %al,%al
je     118d <equalsIgnoreCase+0x6d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <toLower@plt>
mov    %rax,%rbp
movsbl (%r14,%rbx,1),%edi
call   1040 <toLower@plt>
cmp    %rax,%rbp
jne    118a <equalsIgnoreCase+0x6a>
movzbl 0x1(%r12,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <equalsIgnoreCase+0x40>
jmp    118d <equalsIgnoreCase+0x6d>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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