#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 */
int get_argCnt(char **);
int strlen(char *);
int isRedirected(char *args[]) {
  int res = 0;
  int ac = get_argCnt(args);
  if (ac > 2) {
    int loc = ac - 2;
    if (strlen(args[loc]) == 1 && args[loc][0] == '>')
      res = 1;
  }
  return res;
}


x86 assembly (clang, -O0):
<isRedirected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get_argCnt@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jle    1190 <isRedirected+0x70>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    118b <isRedirected+0x6b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    118b <isRedirected+0x6b>
movl   $0x1,-0xc(%rbp)
jmp    1190 <isRedirected+0x70>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isRedirected>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <get_argCnt@plt>
xor    %r14d,%r14d
cmp    $0x3,%eax
jl     1155 <isRedirected+0x35>
mov    %eax,%ebp
add    $0xfffffffe,%ebp
mov    (%rbx,%rbp,8),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1155 <isRedirected+0x35>
mov    (%rbx,%rbp,8),%rax
xor    %r14d,%r14d
cmpb   $0x3e,(%rax)
sete   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isRedirected(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %3
%6 = load i8**, i8*** %2
%7 = call i32 @get_argCnt(i8** %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %32
10: ; preds = %1
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 2
store i32 %12, i32* %5
%13 = load i8**, i8*** %2
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %31
20: ; preds = %10
%21 = load i8**, i8*** %2
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 62
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 1, i32* %3
br label %31
31: ; preds = %30, %20, %10
br label %32
32: ; preds = %31, %1
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @isRedirected(i8** %0) {
%2 = tail call i32 @get_argCnt(i8** %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %16
4: ; preds = %1
%5 = add nsw i32 %2, -2
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i8*, i8** %0, i64 %6
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 62
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %11, %4, %1
%17 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %15, %11 ]
ret i32 %17
}