#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__ is_word_end(char const);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
bool keyword(const char *s, const char *keyword, const char **rest) {
  size_t keyword_length = strlen(keyword);
  if (strncmp(s, keyword, keyword_length) == 0) {
    s += keyword_length;
    if (is_word_end(*s)) {
      if (rest)
        *rest = s;
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<keyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b5 <keyword+0x85>
mov    -0x28(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <is_word_end@plt>
cmp    $0x0,%rax
je     11b0 <keyword+0x80>
cmpq   $0x0,-0x20(%rbp)
je     11a4 <keyword+0x74>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11bc <keyword+0x8c>
jmp    11b5 <keyword+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyword>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    1182 <keyword+0x52>
movsbl (%rbx,%r12,1),%edi
call   1050 <is_word_end@plt>
test   %rax,%rax
je     1182 <keyword+0x52>
mov    $0x1,%r15d
test   %r14,%r14
je     1182 <keyword+0x52>
add    %r12,%rbx
mov    %rbx,(%r14)
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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