#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*/ strcpy(char *, char *);
char *strstr(char *, char *);
int redirCheck(char input[], char fileName[]) {
  char *redir = NULL;
  if (strstr(input, "==>") != NULL) {
    redir = strstr(input, "==>");
    input[redir - input] = '\0';
    strcpy(fileName, redir + 4);
    return 0;
  } else if (strstr(input, "<==") != NULL) {
    redir = strstr(input, "<==");
    input[redir - input] = '\0';
    strcpy(fileName, redir + 4);
    return 1;
  } else if (strstr(input, "-->") != NULL) {
    redir = strstr(input, "-->");
    input[redir - input] = '\0';
    strcpy(fileName, redir + 4);
    return 2;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<redirCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1196 <redirCheck+0x76>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1259 <redirCheck+0x139>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11f4 <redirCheck+0xd4>
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <redirCheck+0x139>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1252 <redirCheck+0x132>
mov    -0x10(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   1030 <strcpy@plt>
movl   $0x2,-0x4(%rbp)
jmp    1259 <redirCheck+0x139>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redirCheck>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xed0(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     113e <redirCheck+0x1e>
xor    %ebp,%ebp
jmp    1172 <redirCheck+0x52>
lea    0xebf(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1159 <redirCheck+0x39>
mov    $0x1,%ebp
jmp    1172 <redirCheck+0x52>
lea    0xea8(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     118d <redirCheck+0x6d>
mov    $0x2,%ebp
movb   $0x0,(%rax)
add    $0x4,%rax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0xffffffff,%ebp
jmp    1184 <redirCheck+0x64>

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

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