#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 getRedirectionType(char *redirection) {
  if (strcmp(redirection, ">") == 0 || strcmp(redirection, "1>") == 0) {
    return 1;
  } else if (strcmp(redirection, ">>") == 0) {
    return 2;
  } else if (strcmp(redirection, "2>") == 0) {
    return 3;
  } else if (strcmp(redirection, "2>>") == 0) {
    return 4;
  } else if (strcmp(redirection, "<") == 0) {
    return 5;
  } else {
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getRedirectionType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeda(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1150 <getRedirectionType+0x40>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115c <getRedirectionType+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11fb <getRedirectionType+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1182 <getRedirectionType+0x72>
movl   $0x2,-0x4(%rbp)
jmp    11fb <getRedirectionType+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <getRedirectionType+0x98>
movl   $0x3,-0x4(%rbp)
jmp    11fb <getRedirectionType+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ce <getRedirectionType+0xbe>
movl   $0x4,-0x4(%rbp)
jmp    11fb <getRedirectionType+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f4 <getRedirectionType+0xe4>
movl   $0x5,-0x4(%rbp)
jmp    11fb <getRedirectionType+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRedirectionType>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee4(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11ab <getRedirectionType+0x9b>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ab <getRedirectionType+0x9b>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1198 <getRedirectionType+0x88>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     119f <getRedirectionType+0x8f>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a6 <getRedirectionType+0x96>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,4),%ebp
jmp    11ab <getRedirectionType+0x9b>
mov    $0x2,%ebp
jmp    11ab <getRedirectionType+0x9b>
mov    $0x3,%ebp
jmp    11ab <getRedirectionType+0x9b>
mov    $0x4,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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