#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 my_exec(char **, char *, char **);
int /*<<< orphan*/ my_putchar(char);
scalar_t__ my_strcmp2(char *, char *);
int s_arrow_exec(char **command, char **env) {
  int i;
  i = 0;
  if ((command[0][0] == 'c' && command[0][1] == 'a' && command[0][2] == 't') ||
      (command[0][0] == 'w' && command[0][1] == 'c') ||
      (my_strcmp2(command[0], "/bin/cat") == 0) ||
      (my_strcmp2(command[0], "/usr/bin/wc") == 0)) {
    while (command[i])
      i++;
    command[i++] = "tmp";
    command[i] = NULL;
    if (my_exec(env, command[0], command) == 1)
      return (-1);
    my_putchar('\n');
  } else if (my_exec(env, command[0], command) == 1)
    return (-1);
  return (0);
}


x86 assembly (clang, -O0):
<s_arrow_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    1182 <s_arrow_exec+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x61,%eax
jne    1182 <s_arrow_exec+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x2(%rax),%eax
cmp    $0x74,%eax
je     11e3 <s_arrow_exec+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x77,%eax
jne    11a9 <s_arrow_exec+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x63,%eax
je     11e3 <s_arrow_exec+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe49(%rip),%rsi
call   1050 <my_strcmp2@plt>
cmp    $0x0,%rax
je     11e3 <s_arrow_exec+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe35(%rip),%rsi
call   1050 <my_strcmp2@plt>
cmp    $0x0,%rax
jne    126e <s_arrow_exec+0x13e>
jmp    11e8 <s_arrow_exec+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1209 <s_arrow_exec+0xd9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e8 <s_arrow_exec+0xb8>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
lea    0xdf3(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <my_exec@plt>
cmp    $0x1,%eax
jne    125f <s_arrow_exec+0x12f>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <s_arrow_exec+0x173>
mov    $0xa,%edi
call   1040 <my_putchar@plt>
jmp    129c <s_arrow_exec+0x16c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <my_exec@plt>
cmp    $0x1,%eax
jne    1297 <s_arrow_exec+0x167>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <s_arrow_exec+0x173>
jmp    129c <s_arrow_exec+0x16c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_arrow_exec>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    (%rdi),%al
cmp    $0x77,%al
je     1155 <s_arrow_exec+0x25>
cmp    $0x63,%al
jne    115b <s_arrow_exec+0x2b>
cmpb   $0x61,0x1(%rdi)
jne    115b <s_arrow_exec+0x2b>
cmpb   $0x74,0x2(%rdi)
jne    115b <s_arrow_exec+0x2b>
jmp    119c <s_arrow_exec+0x6c>
cmpb   $0x63,0x1(%rdi)
je     119c <s_arrow_exec+0x6c>
lea    0xe9e(%rip),%rsi
call   1050 <my_strcmp2@plt>
test   %rax,%rax
je     119c <s_arrow_exec+0x6c>
mov    (%rbx),%rdi
lea    0xe93(%rip),%rsi
call   1050 <my_strcmp2@plt>
test   %rax,%rax
je     119c <s_arrow_exec+0x6c>
mov    (%rbx),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <my_exec@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    11e7 <s_arrow_exec+0xb7>
jmp    11e9 <s_arrow_exec+0xb9>
xor    %eax,%eax
xchg   %ax,%ax
cmpq   $0x0,(%rbx,%rax,8)
lea    0x1(%rax),%rax
jne    11a0 <s_arrow_exec+0x70>
lea    -0x1(%rax),%ecx
lea    0xe60(%rip),%rdx
mov    %rdx,(%rbx,%rcx,8)
mov    %eax,%eax
movq   $0x0,(%rbx,%rax,8)
mov    (%rbx),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <my_exec@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
je     11e9 <s_arrow_exec+0xb9>
mov    $0xa,%edi
call   1040 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/bin/cat\00"
@.str.1 = [12 x i8] c"/usr/bin/wc\00"
@.str.2 = [4 x i8] c"tmp\00"
define i32 @s_arrow_exec(i8** %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i32
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 99
br i1 %13, label %14, label %30
14: ; preds = %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 97
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 116
br i1 %29, label %58, label %30
30: ; preds = %22, %14, %2
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 119
br i1 %37, label %38, label %46
38: ; preds = %30
%39 = load i8**, i8*** %4
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 99
br i1 %45, label %58, label %46
46: ; preds = %38, %30
%47 = load i8**, i8*** %4
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i64 @my_strcmp2(i8* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %46
%53 = load i8**, i8*** %4
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i64 @my_strcmp2(i8* %55, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %89
58: ; preds = %52, %46, %38, %22
br label %59
59: ; preds = %66, %58
%60 = load i8**, i8*** %4
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %59
69: ; preds = %59
%70 = load i8**, i8*** %4
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8*, i8** %70, i64 %73
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %74
%75 = load i8**, i8*** %4
%76 = load i32, i32* %6
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
store i8* null, i8** %78
%79 = load i8**, i8*** %5
%80 = load i8**, i8*** %4
%81 = getelementptr inbounds i8*, i8** %80, i64 0
%82 = load i8*, i8** %81
%83 = load i8**, i8*** %4
%84 = call i32 @my_exec(i8** %79, i8* %82, i8** %83)
%85 = icmp eq i32 %84, 1
br i1 %85, label %86, label %87
86: ; preds = %69
store i32 -1, i32* %3
br label %100
87: ; preds = %69
%88 = call i32 @my_putchar(i8 signext 10)
br label %99
89: ; preds = %52
%90 = load i8**, i8*** %5
%91 = load i8**, i8*** %4
%92 = getelementptr inbounds i8*, i8** %91, i64 0
%93 = load i8*, i8** %92
%94 = load i8**, i8*** %4
%95 = call i32 @my_exec(i8** %90, i8* %93, i8** %94)
%96 = icmp eq i32 %95, 1
br i1 %96, label %97, label %98
97: ; preds = %89
store i32 -1, i32* %3
br label %100
98: ; preds = %89
br label %99
99: ; preds = %98, %87
store i32 0, i32* %3
br label %100
100: ; preds = %99, %97, %86
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [9 x i8] c"/bin/cat\00"
@.str.1 = [12 x i8] c"/usr/bin/wc\00"
@.str.2 = [4 x i8] c"tmp\00"
define i32 @s_arrow_exec(i8** %0, i8** %1) {
%3 = load i8*, i8** %0
%4 = load i8, i8* %3
switch i8 %4, label %17 [
i8 99, label %5
i8 119, label %13
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 97
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %3, i64 2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 116
br i1 %12, label %24, label %17
13: ; preds = %2
%14 = getelementptr inbounds i8, i8* %3, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 99
br i1 %16, label %24, label %17
17: ; preds = %2, %5, %9, %13
%18 = tail call i64 @my_strcmp2(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i8*, i8** %0
%22 = tail call i64 @my_strcmp2(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %42
24: ; preds = %20, %17, %13, %9
br label %25
25: ; preds = %24, %25
%26 = phi i64 [ %30, %25 ], [ 0, %24 ]
%27 = getelementptr inbounds i8*, i8** %0, i64 %26
%28 = load i8*, i8** %27
%29 = icmp eq i8* %28, null
%30 = add nuw i64 %26, 1
br i1 %29, label %31, label %25
31: ; preds = %25
%32 = and i64 %26, 4294967295
%33 = getelementptr inbounds i8*, i8** %0, i64 %32
%34 = add i64 %26, 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %33
%35 = and i64 %34, 4294967295
%36 = getelementptr inbounds i8*, i8** %0, i64 %35
store i8* null, i8** %36
%37 = load i8*, i8** %0
%38 = tail call i32 @my_exec(i8** %1, i8* %37, i8** %0)
%39 = icmp eq i32 %38, 1
br i1 %39, label %47, label %40
40: ; preds = %31
%41 = tail call i32 @my_putchar(i8 signext 10)
br label %46
42: ; preds = %20
%43 = load i8*, i8** %0
%44 = tail call i32 @my_exec(i8** %1, i8* %43, i8** %0)
%45 = icmp eq i32 %44, 1
br i1 %45, label %47, label %46
46: ; preds = %42, %40
br label %47
47: ; preds = %42, %31, %46
%48 = phi i32 [ 0, %46 ], [ -1, %31 ], [ -1, %42 ]
ret i32 %48
}