#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*/ O_RDONLY;
int /*<<< orphan*/ free(char **);
char **init_rm(char **);
char **malloc(int);
int my_exec(char **, char *, char **);
int /*<<< orphan*/ my_putstr(char *);
int open(char *, int /*<<< orphan*/);
int read_file(int);
int /*<<< orphan*/ s_arrow_exec(char **, char **);
int s_arrow_left(char **command, char **file, char **env, int point) {
  int fd_file;
  char **rm;
  (void)point;
  if ((rm = malloc(sizeof(char *) * 3)) == NULL)
    return (-1);
  if ((rm = init_rm(rm)) == NULL)
    return (-1);
  if (file == NULL)
    return (-1);
  if ((fd_file = open(file[0], O_RDONLY)) == -1) {
    my_putstr("The file doesn't exist\n");
    return (-1);
  }
  if ((read_file(fd_file)) == -1)
    return (-1);
  s_arrow_exec(command, env);
  if (my_exec(env, rm[0], rm) == 1)
    return (-1);
  free(rm);
  return (0);
}


x86 assembly (clang, -O0):
<s_arrow_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    $0x18,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11bb <s_arrow_left+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
mov    -0x30(%rbp),%rdi
call   1070 <init_rm@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11de <s_arrow_left+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
cmpq   $0x0,-0x18(%rbp)
jne    11f5 <s_arrow_left+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    122e <s_arrow_left+0xae>
lea    0xde3(%rip),%rdi
call   1080 <my_putstr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
mov    -0x28(%rbp),%edi
call   1060 <read_file@plt>
cmp    $0xffffffff,%eax
jne    124b <s_arrow_left+0xcb>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <s_arrow_exec@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <my_exec@plt>
cmp    $0x1,%eax
jne    1281 <s_arrow_left+0x101>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <s_arrow_left+0x111>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_arrow_left>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
mov    $0x18,%edi
call   1090 <malloc@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1212 <s_arrow_left+0x92>
mov    %rax,%rdi
call   1070 <init_rm@plt>
test   %rbx,%rbx
je     1212 <s_arrow_left+0x92>
mov    %rax,%r15
test   %rax,%rax
je     1212 <s_arrow_left+0x92>
mov    (%rbx),%rdi
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     1206 <s_arrow_left+0x86>
mov    %eax,%edi
call   1060 <read_file@plt>
cmp    $0xffffffff,%eax
je     1212 <s_arrow_left+0x92>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <s_arrow_exec@plt>
mov    (%r15),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1050 <my_exec@plt>
cmp    $0x1,%eax
je     1212 <s_arrow_left+0x92>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %ebp,%ebp
jmp    1212 <s_arrow_left+0x92>
lea    0xdf3(%rip),%rdi
call   1080 <my_putstr@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [24 x i8] c"The file doesn't exist\0A\00"
define i32 @s_arrow_left(i8** %0, i8** %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8**
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
%12 = load i32, i32* %9
%13 = call i8** @malloc(i32 24)
store i8** %13, i8*** %11
%14 = icmp eq i8** %13, null
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 -1, i32* %5
br label %54
16: ; preds = %4
%17 = load i8**, i8*** %11
%18 = call i8** @init_rm(i8** %17)
store i8** %18, i8*** %11
%19 = icmp eq i8** %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %5
br label %54
21: ; preds = %16
%22 = load i8**, i8*** %7
%23 = icmp eq i8** %22, null
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 -1, i32* %5
br label %54
25: ; preds = %21
%26 = load i8**, i8*** %7
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %28, i32 %29)
store i32 %30, i32* %10
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 @my_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %54
34: ; preds = %25
%35 = load i32, i32* %10
%36 = call i32 @read_file(i32 %35)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 -1, i32* %5
br label %54
39: ; preds = %34
%40 = load i8**, i8*** %6
%41 = load i8**, i8*** %8
%42 = call i32 @s_arrow_exec(i8** %40, i8** %41)
%43 = load i8**, i8*** %8
%44 = load i8**, i8*** %11
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %11
%48 = call i32 @my_exec(i8** %43, i8* %46, i8** %47)
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %51
50: ; preds = %39
store i32 -1, i32* %5
br label %54
51: ; preds = %39
%52 = load i8**, i8*** %11
%53 = call i32 @free(i8** %52)
store i32 0, i32* %5
br label %54
54: ; preds = %51, %50, %38, %32, %24, %20, %15
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [24 x i8] c"The file doesn't exist\0A\00"
define i32 @s_arrow_left(i8** %0, i8** %1, i8** %2, i32 %3) {
%5 = tail call i8** @malloc(i32 24)
%6 = icmp eq i8** %5, null
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = tail call i8** @init_rm(i8** %5)
%9 = icmp eq i8** %8, null
%10 = icmp eq i8** %1, null
%11 = or i1 %10, %9
br i1 %11, label %29, label %12
12: ; preds = %7
%13 = load i8*, i8** %1
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 @open(i8* %13, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @my_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %29
19: ; preds = %12
%20 = tail call i32 @read_file(i32 %15)
%21 = icmp eq i32 %20, -1
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = tail call i32 @s_arrow_exec(i8** %0, i8** %2)
%24 = load i8*, i8** %8
%25 = tail call i32 @my_exec(i8** %2, i8* %24, i8** %8)
%26 = icmp eq i32 %25, 1
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = tail call i32 @free(i8** %8)
br label %29
29: ; preds = %22, %19, %7, %4, %27, %17
%30 = phi i32 [ -1, %17 ], [ 0, %27 ], [ -1, %4 ], [ -1, %7 ], [ -1, %19 ], [ -1, %22 ]
ret i32 %30
}