#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 */
struct timeval {
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int getRedirectionType(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, scalar_t__);
void testGetRedirectionType(void) {
  struct timeval stop, start;
  gettimeofday(&start, NULL);
  assert(getRedirectionType(">") == 1);
  assert(getRedirectionType("1>") == 1);
  assert(getRedirectionType(">>") == 2);
  assert(getRedirectionType("2>") == 3);
  assert(getRedirectionType("2>>") == 4);
  gettimeofday(&stop, NULL);
  printf("getRedirectionType success : %lu ms\n", stop.tv_usec - start.tv_usec);
}


x86 assembly (clang, -O0):
<testGetRedirectionType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    0xea5(%rip),%rdi
call   1060 <getRedirectionType@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe88(%rip),%rdi
call   1060 <getRedirectionType@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe73(%rip),%rdi
call   1060 <getRedirectionType@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe53(%rip),%rdi
call   1060 <getRedirectionType@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe3a(%rip),%rdi
call   1060 <getRedirectionType@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%rsi
sub    -0x10(%rbp),%rsi
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGetRedirectionType>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0xeaa(%rip),%rdi
call   1060 <getRedirectionType@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe8f(%rip),%rdi
call   1060 <getRedirectionType@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe7c(%rip),%rdi
call   1060 <getRedirectionType@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe5e(%rip),%rdi
call   1060 <getRedirectionType@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe47(%rip),%rdi
call   1060 <getRedirectionType@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1050 <assert@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x10(%rsp),%rsi
sub    0x8(%rsp),%rsi
lea    0xe1b(%rip),%rdi
add    $0x18,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.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 = [37 x i8] c"getRedirectionType success : %lu ms\0A\00"
define void @testGetRedirectionType() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%4 = call i32 @getRedirectionType(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 2
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32 %16, 3
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @getRedirectionType(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32 %20, 4
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%28 = load i64, i64* %27
%29 = sub nsw i64 %26, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i64 %29)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.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 = [37 x i8] c"getRedirectionType success : %lu ms\0A\00"
define void @testGetRedirectionType() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = tail call i32 @getRedirectionType(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 1
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 2
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 @getRedirectionType(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 3
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @getRedirectionType(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32 %22, 4
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%30 = load i64, i64* %29
%31 = sub nsw i64 %28, %30
%32 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i64 %31)
ret void
}