#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*/ isalpha(int);
size_t strlen(char const *);
int is_whole_word(int curr_pos, const char *datastr, const char *searchword) {
  size_t sln = curr_pos + strlen(searchword);
  return (curr_pos < 1 || !isalpha((int)datastr[curr_pos - 1])) &&
         (sln == strlen(datastr) || !isalpha((int)datastr[sln]));
}


x86 assembly (clang, -O0):
<is_whole_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     1182 <is_whole_word+0x62>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalpha@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    11ca <is_whole_word+0xaa>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rcx
mov    %rax,%rdx
mov    $0x1,%al
cmp    %rdx,%rcx
mov    %al,-0x2a(%rbp)
je     11c4 <is_whole_word+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_whole_word>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
mov    %rdx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
test   %ebx,%ebx
jle    114e <is_whole_word+0x2e>
lea    -0x1(%rbx),%eax
movsbl (%r14,%rax,1),%edi
call   1040 <isalpha@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    117c <is_whole_word+0x5c>
movslq %ebx,%rax
add    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %rcx,%r15
je     117c <is_whole_word+0x5c>
movsbl (%r14,%r15,1),%edi
call   1040 <isalpha@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @is_whole_word(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = load i8*, i8** %6
%11 = call i64 @strlen(i8* %10)
%12 = add i64 %9, %11
store i64 %12, i64* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 1
br i1 %14, label %25, label %15
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 @isalpha(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %41, label %25
25: ; preds = %15, %3
%26 = load i64, i64* %7
%27 = load i8*, i8** %5
%28 = call i64 @strlen(i8* %27)
%29 = icmp eq i64 %26, %28
br i1 %29, label %39, label %30
30: ; preds = %25
%31 = load i8*, i8** %5
%32 = load i64, i64* %7
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 @isalpha(i32 %35)
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
br label %39
39: ; preds = %30, %25
%40 = phi i1 [ true, %25 ], [ %38, %30 ]
br label %41
41: ; preds = %39, %15
%42 = phi i1 [ false, %15 ], [ %40, %39 ]
%43 = zext i1 %42 to i32
ret i32 %43
}

LLVM IR (-O2):
define i32 @is_whole_word(i32 %0, i8* nocapture %1, i8* nocapture %2) {
%4 = sext i32 %0 to i64
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = add i64 %5, %4
%7 = icmp slt i32 %0, 1
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 @isalpha(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %8, %3
%17 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%18 = icmp eq i64 %6, %17
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %1, i64 %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = tail call i32 @isalpha(i32 %22)
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %16, %19, %8
%27 = phi i32 [ 0, %8 ], [ 1, %16 ], [ %25, %19 ]
ret i32 %27
}