#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int O_CREAT;
int O_RDWR;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ dup2(int, int);
scalar_t__ execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ wait(int *);
void runOut(char *command, char **args, int i) {
  pid_t childPid;
  int status, fdout, _stdout;
  char *argsOut[i];
  int x;
  for (x = 0; x < i; x++) {
    argsOut[x] = args[x];
  }
  _stdout = dup(1);
  fdout = open(args[i + 1], O_RDWR);
  if (fdout == -1) {
    fprintf(stderr, "File %s not exist, creating file.\n", args[i + 1]);
    fdout = open(args[i + 1], O_RDWR | O_CREAT,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
    if (fdout == -1) {
      fprintf(stderr, "Error while creating %s\n", args[i + 1]);
      exit(EXIT_FAILURE);
    } else {
      printf("File %s created with success. Check it's content.\n",
             args[i + 1]);
    }
  }
  if (args[i + 1] == NULL) {
    fprintf(stderr, "shox: syntax error near unexpected token `newline'");
  } else {
    dup2(fdout, 1);
    if ((childPid = fork()) < 0) {
      fprintf(stderr, "Not possible to create child process\n");
      exit(EXIT_FAILURE);
    } else if (childPid == 0) {
      close(fdout);
      close(_stdout);
      if (execvp(command, argsOut) < 0) {
        fprintf(stderr, "Not possible to execute %s\n", command);
        perror("[ERROR]");
        exit(EXIT_FAILURE);
      }
    } else if (childPid < 0) {
      fprintf(stderr, "Not possible to fork\n");
    } else {
      dup2(_stdout, 1);
      while (wait(&status) != childPid)
        ;
    }
  }
}


x86 assembly (clang, -O0):
<runOut>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1223 <runOut+0x73>
mov    -0x50(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x44(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdx
movslq -0x44(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11f1 <runOut+0x41>
mov    $0x1,%edi
call   1050 <dup@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1339 <runOut+0x189>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
mov    0x2d51(%rip),%rax
or     (%rax),%esi
mov    0x2cf8(%rip),%rax
mov    (%rax),%edx
mov    0x2d1f(%rip),%rax
or     (%rax),%edx
mov    0x2cfe(%rip),%rax
or     (%rax),%edx
mov    0x2ced(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1317 <runOut+0x167>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd0d(%rip),%rdi
call   1040 <printf@plt>
jmp    1339 <runOut+0x189>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    136d <runOut+0x1bd>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1480 <runOut+0x2d0>
mov    -0x28(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    13b4 <runOut+0x204>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c03(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1420 <runOut+0x270>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
mov    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   10a0 <execvp@plt>
cmp    $0x0,%rax
jge    141b <runOut+0x26b>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xcdc(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    1476 <runOut+0x2c6>
cmpq   $0x0,-0x20(%rbp)
jge    1447 <runOut+0x297>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1471 <runOut+0x2c1>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
lea    -0x24(%rbp),%rdi
call   10c0 <wait@plt>
cmp    -0x20(%rbp),%rax
je     146c <runOut+0x2bc>
jmp    1454 <runOut+0x2a4>
jmp    1471 <runOut+0x2c1>
jmp    1476 <runOut+0x2c6>
jmp    147b <runOut+0x2cb>
jmp    1480 <runOut+0x2d0>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runOut>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %rsi,%r13
mov    %rdi,-0x38(%rbp)
mov    %rsp,-0x40(%rbp)
mov    %edx,%edx
mov    %rsp,%r15
lea    0xf(,%rdx,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
test   %ebx,%ebx
jle    1208 <runOut+0x48>
shl    $0x3,%rdx
mov    %r15,%rdi
mov    %r13,%rsi
call   1080 <memcpy@plt>
mov    $0x1,%edi
call   1050 <dup@plt>
mov    %eax,-0x2c(%rbp)
movslq %ebx,%rbx
mov    0x8(%r13,%rbx,8),%rdi
add    $0x1,%rbx
mov    0x2db8(%rip),%r12
mov    (%r12),%esi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     1292 <runOut+0xd2>
cmpq   $0x0,0x0(%r13,%rbx,8)
je     1314 <runOut+0x154>
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
js     1364 <runOut+0x1a4>
je     132d <runOut+0x16d>
mov    %rax,%rbx
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
lea    -0x44(%rbp),%r14
xchg   %ax,%ax
mov    %r14,%rdi
call   10d0 <wait@plt>
cmp    %rbx,%rax
jne    1280 <runOut+0xc0>
jmp    1351 <runOut+0x191>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%rbx,8),%rdx
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
or     (%r12),%esi
mov    0x2ce6(%rip),%rax
mov    0x2d0f(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cec(%rip),%rax
or     (%rax),%edx
mov    0x0(%r13,%rbx,8),%rdi
mov    0x2cd6(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     137d <runOut+0x1bd>
mov    %eax,%r14d
mov    0x0(%r13,%rbx,8),%rsi
lea    0xd39(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,0x0(%r13,%rbx,8)
jne    1247 <runOut+0x87>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1351 <runOut+0x191>
mov    %r14d,%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   10b0 <execvp@plt>
test   %rax,%rax
js     139b <runOut+0x1db>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13c1 <runOut+0x201>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%rbx,8),%rdx
lea    0xc91(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13c1 <runOut+0x201>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    0xd1d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xd28(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@O_RDWR = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"File %s not exist, creating file.\0A\00"
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.1 = [25 x i8] c"Error while creating %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [51 x i8] c"File %s created with success. Check it's content.\0A\00"
@.str.3 = [51 x i8] c"shox: syntax error near unexpected token `newline'\00"
@.str.4 = [38 x i8] c"Not possible to create child process\0A\00"
@.str.5 = [28 x i8] c"Not possible to execute %s\0A\00"
@.str.6 = [8 x i8] c"[ERROR]\00"
@.str.7 = [22 x i8] c"Not possible to fork\0A\00"
define void @runOut(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca i8*, i64 %15
store i64 %15, i64* %12
store i32 0, i32* %13
br label %18
18: ; preds = %31, %3
%19 = load i32, i32* %13
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %13
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %17, i64 %29
store i8* %27, i8** %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %13
%33 = add nsw i32 %32, 1
store i32 %33, i32* %13
br label %18
34: ; preds = %18
%35 = call i32 @dup(i32 1)
store i32 %35, i32* %10
%36 = load i8**, i8*** %5
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %36, i64 %39
%41 = load i8*, i8** %40
%42 = load i32, i32* @O_RDWR
%43 = call i32 (i8*, i32, ...) @open(i8* %41, i32 %42)
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %94
46: ; preds = %34
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %48, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %53)
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %55, i64 %58
%60 = load i8*, i8** %59
%61 = load i32, i32* @O_RDWR
%62 = load i32, i32* @O_CREAT
%63 = or i32 %61, %62
%64 = load i32, i32* @S_IRUSR
%65 = load i32, i32* @S_IWUSR
%66 = or i32 %64, %65
%67 = load i32, i32* @S_IRGRP
%68 = or i32 %66, %67
%69 = load i32, i32* @S_IROTH
%70 = or i32 %68, %69
%71 = call i32 (i8*, i32, ...) @open(i8* %60, i32 %63, i32 %70)
store i32 %71, i32* %9
%72 = load i32, i32* %9
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %85
74: ; preds = %46
%75 = load i32, i32* @stderr
%76 = load i8**, i8*** %5
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %76, i64 %79
%81 = load i8*, i8** %80
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %46
%86 = load i8**, i8*** %5
%87 = load i32, i32* %6
%88 = add nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %86, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %85
br label %94
94: ; preds = %93, %34
%95 = load i8**, i8*** %5
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %95, i64 %98
%100 = load i8*, i8** %99
%101 = icmp eq i8* %100, null
br i1 %101, label %102, label %105
102: ; preds = %94
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %152
105: ; preds = %94
%106 = load i32, i32* %9
%107 = call i32 @dup2(i32 %106, i32 1)
%108 = call i64 (...) @fork()
store i64 %108, i64* %7
%109 = icmp slt i64 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %105
%111 = load i32, i32* @stderr
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %105
%116 = load i64, i64* %7
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %134
118: ; preds = %115
%119 = load i32, i32* %9
%120 = call i32 @close(i32 %119)
%121 = load i32, i32* %10
%122 = call i32 @close(i32 %121)
%123 = load i8*, i8** %4
%124 = call i64 @execvp(i8* %123, i8** %17)
%125 = icmp slt i64 %124, 0
br i1 %125, label %126, label %133
126: ; preds = %118
%127 = load i32, i32* @stderr
%128 = load i8*, i8** %4
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %128)
%130 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%131 = load i32, i32* @EXIT_FAILURE
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %118
br label %150
134: ; preds = %115
%135 = load i64, i64* %7
%136 = icmp slt i64 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %134
%138 = load i32, i32* @stderr
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %149
140: ; preds = %134
%141 = load i32, i32* %10
%142 = call i32 @dup2(i32 %141, i32 1)
br label %143
143: ; preds = %147, %140
%144 = call i64 @wait(i32* %8)
%145 = load i64, i64* %7
%146 = icmp ne i64 %144, %145
br i1 %146, label %147, label %148
147: ; preds = %143
br label %143
148: ; preds = %143
br label %149
149: ; preds = %148, %137
br label %150
150: ; preds = %149, %133
br label %151
151: ; preds = %150
br label %152
152: ; preds = %151, %102
%153 = load i8*, i8** %11
ret void
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"File %s not exist, creating file.\0A\00"
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.1 = [25 x i8] c"Error while creating %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [51 x i8] c"File %s created with success. Check it's content.\0A\00"
@.str.3 = [51 x i8] c"shox: syntax error near unexpected token `newline'\00"
@.str.4 = [38 x i8] c"Not possible to create child process\0A\00"
@.str.5 = [28 x i8] c"Not possible to execute %s\0A\00"
@.str.6 = [8 x i8] c"[ERROR]\00"
define void @runOut(i8* %0, i8** nocapture %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = zext i32 %2 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8*, i64 %6
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = bitcast i8** %8 to i8*
%12 = bitcast i8** %1 to i8*
%13 = shl nuw nsw i64 %6, 3
br label %14
14: ; preds = %10, %3
%15 = tail call i32 @dup(i32 1)
%16 = add nsw i32 %2, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = load i32, i32* @O_RDWR
%21 = tail call i32 (i8*, i32, ...) @open(i8* %19, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %49
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %18
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %18
%28 = load i32, i32* @O_RDWR
%29 = load i32, i32* @O_CREAT
%30 = or i32 %29, %28
%31 = load i32, i32* @S_IRUSR
%32 = load i32, i32* @S_IWUSR
%33 = or i32 %32, %31
%34 = load i32, i32* @S_IRGRP
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IROTH
%37 = or i32 %35, %36
%38 = tail call i32 (i8*, i32, ...) @open(i8* %27, i32 %30, i32 %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %46
40: ; preds = %23
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %18
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %23
%47 = load i8*, i8** %18
%48 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %14
%50 = phi i32 [ %38, %46 ], [ %21, %14 ]
%51 = load i8*, i8** %18
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %83
56: ; preds = %49
%57 = tail call i32 @dup2(i32 %50, i32 1)
%58 = tail call i64 (...) @fork()
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @exit(i32 %63)
unreachable
65: ; preds = %56
%66 = icmp eq i64 %58, 0
br i1 %66, label %67, label %78
67: ; preds = %65
%68 = tail call i32 @close(i32 %50)
%69 = tail call i32 @close(i32 %15)
%70 = call i64 @execvp(i8* %0, i8** %8)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %83
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%75 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %65
%79 = tail call i32 @dup2(i32 %15, i32 1)
br label %80
80: ; preds = %80, %78
%81 = call i64 @wait(i32* %4)
%82 = icmp eq i64 %81, %58
br i1 %82, label %83, label %80
83: ; preds = %80, %67, %53
ret void
}