#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*/ strcmp(char *, char *);
int getRedirectionPosition(char **args, int spaces) {
  for (int i = 0; i < (spaces + 1); i++) {
    if ((!strcmp(args[i], ">")) && (i < spaces))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<getRedirectionPosition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1182 <getRedirectionPosition+0x72>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116f <getRedirectionPosition+0x5f>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116f <getRedirectionPosition+0x5f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <getRedirectionPosition+0x79>
jmp    1174 <getRedirectionPosition+0x64>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <getRedirectionPosition+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRedirectionPosition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %esi,%esi
js     1162 <getRedirectionPosition+0x52>
mov    %esi,%ebx
mov    %rdi,%r13
mov    %esi,%r12d
add    $0x1,%ebx
xor    %ebp,%ebp
lea    0xec7(%rip),%r15
jmp    1149 <getRedirectionPosition+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1162 <getRedirectionPosition+0x52>
mov    0x0(%r13,%rbp,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1140 <getRedirectionPosition+0x30>
cmp    %r12,%rbp
jae    1140 <getRedirectionPosition+0x30>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c">\00"
define i32 @getRedirectionPosition(i8** nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = add nuw i32 %1, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %4, %16
%9 = phi i64 [ 0, %4 ], [ %17, %16 ]
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = icmp ult i64 %9, %5
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %21, label %8
19: ; preds = %8
%20 = trunc i64 %9 to i32
br label %21
21: ; preds = %16, %19, %2
%22 = phi i32 [ -1, %2 ], [ %20, %19 ], [ -1, %16 ]
ret i32 %22
}