#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 */
char const tolower_c(char const);
int cmp_prefix(const char *key, const char *s) {
  while (*key)
    if (tolower_c(*s) != *key)
      return +1;
    else
      s++, key++;
  return 0;
}


x86 assembly (clang, -O0):
<cmp_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1174 <cmp_prefix+0x64>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower_c@plt>
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1157 <cmp_prefix+0x47>
movl   $0x1,-0x4(%rbp)
jmp    117b <cmp_prefix+0x6b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <cmp_prefix+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_prefix>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdi)
je     114c <cmp_prefix+0x3c>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower_c@plt>
cmp    (%r15,%rbx,1),%al
jne    1150 <cmp_prefix+0x40>
cmpb   $0x0,0x1(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1130 <cmp_prefix+0x20>
xor    %eax,%eax
jmp    1155 <cmp_prefix+0x45>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @cmp_prefix(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %12
%6 = phi i8* [ %13, %12 ], [ %1, %2 ]
%7 = phi i8* [ %14, %12 ], [ %0, %2 ]
%8 = load i8, i8* %6
%9 = tail call signext i8 @tolower_c(i8 signext %8)
%10 = load i8, i8* %7
%11 = icmp eq i8 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %6, i64 1
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %12, %2
%18 = phi i32 [ 0, %2 ], [ 0, %12 ], [ 1, %5 ]
ret i32 %18
}