#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 parseCmd(const char *pCmdStr, char *pExecutable, char *pInFile,
             char *pOutFile, char *pOutMode) {
  char strCmd[BUFSIZ];
  char *p = NULL;
  pExecutable[0] = 0;
  pInFile[0] = 0;
  pOutFile[0] = 0;
  pOutMode[0] = 0;
  strncpy(strCmd, pCmdStr, sizeof(strCmd));
  p = strrchr(strCmd, '>');
  if (p != NULL) {
    char *pFile = NULL;
    strncpy(pOutMode, "w", 2);
    if (p != &(strCmd[0]) && *(--p) == '>') {
      strncpy(pOutMode, "a", 2);
    }
    pFile = strtok(p, "> \t");
    if (pFile == NULL) {
      return 2002;
    }
    strncpy(pOutFile, pFile, BUFSIZ);
    ;
    p = strtok(strCmd, ">");
    strncpy(strCmd, p, sizeof(strCmd));

    ;
  }
  p = strrchr(strCmd, '<');
  if (p != NULL) {
    char *pFile = NULL;
    pFile = strtok(p, "< \t");
    if (pFile == NULL) {
      return 2003;
    }
    strncpy(pInFile, pFile, BUFSIZ);
    ;
  }
  p = strtok(strCmd, "<");
  if (p == NULL) {
    return 2001;
  }
  strncpy(pExecutable, p, BUFSIZ);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<parseCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x70(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rcx)
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rcx)
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rcx)
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rcx)
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
mov    $0x3e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1299 <parseCmd+0x169>
movq   $0x0,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
je     1227 <parseCmd+0xf7>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x48(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x3e,%eax
jne    1227 <parseCmd+0xf7>
mov    -0x30(%rbp),%rdi
lea    0xde5(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x48(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1259 <parseCmd+0x129>
movl   $0x7d2,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    135c <parseCmd+0x22c>
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    0x2d78(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   1050 <strtok@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
mov    $0x3c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1306 <parseCmd+0x1d6>
movq   $0x0,-0x60(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xd41(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12f0 <parseCmd+0x1c0>
movl   $0x7d3,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    135c <parseCmd+0x22c>
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1338 <parseCmd+0x208>
movl   $0x7d1,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    135c <parseCmd+0x22c>
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    0x2c99(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseCmd>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdi,%rcx
mov    0x2e8f(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%rbx
mov    %r12,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsi,-0x38(%rbp)
movb   $0x0,(%rsi)
mov    %rdx,-0x30(%rbp)
movb   $0x0,(%rdx)
movb   $0x0,0x0(%r13)
movb   $0x0,(%r8)
mov    %rbx,%rdi
mov    %rcx,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x3e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     122c <parseCmd+0xfc>
mov    %rax,%r15
lea    0xe53(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
cmp    %rbx,%r15
je     11e6 <parseCmd+0xb6>
mov    %r15,%rax
add    $0xffffffffffffffff,%r15
cmpb   $0x3e,-0x1(%rax)
jne    11e3 <parseCmd+0xb3>
lea    0xe2c(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
lea    0xe17(%rip),%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1294 <parseCmd+0x164>
mov    0x2dde(%rip),%rcx
mov    (%rcx),%edx
mov    %r13,%rdi
mov    %rax,%rsi
call   1030 <strncpy@plt>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1267 <parseCmd+0x137>
lea    0xdc5(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     12a2 <parseCmd+0x172>
mov    0x2d87(%rip),%rcx
mov    (%rcx),%edx
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strncpy@plt>
lea    0xda0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     129b <parseCmd+0x16b>
mov    0x2d5e(%rip),%rcx
mov    (%rcx),%edx
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strncpy@plt>
xor    %eax,%eax
jmp    12a7 <parseCmd+0x177>
mov    $0x7d2,%eax
jmp    12a7 <parseCmd+0x177>
mov    $0x7d1,%eax
jmp    12a7 <parseCmd+0x177>
mov    $0x7d3,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [4 x i8] c"> \09\00"
@.str.3 = [2 x i8] c">\00"
@.str.4 = [4 x i8] c"< \09\00"
@.str.5 = [2 x i8] c"<\00"
define i32 @parseCmd(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%18 = load i32, i32* @BUFSIZ
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %12
%21 = alloca i8, i64 %19
store i64 %19, i64* %13
store i8* null, i8** %14
%22 = load i8*, i8** %8
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 0, i8* %23
%24 = load i8*, i8** %9
%25 = getelementptr inbounds i8, i8* %24, i64 0
store i8 0, i8* %25
%26 = load i8*, i8** %10
%27 = getelementptr inbounds i8, i8* %26, i64 0
store i8 0, i8* %27
%28 = load i8*, i8** %11
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 0, i8* %29
%30 = load i8*, i8** %7
%31 = trunc i64 %19 to i32
%32 = call i32 @strncpy(i8* %21, i8* %30, i32 %31)
%33 = call i8* @strrchr(i8* %21, i8 signext 62)
store i8* %33, i8** %14
%34 = load i8*, i8** %14
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %66
36: ; preds = %5
store i8* null, i8** %15
%37 = load i8*, i8** %11
%38 = call i32 @strncpy(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
%39 = load i8*, i8** %14
%40 = getelementptr inbounds i8, i8* %21, i64 0
%41 = icmp ne i8* %39, %40
br i1 %41, label %42, label %51
42: ; preds = %36
%43 = load i8*, i8** %14
%44 = getelementptr inbounds i8, i8* %43, i32 -1
store i8* %44, i8** %14
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 62
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load i8*, i8** %11
%50 = call i32 @strncpy(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %51
51: ; preds = %48, %42, %36
%52 = load i8*, i8** %14
%53 = call i8* @strtok(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %53, i8** %15
%54 = load i8*, i8** %15
%55 = icmp eq i8* %54, null
br i1 %55, label %56, label %57
56: ; preds = %51
store i32 2002, i32* %6
store i32 1, i32* %16
br label %91
57: ; preds = %51
%58 = load i8*, i8** %10
%59 = load i8*, i8** %15
%60 = load i32, i32* @BUFSIZ
%61 = call i32 @strncpy(i8* %58, i8* %59, i32 %60)
%62 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %62, i8** %14
%63 = load i8*, i8** %14
%64 = trunc i64 %19 to i32
%65 = call i32 @strncpy(i8* %21, i8* %63, i32 %64)
br label %66
66: ; preds = %57, %5
%67 = call i8* @strrchr(i8* %21, i8 signext 60)
store i8* %67, i8** %14
%68 = load i8*, i8** %14
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %81
70: ; preds = %66
store i8* null, i8** %17
%71 = load i8*, i8** %14
%72 = call i8* @strtok(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i8* %72, i8** %17
%73 = load i8*, i8** %17
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %76
75: ; preds = %70
store i32 2003, i32* %6
store i32 1, i32* %16
br label %91
76: ; preds = %70
%77 = load i8*, i8** %9
%78 = load i8*, i8** %17
%79 = load i32, i32* @BUFSIZ
%80 = call i32 @strncpy(i8* %77, i8* %78, i32 %79)
br label %81
81: ; preds = %76, %66
%82 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %82, i8** %14
%83 = load i8*, i8** %14
%84 = icmp eq i8* %83, null
br i1 %84, label %85, label %86
85: ; preds = %81
store i32 2001, i32* %6
store i32 1, i32* %16
br label %91
86: ; preds = %81
%87 = load i8*, i8** %8
%88 = load i8*, i8** %14
%89 = load i32, i32* @BUFSIZ
%90 = call i32 @strncpy(i8* %87, i8* %88, i32 %89)
store i32 0, i32* %6
store i32 1, i32* %16
br label %91
91: ; preds = %86, %85, %75, %56
%92 = load i8*, i8** %12
%93 = load i32, i32* %6
ret i32 %93
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [4 x i8] c"> \09\00"
@.str.3 = [2 x i8] c">\00"
@.str.4 = [4 x i8] c"< \09\00"
@.str.5 = [2 x i8] c"<\00"
define i32 @parseCmd(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
store i8 0, i8* %1
store i8 0, i8* %2
store i8 0, i8* %3
store i8 0, i8* %4
%9 = call i32 @strncpy(i8* %8, i8* %0, i32 %6)
%10 = call i8* @strrchr(i8* %8, i8 signext 62)
%11 = icmp eq i8* %10, null
br i1 %11, label %30, label %12
12: ; preds = %5
%13 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = icmp eq i8* %10, %8
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %10, i64 -1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 62
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %21
21: ; preds = %19, %15, %12
%22 = phi i8* [ %16, %19 ], [ %16, %15 ], [ %8, %12 ]
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %45, label %25
25: ; preds = %21
%26 = load i32, i32* @BUFSIZ
%27 = call i32 @strncpy(i8* %3, i8* %23, i32 %26)
%28 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @strncpy(i8* %8, i8* %28, i32 %6)
br label %30
30: ; preds = %25, %5
%31 = call i8* @strrchr(i8* %8, i8 signext 60)
%32 = icmp eq i8* %31, null
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = call i8* @strtok(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %45, label %36
36: ; preds = %33
%37 = load i32, i32* @BUFSIZ
%38 = call i32 @strncpy(i8* %2, i8* %34, i32 %37)
br label %39
39: ; preds = %36, %30
%40 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i8* %40, null
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* @BUFSIZ
%44 = call i32 @strncpy(i8* %1, i8* %40, i32 %43)
br label %45
45: ; preds = %33, %21, %39, %42
%46 = phi i32 [ 0, %42 ], [ 2001, %39 ], [ 2002, %21 ], [ 2003, %33 ]
ret i32 %46
}