#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 */
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ strtolower(char *);
int is_prefix(const char *key, const char *prefix, int csens) {
  char keybuf[64 + 1];
  char prebuf[64 + 1];
  if (key == (char *)NULL)
    keybuf[0] = '\0';
  else {
    strncpy(keybuf, key, 64);
    keybuf[64] = '\0';
  }
  if (prefix == (char *)NULL)
    prebuf[0] = '\0';
  else {
    strncpy(prebuf, prefix, 64);
    prebuf[64] = '\0';
  }
  if (strlen(prebuf) == 0)
    return (0);
  if (!csens) {
    strtolower(prebuf);
    strtolower(keybuf);
  }
  if (keybuf == strstr(keybuf, prebuf))
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<is_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116a <is_prefix+0x2a>
movb   $0x0,-0x60(%rbp)
jmp    1180 <is_prefix+0x40>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1197 <is_prefix+0x57>
movb   $0x0,-0xb0(%rbp)
jmp    11b0 <is_prefix+0x70>
lea    -0xb0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x70(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    11d2 <is_prefix+0x92>
movl   $0x0,-0x4(%rbp)
jmp    1232 <is_prefix+0xf2>
cmpl   $0x0,-0x1c(%rbp)
jne    11f1 <is_prefix+0xb1>
lea    -0xb0(%rbp),%rdi
call   1050 <strtolower@plt>
lea    -0x60(%rbp),%rdi
call   1050 <strtolower@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
cmp    %rcx,%rax
jne    122b <is_prefix+0xeb>
movl   $0x1,-0x4(%rbp)
jmp    1232 <is_prefix+0xf2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prefix>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
test   %rdi,%rdi
je     1162 <is_prefix+0x32>
mov    %rdi,%rsi
lea    0x50(%rsp),%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x90(%rsp)
jmp    1167 <is_prefix+0x37>
movb   $0x0,0x50(%rsp)
xor    %ebp,%ebp
test   %rbx,%rbx
je     11b9 <is_prefix+0x89>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x40(%rsp)
cmpb   $0x0,(%rsp)
je     11b9 <is_prefix+0x89>
test   %r14d,%r14d
jne    11a0 <is_prefix+0x70>
mov    %rsp,%rdi
call   1040 <strtolower@plt>
lea    0x50(%rsp),%rdi
call   1040 <strtolower@plt>
lea    0x50(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
xor    %ebp,%ebp
cmp    %rax,%rbx
sete   %bpl
mov    %ebp,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_prefix(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [65 x i8]
%9 = alloca [65 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
store i8 0, i8* %13
br label %19
14: ; preds = %3
%15 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i32 @strncpy(i8* %15, i8* %16, i32 64)
%18 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 64
store i8 0, i8* %18
br label %19
19: ; preds = %14, %12
%20 = load i8*, i8** %6
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
store i8 0, i8* %23
br label %29
24: ; preds = %19
%25 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%26 = load i8*, i8** %6
%27 = call i32 @strncpy(i8* %25, i8* %26, i32 64)
%28 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 64
store i8 0, i8* %28
br label %29
29: ; preds = %24, %22
%30 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%31 = call i64 @strlen(i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 0, i32* %4
br label %50
34: ; preds = %29
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%39 = call i32 @strtolower(i8* %38)
%40 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%41 = call i32 @strtolower(i8* %40)
br label %42
42: ; preds = %37, %34
%43 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%45 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%46 = call i8* @strstr(i8* %44, i8* %45)
%47 = icmp eq i8* %43, %46
br i1 %47, label %48, label %49
48: ; preds = %42
store i32 1, i32* %4
br label %50
49: ; preds = %42
store i32 0, i32* %4
br label %50
50: ; preds = %49, %48, %33
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
define i32 @is_prefix(i8* %0, i8* %1, i32 %2) {
%4 = alloca [65 x i8]
%5 = alloca [65 x i8]
%6 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%8 = icmp eq i8* %0, null
br i1 %8, label %9, label %10
9: ; preds = %3
store i8 0, i8* %6
br label %13
10: ; preds = %3
%11 = call i32 @strncpy(i8* %6, i8* %0, i32 64)
%12 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 64
store i8 0, i8* %12
br label %13
13: ; preds = %10, %9
%14 = icmp eq i8* %1, null
br i1 %14, label %29, label %15
15: ; preds = %13
%16 = call i32 @strncpy(i8* %7, i8* %1, i32 64)
%17 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 64
store i8 0, i8* %17
%18 = load i8, i8* %7
%19 = icmp eq i8 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %15
%21 = icmp eq i32 %2, 0
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = call i32 @strtolower(i8* %7)
%24 = call i32 @strtolower(i8* %6)
br label %25
25: ; preds = %22, %20
%26 = call i8* @strstr(i8* %6, i8* %7)
%27 = icmp eq i8* %6, %26
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %13, %25, %15
%30 = phi i32 [ 0, %15 ], [ %28, %25 ], [ 0, %13 ]
ret i32 %30
}