#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*/ memset(char *, char, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
bool check_if_output_redirect(char **arguments_array, int *args_count,
                              char *output_filename) {
  memset(output_filename, '\0', 2048);
  for (int i = 0; i < *args_count; i++) {
    if (strcmp(arguments_array[i], ">") == 0) {
      strcpy(output_filename, arguments_array[i + 1]);
      *args_count -= 2;
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<check_if_output_redirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    11d0 <check_if_output_redirect+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <check_if_output_redirect+0x8d>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x2,%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11d7 <check_if_output_redirect+0xa7>
jmp    11c2 <check_if_output_redirect+0x92>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115b <check_if_output_redirect+0x2b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_if_output_redirect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %ebp,%ebp
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
cmpl   $0x0,(%r15)
jle    11a7 <check_if_output_redirect+0x77>
xor    %ebp,%ebp
lea    0xe9f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1191 <check_if_output_redirect+0x61>
add    $0x1,%rbp
movslq (%r15),%rax
cmp    %rax,%rbp
jl     1170 <check_if_output_redirect+0x40>
xor    %ebp,%ebp
jmp    11a7 <check_if_output_redirect+0x77>
mov    0x8(%rbx,%rbp,8),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
addl   $0xfffffffe,(%r15)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c">\00"
define i32 @check_if_output_redirect(i8** %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 2048)
store i32 0, i32* %8
br label %11
11: ; preds = %37, %3
%12 = load i32, i32* %8
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = load i8**, i8*** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %16
%25 = load i8*, i8** %7
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strcpy(i8* %25, i8* %31)
%33 = load i32*, i32** %6
%34 = load i32, i32* %33
%35 = sub nsw i32 %34, 2
store i32 %35, i32* %33
store i32 1, i32* %4
br label %41
36: ; preds = %16
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %11
40: ; preds = %11
store i32 0, i32* %4
br label %41
41: ; preds = %40, %24
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [2 x i8] c">\00"
define i32 @check_if_output_redirect(i8** nocapture %0, i32* nocapture %1, i8* %2) {
%4 = tail call i32 @memset(i8* %2, i8 signext 0, i32 2048)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %3, %21
%8 = phi i64 [ %13, %21 ], [ 0, %3 ]
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = add nuw nsw i64 %8, 1
br i1 %12, label %14, label %21
14: ; preds = %7
%15 = and i64 %13, 4294967295
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @strcpy(i8* %2, i8* %17)
%19 = load i32, i32* %1
%20 = add nsw i32 %19, -2
store i32 %20, i32* %1
br label %25
21: ; preds = %7
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %13, %23
br i1 %24, label %7, label %25
25: ; preds = %21, %3, %14
%26 = phi i32 [ 1, %14 ], [ 0, %3 ], [ 0, %21 ]
ret i32 %26
}