#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 */
size_t strlen(char const *);
scalar_t__ toupper(char const);
int startwith_incensitive(char *source, const char *pattern) {
  size_t len = strlen(pattern);
  for (int i = 0; i < len; i++) {
    if (toupper(source[i]) != toupper(pattern[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<startwith_incensitive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a7 <startwith_incensitive+0x87>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1194 <startwith_incensitive+0x74>
movl   $0x0,-0x4(%rbp)
jmp    11ae <startwith_incensitive+0x8e>
jmp    1199 <startwith_incensitive+0x79>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <startwith_incensitive+0x24>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startwith_incensitive>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11a2 <startwith_incensitive+0x82>
mov    %rax,%r13
movsbl (%r14),%edi
call   1030 <toupper@plt>
mov    %rax,%r12
movsbl (%r15),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r12
jne    11a7 <startwith_incensitive+0x87>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rbx
cmp    %rcx,%r13
je     1198 <startwith_incensitive+0x78>
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%r12
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
lea    0x1(%rbx),%rcx
cmp    %rax,%r12
je     1170 <startwith_incensitive+0x50>
xor    %eax,%eax
cmp    %rbx,%r13
setbe  %al
jmp    11a7 <startwith_incensitive+0x87>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @startwith_incensitive(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %26, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = tail call i64 @toupper(i8 signext %6)
%8 = load i8, i8* %1
%9 = tail call i64 @toupper(i8 signext %8)
%10 = icmp eq i64 %7, %9
br i1 %10, label %11, label %26
11: ; preds = %5, %14
%12 = phi i64 [ %22, %14 ], [ 1, %5 ]
%13 = icmp eq i64 %12, %3
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = load i8, i8* %15
%17 = tail call i64 @toupper(i8 signext %16)
%18 = getelementptr inbounds i8, i8* %1, i64 %12
%19 = load i8, i8* %18
%20 = tail call i64 @toupper(i8 signext %19)
%21 = icmp eq i64 %17, %20
%22 = add nuw i64 %12, 1
br i1 %21, label %11, label %23
23: ; preds = %11, %14
%24 = icmp ule i64 %3, %12
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %23, %5, %2
%27 = phi i32 [ 1, %2 ], [ 0, %5 ], [ %25, %23 ]
ret i32 %27
}