#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 /*<<< orphan*/ perror(char *);
int isValidRedirection(char *input) {
  int i = 0, outcount = 0, incount = 0;
  for (i = 0; input[i] != '\0'; i++) {
    if (input[i] == '>') {
      if (outcount == 0)
        outcount++;
      else
        perror("More than one out redirection.\n");
    }
    if (input[i] == '<') {
      if (incount == 0)
        incount++;
      else
        perror("More than one in redirection.\n");
    }
  }
  if (incount == 1 || outcount == 1)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<isValidRedirection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11dc <isValidRedirection+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
jne    118b <isValidRedirection+0x7b>
cmpl   $0x0,-0x18(%rbp)
jne    117a <isValidRedirection+0x6a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <isValidRedirection+0x76>
lea    0xe7f(%rip),%rdi
call   1030 <perror@plt>
jmp    118b <isValidRedirection+0x7b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
jne    11c9 <isValidRedirection+0xb9>
cmpl   $0x0,-0x1c(%rbp)
jne    11b8 <isValidRedirection+0xa8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c4 <isValidRedirection+0xb4>
lea    0xe61(%rip),%rdi
call   1030 <perror@plt>
jmp    11c9 <isValidRedirection+0xb9>
jmp    11ce <isValidRedirection+0xbe>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <isValidRedirection+0x28>
cmpl   $0x1,-0x1c(%rbp)
je     11f0 <isValidRedirection+0xe0>
cmpl   $0x1,-0x18(%rbp)
jne    11fc <isValidRedirection+0xec>
movl   $0x1,-0x4(%rbp)
jmp    1203 <isValidRedirection+0xf3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isValidRedirection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r12d,%r12d
lea    0xed8(%rip),%r14
lea    0xef1(%rip),%r15
xor    %r13d,%r13d
jmp    1155 <isValidRedirection+0x45>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r12d,%r12d
jne    1178 <isValidRedirection+0x68>
mov    $0x1,%r12d
mov    %r13d,%ebp
add    $0x1,%rbx
mov    %ebp,%r13d
movzbl (%rbx),%eax
cmp    $0x3e,%al
je     1140 <isValidRedirection+0x30>
test   %al,%al
je     118f <isValidRedirection+0x7f>
cmp    $0x3c,%al
jne    114b <isValidRedirection+0x3b>
mov    $0x1,%ebp
test   %r13d,%r13d
je     114e <isValidRedirection+0x3e>
mov    %r15,%rdi
call   1030 <perror@plt>
jmp    114e <isValidRedirection+0x3e>
mov    %r14,%rdi
call   1030 <perror@plt>
movzbl (%rbx),%eax
mov    $0x1,%r12d
cmp    $0x3c,%al
je     1164 <isValidRedirection+0x54>
jmp    114b <isValidRedirection+0x3b>
cmp    $0x1,%r13d
sete   %al
cmp    $0x1,%r12d
sete   %cl
or     %al,%cl
movzbl %cl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"More than one out redirection.\0A\00"
@.str.1 = [31 x i8] c"More than one in redirection.\0A\00"
define i32 @isValidRedirection(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %4
br label %7
7: ; preds = %50, %1
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %53
15: ; preds = %7
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 62
br i1 %22, label %23, label %32
23: ; preds = %15
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %31
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
br label %32
32: ; preds = %31, %15
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 60
br i1 %39, label %40, label %49
40: ; preds = %32
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %48
46: ; preds = %40
%47 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
br label %49
49: ; preds = %48, %32
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %7
53: ; preds = %7
%54 = load i32, i32* %6
%55 = icmp eq i32 %54, 1
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i32, i32* %5
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %60
59: ; preds = %56, %53
store i32 1, i32* %2
br label %61
60: ; preds = %56
store i32 0, i32* %2
br label %61
61: ; preds = %60, %59
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
@.str = [32 x i8] c"More than one out redirection.\0A\00"
@.str.1 = [31 x i8] c"More than one in redirection.\0A\00"
define i32 @isValidRedirection(i8* nocapture %0) {
br label %2
2: ; preds = %21, %1
%3 = phi i64 [ %24, %21 ], [ 0, %1 ]
%4 = phi i32 [ %22, %21 ], [ 0, %1 ]
%5 = phi i32 [ %23, %21 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %3
%7 = load i8, i8* %6
switch i8 %7, label %13 [
i8 0, label %25
i8 62, label %8
]
8: ; preds = %2
%9 = icmp eq i32 %4, 0
br i1 %9, label %21, label %10
10: ; preds = %8
%11 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = load i8, i8* %6
br label %13
13: ; preds = %2, %10
%14 = phi i8 [ %7, %2 ], [ %12, %10 ]
%15 = phi i32 [ %4, %2 ], [ 1, %10 ]
%16 = icmp eq i8 %14, 60
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = icmp eq i32 %5, 0
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %8, %17, %13, %19
%22 = phi i32 [ %15, %19 ], [ %15, %13 ], [ %15, %17 ], [ 1, %8 ]
%23 = phi i32 [ 1, %19 ], [ %5, %13 ], [ 1, %17 ], [ %5, %8 ]
%24 = add nuw i64 %3, 1
br label %2
25: ; preds = %2
%26 = icmp eq i32 %5, 1
%27 = icmp eq i32 %4, 1
%28 = select i1 %26, i1 true, i1 %27
%29 = zext i1 %28 to i32
ret i32 %29
}