#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 O_APPEND;
int O_CREAT;
int O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ builtInCommands(char *, char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ execvp(char *, char **);
int fork();
int /*<<< orphan*/ open(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int wait(int *);
void processCommand(char command[512]) {
  char *args[512], *cmd, *arg;
  int pid, status, redir = 0, rediri = 0, i = 1, builtin = 0;
  command[strlen(command) - 1] = 0;
  cmd = strtok(command, " ");
  arg = strtok(0, " ");
  if (!builtInCommands(cmd, arg)) {
    args[0] = cmd;
    while (arg != NULL) {
      args[i] = arg;
      if (strcmp(arg, "<") == 0) {
        rediri = i;
        redir = 1;
      } else if (strcmp(arg, ">") == 0) {
        rediri = i;
        redir = 2;
      } else if (strcmp(arg, ">>") == 0) {
        rediri = i;
        redir = 3;
      }
      arg = strtok(0, " ");
      i++;
    }
    if (!rediri)
      args[i] = NULL;
    else
      args[rediri] = NULL;
    pid = fork();
    if (!pid) {
      if (redir == 1) {
        close(0);
        open(args[i - 1], O_RDONLY);
      } else if (redir == 2) {
        close(1);
        open(args[i - 1], O_WRONLY | O_CREAT, 0644);
      } else if (redir == 3) {
        close(1);
        open(args[i - 1], O_WRONLY | O_APPEND);
      }
      execvp(cmd, args);
      printf("couldn't execute: %s", cmd);
    } else if (pid) {
      pid = wait(&status);
      printf("Child Exit Code: %d\n", status);
    }
  }
}


x86 assembly (clang, -O0):
<processCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x102c(%rbp)
movl   $0x0,-0x1030(%rbp)
movl   $0x1,-0x1034(%rbp)
movl   $0x0,-0x1038(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1040(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1040(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x1018(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde0(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x1020(%rbp)
mov    -0x1018(%rbp),%rdi
mov    -0x1020(%rbp),%rsi
call   1070 <builtInCommands@plt>
cmp    $0x0,%eax
jne    14e4 <processCommand+0x344>
mov    -0x1018(%rbp),%rax
mov    %rax,-0x1010(%rbp)
cmpq   $0x0,-0x1020(%rbp)
je     1352 <processCommand+0x1b2>
mov    -0x1020(%rbp),%rcx
movslq -0x1034(%rbp),%rax
mov    %rcx,-0x1010(%rbp,%rax,8)
ff
mov    -0x1020(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b2 <processCommand+0x112>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x1030(%rbp)
movl   $0x1,-0x102c(%rbp)
jmp    1327 <processCommand+0x187>
mov    -0x1020(%rbp),%rdi
lea    0xd45(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ea <processCommand+0x14a>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x1030(%rbp)
movl   $0x2,-0x102c(%rbp)
jmp    1322 <processCommand+0x182>
mov    -0x1020(%rbp),%rdi
lea    0xd0c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    131d <processCommand+0x17d>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x1030(%rbp)
movl   $0x3,-0x102c(%rbp)
jmp    1322 <processCommand+0x182>
jmp    1327 <processCommand+0x187>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcce(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x1020(%rbp)
mov    -0x1034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1034(%rbp)
jmp    1256 <processCommand+0xb6>
cmpl   $0x0,-0x1030(%rbp)
jne    1377 <processCommand+0x1d7>
movslq -0x1034(%rbp),%rax
movq   $0x0,-0x1010(%rbp,%rax,8)
jmp    138a <processCommand+0x1ea>
movslq -0x1030(%rbp),%rax
movq   $0x0,-0x1010(%rbp,%rax,8)
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1024(%rbp)
jne    14a7 <processCommand+0x307>
cmpl   $0x1,-0x102c(%rbp)
jne    13e0 <processCommand+0x240>
xor    %edi,%edi
call   1050 <close@plt>
mov    -0x1034(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1010(%rbp,%rax,8),%rdi
ff
mov    0x2c0e(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
jmp    147a <processCommand+0x2da>
cmpl   $0x2,-0x102c(%rbp)
jne    142d <processCommand+0x28d>
mov    $0x1,%edi
call   1050 <close@plt>
mov    -0x1034(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1010(%rbp,%rax,8),%rdi
ff
mov    0x2bb7(%rip),%rax
mov    (%rax),%esi
mov    0x2bde(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   1080 <open@plt>
jmp    1475 <processCommand+0x2d5>
cmpl   $0x3,-0x102c(%rbp)
jne    1470 <processCommand+0x2d0>
mov    $0x1,%edi
call   1050 <close@plt>
mov    -0x1034(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1010(%rbp,%rax,8),%rdi
ff
mov    0x2b6a(%rip),%rax
mov    (%rax),%esi
mov    0x2b59(%rip),%rax
or     (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
jmp    1475 <processCommand+0x2d5>
jmp    147a <processCommand+0x2da>
mov    -0x1018(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10a0 <execvp@plt>
mov    -0x1018(%rbp),%rsi
lea    0xb6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14df <processCommand+0x33f>
cmpl   $0x0,-0x1024(%rbp)
je     14da <processCommand+0x33a>
lea    -0x1028(%rbp),%rdi
call   10b0 <wait@plt>
mov    %eax,-0x1024(%rbp)
mov    -0x1028(%rbp),%esi
lea    0xb49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14df <processCommand+0x33f>
jmp    14e4 <processCommand+0x344>
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe39(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbx
xor    %r13d,%r13d
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <builtInCommands@plt>
test   %eax,%eax
jne    13a3 <processCommand+0x203>
mov    %rbx,0x10(%rsp)
test   %rbp,%rbp
je     12b7 <processCommand+0x117>
mov    %rbx,0x8(%rsp)
xor    %r12d,%r12d
mov    $0x1,%r14d
lea    0xde7(%rip),%r15
lea    0xdde(%rip),%rbx
xor    %r13d,%r13d
jmp    124f <processCommand+0xaf>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r13d
mov    %r14d,%r12d
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbp
add    $0x1,%r14
test   %rax,%rax
je     12a8 <processCommand+0x108>
mov    %rbp,0x10(%rsp,%r14,8)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1230 <processCommand+0x90>
mov    %rbp,%rdi
lea    0xd97(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12a0 <processCommand+0x100>
mov    %rbp,%rdi
lea    0xd82(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    $0x3,%eax
cmove  %eax,%r13d
cmove  %r14d,%r12d
jmp    1239 <processCommand+0x99>
nopl   0x0(%rax)
mov    $0x2,%r13d
jmp    1236 <processCommand+0x96>
test   %r12d,%r12d
je     12bf <processCommand+0x11f>
movslq %r12d,%rax
mov    0x8(%rsp),%rbx
jmp    12c7 <processCommand+0x127>
mov    $0x1,%r14d
jmp    12c4 <processCommand+0x124>
mov    0x8(%rsp),%rbx
mov    %r14d,%eax
movq   $0x0,0x10(%rsp,%rax,8)
xor    %eax,%eax
call   10c0 <fork@plt>
test   %eax,%eax
je     12fc <processCommand+0x15c>
lea    0x4(%rsp),%rdi
call   10b0 <wait@plt>
mov    0x4(%rsp),%esi
lea    0xd2c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    13a3 <processCommand+0x203>
cmp    $0x3,%r13d
je     1328 <processCommand+0x188>
cmp    $0x2,%r13d
je     1355 <processCommand+0x1b5>
cmp    $0x1,%r13d
jne    1385 <processCommand+0x1e5>
xor    %edi,%edi
call   1050 <close@plt>
movslq %r14d,%rax
mov    0x8(%rsp,%rax,8),%rdi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
jmp    134c <processCommand+0x1ac>
mov    $0x1,%edi
call   1050 <close@plt>
movslq %r14d,%rax
mov    0x8(%rsp,%rax,8),%rdi
mov    0x2c87(%rip),%rax
mov    0x2c78(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
xor    %eax,%eax
call   1080 <open@plt>
jmp    1385 <processCommand+0x1e5>
mov    $0x1,%edi
call   1050 <close@plt>
movslq %r14d,%rax
mov    0x8(%rsp,%rax,8),%rdi
mov    0x2c5a(%rip),%rax
mov    0x2c83(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   1080 <open@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <execvp@plt>
lea    0xc6e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1018,%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"
@.str.2 = [2 x i8] c">\00"
@.str.3 = [3 x i8] c">>\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.4 = [21 x i8] c"couldn't execute: %s\00"
@.str.5 = [21 x i8] c"Child Exit Code: %d\0A\00"
define void @processCommand(i8* %0) {
%2 = alloca i8*
%3 = alloca [512 x i8*]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
store i32 0, i32* %11
%12 = load i8*, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %12, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %2
%19 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %5
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 @builtInCommands(i8* %21, i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %131, label %25
25: ; preds = %1
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 0
store i8* %26, i8** %27
br label %28
28: ; preds = %55, %25
%29 = load i8*, i8** %5
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %59
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %34
store i8* %32, i8** %35
%36 = load i8*, i8** %5
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = load i32, i32* %10
store i32 %40, i32* %9
store i32 1, i32* %8
br label %55
41: ; preds = %31
%42 = load i8*, i8** %5
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* %10
store i32 %46, i32* %9
store i32 2, i32* %8
br label %54
47: ; preds = %41
%48 = load i8*, i8** %5
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = load i32, i32* %10
store i32 %52, i32* %9
store i32 3, i32* %8
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53, %45
br label %55
55: ; preds = %54, %39
%56 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %56, i8** %5
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %28
59: ; preds = %28
%60 = load i32, i32* %9
%61 = icmp ne i32 %60, 0
br i1 %61, label %66, label %62
62: ; preds = %59
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %64
store i8* null, i8** %65
br label %70
66: ; preds = %59
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %68
store i8* null, i8** %69
br label %70
70: ; preds = %66, %62
%71 = call i32 (...) @fork()
store i32 %71, i32* %6
%72 = load i32, i32* %6
%73 = icmp ne i32 %72, 0
br i1 %73, label %122, label %74
74: ; preds = %70
%75 = load i32, i32* %8
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %86
77: ; preds = %74
%78 = call i32 @close(i32 0)
%79 = load i32, i32* %10
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %81
%83 = load i8*, i8** %82
%84 = load i32, i32* @O_RDONLY
%85 = call i32 (i8*, i32, ...) @open(i8* %83, i32 %84)
br label %116
86: ; preds = %74
%87 = load i32, i32* %8
%88 = icmp eq i32 %87, 2
br i1 %88, label %89, label %100
89: ; preds = %86
%90 = call i32 @close(i32 1)
%91 = load i32, i32* %10
%92 = sub nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %93
%95 = load i8*, i8** %94
%96 = load i32, i32* @O_WRONLY
%97 = load i32, i32* @O_CREAT
%98 = or i32 %96, %97
%99 = call i32 (i8*, i32, ...) @open(i8* %95, i32 %98, i32 420)
br label %115
100: ; preds = %86
%101 = load i32, i32* %8
%102 = icmp eq i32 %101, 3
br i1 %102, label %103, label %114
103: ; preds = %100
%104 = call i32 @close(i32 1)
%105 = load i32, i32* %10
%106 = sub nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 %107
%109 = load i8*, i8** %108
%110 = load i32, i32* @O_WRONLY
%111 = load i32, i32* @O_APPEND
%112 = or i32 %110, %111
%113 = call i32 (i8*, i32, ...) @open(i8* %109, i32 %112)
br label %114
114: ; preds = %103, %100
br label %115
115: ; preds = %114, %89
br label %116
116: ; preds = %115, %77
%117 = load i8*, i8** %4
%118 = getelementptr inbounds [512 x i8*], [512 x i8*]* %3, i64 0, i64 0
%119 = call i32 @execvp(i8* %117, i8** %118)
%120 = load i8*, i8** %4
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %120)
br label %130
122: ; preds = %70
%123 = load i32, i32* %6
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %122
%126 = call i32 @wait(i32* %7)
store i32 %126, i32* %6
%127 = load i32, i32* %7
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %127)
br label %129
129: ; preds = %125, %122
br label %130
130: ; preds = %129, %116
br label %131
131: ; preds = %130, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"<\00"
@.str.2 = [2 x i8] c">\00"
@.str.3 = [3 x i8] c">>\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_APPEND = global i32 0
@.str.4 = [21 x i8] c"couldn't execute: %s\00"
@.str.5 = [21 x i8] c"Child Exit Code: %d\0A\00"
define void @processCommand(i8* %0) {
%2 = alloca [512 x i8*]
%3 = alloca i32
%4 = bitcast [512 x i8*]* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 0, i8* %9
%10 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @builtInCommands(i8* %10, i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %92
14: ; preds = %1
%15 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 0
store i8* %10, i8** %15
%16 = icmp eq i8* %11, null
br i1 %16, label %43, label %17
17: ; preds = %14, %34
%18 = phi i64 [ %38, %34 ], [ 1, %14 ]
%19 = phi i8* [ %37, %34 ], [ %11, %14 ]
%20 = phi i32 [ %36, %34 ], [ 0, %14 ]
%21 = phi i32 [ %35, %34 ], [ 0, %14 ]
%22 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 %18
store i8* %19, i8** %22
%23 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = trunc i64 %18 to i32
br i1 %24, label %34, label %26
26: ; preds = %17
%27 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i32 3, i32 %21
%33 = select i1 %31, i32 %25, i32 %20
br label %34
34: ; preds = %29, %26, %17
%35 = phi i32 [ 1, %17 ], [ 2, %26 ], [ %32, %29 ]
%36 = phi i32 [ %25, %17 ], [ %25, %26 ], [ %33, %29 ]
%37 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%38 = add nuw i64 %18, 1
%39 = icmp eq i8* %37, null
br i1 %39, label %40, label %17
40: ; preds = %34
%41 = trunc i64 %38 to i32
%42 = icmp eq i32 %36, 0
br i1 %42, label %43, label %47
43: ; preds = %14, %40
%44 = phi i32 [ %41, %40 ], [ 1, %14 ]
%45 = phi i32 [ %35, %40 ], [ 0, %14 ]
%46 = zext i32 %44 to i64
br label %49
47: ; preds = %40
%48 = sext i32 %36 to i64
br label %49
49: ; preds = %47, %43
%50 = phi i64 [ %48, %47 ], [ %46, %43 ]
%51 = phi i32 [ %41, %47 ], [ %44, %43 ]
%52 = phi i32 [ %35, %47 ], [ %45, %43 ]
%53 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 %50
store i8* null, i8** %53
%54 = tail call i32 (...) @fork()
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %88
56: ; preds = %49
switch i32 %52, label %85 [
i32 1, label %57
i32 2, label %65
i32 3, label %75
]
57: ; preds = %56
%58 = tail call i32 @close(i32 0)
%59 = add nsw i32 %51, -1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* @O_RDONLY
%64 = tail call i32 (i8*, i32, ...) @open(i8* %62, i32 %63)
br label %85
65: ; preds = %56
%66 = tail call i32 @close(i32 1)
%67 = add nsw i32 %51, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* @O_WRONLY
%72 = load i32, i32* @O_CREAT
%73 = or i32 %72, %71
%74 = tail call i32 (i8*, i32, ...) @open(i8* %70, i32 %73, i32 420)
br label %85
75: ; preds = %56
%76 = tail call i32 @close(i32 1)
%77 = add nsw i32 %51, -1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [512 x i8*], [512 x i8*]* %2, i64 0, i64 %78
%80 = load i8*, i8** %79
%81 = load i32, i32* @O_WRONLY
%82 = load i32, i32* @O_APPEND
%83 = or i32 %82, %81
%84 = tail call i32 (i8*, i32, ...) @open(i8* %80, i32 %83)
br label %85
85: ; preds = %56, %65, %75, %57
%86 = call i32 @execvp(i8* %10, i8** %15)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %10)
br label %92
88: ; preds = %49
%89 = call i32 @wait(i32* %3)
%90 = load i32, i32* %3
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %85, %88, %1
ret void
}