#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 is_space(char const);
int mockable_is_surrounded_by_whitespaces(const char *buf, int pos, int end) {
  const int left = is_space(buf[pos - 1]);
  const int right = is_space(buf[end + 1]);
  return (left && right);
}


x86 assembly (clang, -O0):
<mockable_is_surrounded_by_whitespaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <is_space@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <is_space@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
je     116d <mockable_is_surrounded_by_whitespaces+0x5d>
cmpl   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mockable_is_surrounded_by_whitespaces>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rdi,%rbx
movslq %esi,%rax
movsbl -0x1(%rax,%rdi,1),%edi
call   1030 <is_space@plt>
mov    %eax,%ebp
movslq %r14d,%rax
movsbl 0x1(%rax,%rbx,1),%edi
call   1030 <is_space@plt>
test   %ebp,%ebp
setne  %cl
test   %eax,%eax
setne  %al
and    %cl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @mockable_is_surrounded_by_whitespaces(i8* nocapture %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = tail call i32 @is_space(i8 signext %7)
%9 = add nsw i32 %2, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @is_space(i8 signext %12)
%14 = icmp ne i32 %8, 0
%15 = icmp ne i32 %13, 0
%16 = select i1 %14, i1 %15, i1 false
%17 = zext i1 %16 to i32
ret i32 %17
}