#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 strlen(char const *);
scalar_t__ tolower(char const);
int http_utils_str_starts_with(const char *str, const char *start) {
  int i;
  int match_str_len = strlen(str);
  int start_len = strlen(start);
  if (start_len > match_str_len) {
    return -1;
  }
  for (i = 0; i < start_len; i++) {
    if (tolower(str[i]) != tolower(start[i])) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<http_utils_str_starts_with>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1160 <http_utils_str_starts_with+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cf <http_utils_str_starts_with+0xaf>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c8 <http_utils_str_starts_with+0xa8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11b5 <http_utils_str_starts_with+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11cf <http_utils_str_starts_with+0xaf>
jmp    11ba <http_utils_str_starts_with+0x9a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <http_utils_str_starts_with+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_utils_str_starts_with>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ebp,%ecx
jg     118e <http_utils_str_starts_with+0x6e>
test   %ecx,%ecx
jle    1185 <http_utils_str_starts_with+0x65>
mov    %ecx,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rbp
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
cmp    %rax,%rbp
jne    1189 <http_utils_str_starts_with+0x69>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <http_utils_str_starts_with+0x40>
xor    %eax,%eax
jmp    118e <http_utils_str_starts_with+0x6e>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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