#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 */
typedef int /*<<< orphan*/ strCmd;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strrchr(char *, char);
int /*<<< orphan*/ *strtok(char *, char *);
int isBackground(const char *pCmd) {
  char strCmd[BUFSIZ];
  char *p = NULL;
  strncpy(strCmd, pCmd, sizeof(strCmd));
  p = strrchr(strCmd, '&');
  if (p != NULL && strtok(p, " &\t\n") == NULL) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isBackground>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x38(%rbp),%rdi
mov    $0x26,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c5 <isBackground+0x95>
mov    -0x28(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
jne    11c5 <isBackground+0x95>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    11d3 <isBackground+0xa3>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBackground>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%rsi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x26,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1184 <isBackground+0x54>
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     1188 <isBackground+0x58>
xor    %eax,%eax
jmp    118d <isBackground+0x5d>
mov    $0x1,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [5 x i8] c" &\09\0A\00"
define i32 @isBackground(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i8, i64 %9
store i64 %9, i64* %5
store i8* null, i8** %6
%12 = load i8*, i8** %3
%13 = trunc i64 %9 to i32
%14 = call i32 @strncpy(i8* %11, i8* %12, i32 %13)
%15 = call i8* @strrchr(i8* %11, i8 signext 38)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %1
%19 = load i8*, i8** %6
%20 = call i32* @strtok(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %2
store i32 1, i32* %7
br label %24
23: ; preds = %18, %1
store i32 0, i32* %2
store i32 1, i32* %7
br label %24
24: ; preds = %23, %22
%25 = load i8*, i8** %4
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [5 x i8] c" &\09\0A\00"
define i32 @isBackground(i8* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @strncpy(i8* %4, i8* %0, i32 %2)
%6 = call i8* @strrchr(i8* %4, i8 signext 38)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32* @strtok(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8, %1
br label %12
12: ; preds = %8, %11
%13 = phi i32 [ 0, %11 ], [ 1, %8 ]
ret i32 %13
}