#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 */
char const tolower(char const);
int strcmp1(const char *s1, const char *s2) {
  size_t i = 0;
  while (s2[i] != '\0') {
    if (tolower(s1[i]) != s2[i])
      return 1;
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strcmp1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1182 <strcmp1+0x72>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
movsbl %al,%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1171 <strcmp1+0x61>
movl   $0x1,-0x4(%rbp)
jmp    1189 <strcmp1+0x79>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <strcmp1+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp1>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rsi)
je     114c <strcmp1+0x3c>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
cmp    (%r15,%rbx,1),%al
jne    1150 <strcmp1+0x40>
cmpb   $0x0,0x1(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1130 <strcmp1+0x20>
xor    %eax,%eax
jmp    1155 <strcmp1+0x45>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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