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


x86 assembly (clang, -O0):
<isLocalCd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x7c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11b4 <isLocalCd+0x74>
mov    -0x10(%rbp),%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11c7 <isLocalCd+0x87>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1229 <isLocalCd+0xe9>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    121b <isLocalCd+0xdb>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1229 <isLocalCd+0xe9>
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):
<isLocalCd>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    0x2e8b(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    $0x7c,%esi
call   1040 <strchr@plt>
xor    %r12d,%r12d
test   %rax,%rax
jne    11c3 <isLocalCd+0x83>
mov    %r15,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11c3 <isLocalCd+0x83>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <strncpy@plt>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
lea    0xe52(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
xor    %r12d,%r12d
test   %rax,%rax
sete   %r12b
mov    %r12d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [3 x i8] c" \09\00"
@.str.1 = [3 x i8] c"cd\00"
define i32 @isLocalCd(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 = call i32* @strchr(i8* %12, i8 signext 124)
%14 = icmp ne i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32* @strchr(i8* %16, i8 signext 38)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %15, %1
store i32 0, i32* %2
store i32 1, i32* %7
br label %30
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = trunc i64 %9 to i32
%23 = call i32 @strncpy(i8* %11, i8* %21, i32 %22)
%24 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 1, i32* %2
store i32 1, i32* %7
br label %30
29: ; preds = %20
store i32 0, i32* %2
store i32 1, i32* %7
br label %30
30: ; preds = %29, %28, %19
%31 = load i8*, i8** %4
%32 = load i32, i32* %2
ret i32 %32
}

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