#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*/ assert(char *);
unsigned int strings_length(char *);
bool strings_starts_with_imp(char *string, char *start,
                             bool (*equals_function)(char *, char *,
                                                     unsigned int)) {
  assert(string);
  assert(start);
  unsigned int string_length = strings_length(string),
               start_length = strings_length(start);
  if (start_length > string_length)
    return false;
  return equals_function(string, start, start_length);
}


x86 assembly (clang, -O0):
<strings_starts_with_imp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strings_length@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strings_length@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jbe    1176 <strings_starts_with_imp+0x56>
movl   $0x0,-0x4(%rbp)
jmp    118a <strings_starts_with_imp+0x6a>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   *%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strings_starts_with_imp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <assert@plt>
mov    %r14,%rdi
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1030 <strings_length@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strings_length@plt>
cmp    %ebp,%eax
jbe    1160 <strings_starts_with_imp+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    *%rax

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

LLVM IR (-O2):
define i32 @strings_starts_with_imp(i8* %0, i8* %1, i32 (i8*, i8*, i32)* nocapture %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @assert(i8* %1)
%6 = tail call i32 @strings_length(i8* %0)
%7 = tail call i32 @strings_length(i8* %1)
%8 = icmp ugt i32 %7, %6
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = tail call i32 %2(i8* %0, i8* %1, i32 %7)
br label %11
11: ; preds = %3, %9
%12 = phi i32 [ %10, %9 ], [ 0, %3 ]
ret i32 %12
}