#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 nbElementsCommande(char **);
scalar_t__ strcmp(char *, char *);
void rechercheCaractereEntreeSortie(char *com[], int *redirectEntree,
                                    int *redirectSortie) {
  int positCarEntree = 0;
  int positCarSortie = 0;
  int i = 0;
  for (i = 0; i < nbElementsCommande(com); i++) {
    if (strcmp(com[i], "<") == 0)
      positCarEntree = i;
    if (strcmp(com[i], ">") == 0)
      positCarSortie = i;
  }
  *redirectEntree = positCarEntree;
  *redirectSortie = positCarSortie;
}


x86 assembly (clang, -O0):
<rechercheCaractereEntreeSortie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <nbElementsCommande@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11cf <rechercheCaractereEntreeSortie+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1194 <rechercheCaractereEntreeSortie+0x74>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <rechercheCaractereEntreeSortie+0x9c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11c1 <rechercheCaractereEntreeSortie+0xa1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <rechercheCaractereEntreeSortie+0x30>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rechercheCaractereEntreeSortie>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
call   1030 <nbElementsCommande@plt>
test   %eax,%eax
jle    119b <rechercheCaractereEntreeSortie+0x7b>
xor    %r15d,%r15d
lea    0xeb2(%rip),%r12
lea    0xead(%rip),%r13
xor    %r14d,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r15,8),%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
cmove  %r15d,%ebp
mov    (%rbx,%r15,8),%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
cmove  %r15d,%r14d
add    $0x1,%r15
mov    %rbx,%rdi
call   1030 <nbElementsCommande@plt>
cltq
cmp    %rax,%r15
jl     1160 <rechercheCaractereEntreeSortie+0x40>
jmp    11a0 <rechercheCaractereEntreeSortie+0x80>
xor    %ebp,%ebp
xor    %r14d,%r14d
mov    0x8(%rsp),%rax
mov    %ebp,(%rax)
mov    0x10(%rsp),%rax
mov    %r14d,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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