#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 tolower(char const);
int startsWithNoCase(const char *start, const char *string) {
  char c;
  int i;
  for (i = 0;; i += 1) {
    if ((c = tolower(start[i])) == 0)
      return 1;
    if (tolower(string[i]) != c)
      return 0;
  }
}


x86 assembly (clang, -O0):
<startsWithNoCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
jne    1153 <startsWithNoCase+0x43>
movl   $0x1,-0x4(%rbp)
jmp    1192 <startsWithNoCase+0x82>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
movsbl %al,%eax
movsbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
je     117f <startsWithNoCase+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    1192 <startsWithNoCase+0x82>
jmp    1184 <startsWithNoCase+0x74>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1127 <startsWithNoCase+0x17>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startsWithNoCase>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r12
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    $0x1,%r14d
test   %al,%al
je     1168 <startsWithNoCase+0x58>
mov    %eax,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbp,1),%edi
call   1030 <tolower@plt>
cmp    %bl,%al
jne    1165 <startsWithNoCase+0x55>
movsbl 0x1(%r12,%rbp,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebx
add    $0x1,%rbp
test   %al,%al
jne    1140 <startsWithNoCase+0x30>
jmp    1168 <startsWithNoCase+0x58>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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