#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 */
scalar_t__ strcmp(char *, char *);
int chkred(char *token, int *inred, int *outred, int *append, int *pipe_flag) {
  if (token == NULL)
    return 0;
  else if (strcmp(token, "<") == 0) {
    *inred = 1;
    return 1;
  } else if (strcmp(token, ">") == 0) {
    *outred = 1;
    return 2;
  } else if (strcmp(token, ">>") == 0) {
    *append = 1;
    return 3;
  } else if (strcmp(token, "|") == 0) {
    *pipe_flag = 1;
    return 4;
  }
  return 0;
}


x86 assembly (clang, -O0):
<chkred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <chkred+0x33>
movl   $0x0,-0x4(%rbp)
jmp    121e <chkred+0x10e>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1173 <chkred+0x63>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    121e <chkred+0x10e>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <chkred+0x93>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    121e <chkred+0x10e>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d3 <chkred+0xc3>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    121e <chkred+0x10e>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <chkred+0xf3>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x4,-0x4(%rbp)
jmp    121e <chkred+0x10e>
jmp    1208 <chkred+0xf8>
jmp    120d <chkred+0xfd>
jmp    1212 <chkred+0x102>
jmp    1217 <chkred+0x107>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chkred>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
test   %rdi,%rdi
je     11b1 <chkred+0xa1>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118e <chkred+0x7e>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1196 <chkred+0x86>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a1 <chkred+0x91>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11b1 <chkred+0xa1>
mov    $0x4,%r12d
mov    %r14,%rbp
jmp    11aa <chkred+0x9a>
mov    $0x1,%r12d
jmp    11aa <chkred+0x9a>
mov    $0x2,%r12d
mov    %r13,%rbp
jmp    11aa <chkred+0x9a>
mov    $0x3,%r12d
mov    %r15,%rbp
movl   $0x1,0x0(%rbp)
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"<\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [3 x i8] c">>\00"
@.str.3 = [2 x i8] c"|\00"
define i32 @chkred(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%12 = load i8*, i8** %7
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %5
store i32 0, i32* %6
br label %44
15: ; preds = %5
%16 = load i8*, i8** %7
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32*, i32** %8
store i32 1, i32* %20
store i32 1, i32* %6
br label %44
21: ; preds = %15
%22 = load i8*, i8** %7
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32*, i32** %9
store i32 1, i32* %26
store i32 2, i32* %6
br label %44
27: ; preds = %21
%28 = load i8*, i8** %7
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32*, i32** %10
store i32 1, i32* %32
store i32 3, i32* %6
br label %44
33: ; preds = %27
%34 = load i8*, i8** %7
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32*, i32** %11
store i32 1, i32* %38
store i32 4, i32* %6
br label %44
39: ; preds = %33
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41
br label %43
43: ; preds = %42
store i32 0, i32* %6
br label %44
44: ; preds = %43, %37, %31, %25, %19, %14
%45 = load i32, i32* %6
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"<\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [3 x i8] c">>\00"
@.str.3 = [2 x i8] c"|\00"
define i32 @chkred(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = icmp eq i8* %0, null
br i1 %6, label %22, label %7
7: ; preds = %5
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16, %13, %10, %7
%20 = phi i32* [ %1, %7 ], [ %2, %10 ], [ %3, %13 ], [ %4, %16 ]
%21 = phi i32 [ 1, %7 ], [ 2, %10 ], [ 3, %13 ], [ 4, %16 ]
store i32 1, i32* %20
br label %22
22: ; preds = %19, %16, %5
%23 = phi i32 [ 0, %5 ], [ 0, %16 ], [ %21, %19 ]
ret i32 %23
}