#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);
char *strtok(char *, char *);
int hasSyntaxError(const char *pCmd) {
  char strCmd[BUFSIZ];
  char *p = NULL;
  strncpy(strCmd, pCmd, sizeof(strCmd));
  p = strtok(strCmd, "&");
  if (p != NULL && strtok(NULL, " \t\n") != NULL) {
    return 1;
  }
  p = strrchr(strCmd, '|');
  if (p != NULL && strtok(p, " |\t\n") == NULL) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hasSyntaxError>:
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
lea    0xe7a(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c7 <hasSyntaxError+0x97>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5d(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
je     11c7 <hasSyntaxError+0x97>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    121f <hasSyntaxError+0xef>
mov    -0x38(%rbp),%rdi
mov    $0x7c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1211 <hasSyntaxError+0xe1>
mov    -0x28(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
jne    1211 <hasSyntaxError+0xe1>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    121f <hasSyntaxError+0xef>
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):
<hasSyntaxError>:
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>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     118d <hasSyntaxError+0x5d>
lea    0xe89(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11bc <hasSyntaxError+0x8c>
mov    %rbx,%rdi
mov    $0x7c,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11b3 <hasSyntaxError+0x83>
lea    0xe60(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11b7 <hasSyntaxError+0x87>
xor    %eax,%eax
jmp    11bc <hasSyntaxError+0x8c>
mov    $0x1,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"&\00"
@.str.1 = [4 x i8] c" \09\0A\00"
@.str.2 = [5 x i8] c" |\09\0A\00"
define i32 @hasSyntaxError(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* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %1
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %2
store i32 1, i32* %7
br label %32
22: ; preds = %18, %1
%23 = call i8* @strrchr(i8* %11, i8 signext 124)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = call i8* @strtok(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 1, i32* %2
store i32 1, i32* %7
br label %32
31: ; preds = %26, %22
store i32 0, i32* %2
store i32 1, i32* %7
br label %32
32: ; preds = %31, %30, %21
%33 = load i8*, i8** %4
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"&\00"
@.str.1 = [4 x i8] c" \09\0A\00"
@.str.2 = [5 x i8] c" |\09\0A\00"
define i32 @hasSyntaxError(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* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %8, %1
%12 = call i8* @strrchr(i8* %4, i8 signext 124)
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14, %11
br label %18
18: ; preds = %14, %8, %17
%19 = phi i32 [ 0, %17 ], [ 1, %8 ], [ 1, %14 ]
ret i32 %19
}