#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 *);
int strncmp(char const *, char const *, size_t);
int git_release_string_utility_startswith(const char *string,
                                          const char *prefix) {
  if (!string || !prefix) {
    return 0;
  }
  size_t stringlen = strlen(string);
  size_t prefixlen = strlen(prefix);
  if (prefixlen > stringlen) {
    return 1;
  }
  return strncmp(string, prefix, prefixlen);
}


x86 assembly (clang, -O0):
<git_release_string_utility_startswith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <git_release_string_utility_startswith+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <git_release_string_utility_startswith+0x32>
movl   $0x0,-0x4(%rbp)
jmp    119a <git_release_string_utility_startswith+0x7a>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1186 <git_release_string_utility_startswith+0x66>
movl   $0x1,-0x4(%rbp)
jmp    119a <git_release_string_utility_startswith+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<git_release_string_utility_startswith>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
test   %rdi,%rdi
je     1154 <git_release_string_utility_startswith+0x34>
mov    %rsi,%r14
test   %rsi,%rsi
je     1154 <git_release_string_utility_startswith+0x34>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rdx
mov    $0x1,%eax
cmp    %r15,%rdx
jbe    115a <git_release_string_utility_startswith+0x3a>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strncmp@plt>

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

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