#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*/ strlen(char *);
int strncmp(char *, char *, int /*<<< orphan*/);
int strnicmp(char *, char *, int /*<<< orphan*/);
int StartsWith(char *str, char *startsWith, int ignoreCase) {
  int cmp;
  if (ignoreCase != 0) {
    cmp = strnicmp(str, startsWith, strlen(startsWith));
  } else {
    cmp = strncmp(str, startsWith, strlen(startsWith));
  }
  if (cmp == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<StartsWith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117d <StartsWith+0x4d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <strnicmp@plt>
mov    %eax,-0x20(%rbp)
jmp    11a8 <StartsWith+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11be <StartsWith+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <StartsWith+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StartsWith>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
test   %ebp,%ebp
je     1157 <StartsWith+0x27>
call   1040 <strnicmp@plt>
jmp    115c <StartsWith+0x2c>
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @StartsWith(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @strnicmp(i8* %12, i8* %13, i32 %15)
store i32 %16, i32* %8
br label %23
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @strncmp(i8* %18, i8* %19, i32 %21)
store i32 %22, i32* %8
br label %23
23: ; preds = %17, %11
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1, i32* %4
br label %28
27: ; preds = %23
store i32 0, i32* %4
br label %28
28: ; preds = %27, %26
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @StartsWith(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = tail call i32 @strlen(i8* %1)
br i1 %4, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @strnicmp(i8* %0, i8* %1, i32 %5)
br label %10
8: ; preds = %3
%9 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %5)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
ret i32 %13
}