#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*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int execve(char const *, char *const *, char *const *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int createChild(const char *szCommand, char *const aArguments[],
                char *const aEnvironment[], int aPipes[]) {
  int nChild;
  int nResult;
  int aStdinPipe[2];
  int aStdoutPipe[2];
  int aStderrPipe[2];
  if (pipe(aStdinPipe) < 0) {
    perror("allocating pipe for child stdin redirect");
    return -1;
  }
  if (pipe(aStdoutPipe) < 0) {
    close(aStdinPipe[0]);
    close(aStdinPipe[1]);
    perror("allocating pipe for child stdout redirect");
    return -1;
  }
  if (pipe(aStderrPipe) < 0) {
    close(aStdinPipe[0]);
    close(aStdinPipe[1]);
    close(aStdoutPipe[0]);
    close(aStdoutPipe[1]);
    perror("allocating pipe for child stderr redirect");
    return -1;
  }
  nChild = fork();
  if (0 == nChild) {
    if (dup2(aStdinPipe[0], STDIN_FILENO) == -1) {
      perror("redirecting stdin");
      return -1;
    }
    if (dup2(aStdoutPipe[1], STDOUT_FILENO) == -1) {
      perror("redirecting stdout");
      return -1;
    }
    if (dup2(aStderrPipe[1], STDERR_FILENO) == -1) {
      perror("redirecting stderr");
      return -1;
    }
    close(aStdinPipe[0]);
    close(aStdinPipe[1]);
    close(aStdoutPipe[0]);
    close(aStdoutPipe[1]);
    close(aStderrPipe[0]);
    close(aStderrPipe[1]);
    nResult = execve(szCommand, aArguments, aEnvironment);
    perror("exec of the child process");
    exit(nResult);
  } else if (nChild > 0) {
    close(aStdinPipe[0]);
    close(aStdoutPipe[1]);
    close(aStderrPipe[1]);
  } else {
    close(aStdinPipe[0]);
    close(aStdinPipe[1]);
    close(aStdoutPipe[0]);
    close(aStdoutPipe[1]);
    close(aStderrPipe[0]);
    close(aStderrPipe[1]);
  }
  aPipes[0] = aStdinPipe[1];
  aPipes[1] = aStdoutPipe[0];
  aPipes[2] = aStderrPipe[0];
  return nChild;
}


x86 assembly (clang, -O0):
<createChild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jge    11b3 <createChild+0x43>
lea    0xe5e(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
lea    -0x40(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jge    11ee <createChild+0x7e>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
lea    0xe4c(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
lea    -0x48(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jge    1239 <createChild+0xc9>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
mov    -0x40(%rbp),%edi
call   1040 <close@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
lea    0xe2b(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmp    -0x2c(%rbp),%eax
jne    133c <createChild+0x1cc>
mov    -0x38(%rbp),%edi
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1280 <createChild+0x110>
lea    0xe0e(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
mov    -0x3c(%rbp),%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12b2 <createChild+0x142>
lea    0xdee(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
mov    -0x44(%rbp),%edi
mov    0x2d1c(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12e4 <createChild+0x174>
lea    0xdcf(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bb <createChild+0x24b>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
mov    -0x40(%rbp),%edi
call   1040 <close@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
mov    -0x48(%rbp),%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <execve@plt>
mov    %eax,-0x30(%rbp)
lea    0xd86(%rip),%rdi
call   1070 <perror@plt>
mov    -0x30(%rbp),%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    1363 <createChild+0x1f3>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
jmp    1393 <createChild+0x223>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
mov    -0x40(%rbp),%edi
call   1040 <close@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
mov    -0x48(%rbp),%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
jmp    1398 <createChild+0x228>
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x48(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createChild>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x8(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     122b <createChild+0xbb>
lea    0x10(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     1237 <createChild+0xc7>
lea    0x18(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
js     1255 <createChild+0xe5>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     1282 <createChild+0x112>
mov    %eax,%ebp
mov    0x8(%rsp),%edi
call   1040 <close@plt>
test   %ebp,%ebp
jle    11e5 <createChild+0x75>
mov    0x14(%rsp),%edi
jmp    1204 <createChild+0x94>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0x14(%rsp),%edi
call   1040 <close@plt>
mov    0x18(%rsp),%edi
call   1040 <close@plt>
mov    0x1c(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%rbx)
mov    0x10(%rsp),%eax
mov    %eax,0x4(%rbx)
mov    0x18(%rsp),%eax
mov    %eax,0x8(%rbx)
jmp    12ea <createChild+0x17a>
lea    0xdce(%rip),%rdi
jmp    12e0 <createChild+0x170>
mov    0x8(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
lea    0xdd9(%rip),%rdi
jmp    12e0 <createChild+0x170>
mov    0x8(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0x14(%rsp),%edi
call   1040 <close@plt>
lea    0xdd3(%rip),%rdi
jmp    12e0 <createChild+0x170>
mov    0x8(%rsp),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12a2 <createChild+0x132>
lea    0xddd(%rip),%rdi
jmp    12e0 <createChild+0x170>
mov    0x14(%rsp),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12c2 <createChild+0x152>
lea    0xdcf(%rip),%rdi
jmp    12e0 <createChild+0x170>
mov    0x1c(%rsp),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12f9 <createChild+0x189>
lea    0xdc2(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0x14(%rsp),%edi
call   1040 <close@plt>
mov    0x18(%rsp),%edi
call   1040 <close@plt>
mov    0x1c(%rsp),%edi
call   1040 <close@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <execve@plt>
mov    %eax,%ebx
lea    0xd6f(%rip),%rdi
call   1070 <perror@plt>
mov    %ebx,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"allocating pipe for child stdin redirect\00"
@.str.1 = [42 x i8] c"allocating pipe for child stdout redirect\00"
@.str.2 = [42 x i8] c"allocating pipe for child stderr redirect\00"
@STDIN_FILENO = global i32 0
@.str.3 = [18 x i8] c"redirecting stdin\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [19 x i8] c"redirecting stdout\00"
@STDERR_FILENO = global i32 0
@.str.5 = [19 x i8] c"redirecting stderr\00"
@.str.6 = [26 x i8] c"exec of the child process\00"
define i32 @createChild(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 i32
%12 = alloca [2 x i32]
%13 = alloca [2 x i32]
%14 = alloca [2 x i32]
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%16 = call i64 @pipe(i32* %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
20: ; preds = %4
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%22 = call i64 @pipe(i32* %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%26 = load i32, i32* %25
%27 = call i32 @close(i32 %26)
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
32: ; preds = %20
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%34 = call i64 @pipe(i32* %33)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%38 = load i32, i32* %37
%39 = call i32 @close(i32 %38)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%44 = load i32, i32* %43
%45 = call i32 @close(i32 %44)
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%47 = load i32, i32* %46
%48 = call i32 @close(i32 %47)
%49 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
50: ; preds = %32
%51 = call i32 (...) @fork()
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp eq i32 0, %52
br i1 %53, label %54, label %104
54: ; preds = %50
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%56 = load i32, i32* %55
%57 = load i32, i32* @STDIN_FILENO
%58 = call i32 @dup2(i32 %56, i32 %57)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %54
%61 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
62: ; preds = %54
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%64 = load i32, i32* %63
%65 = load i32, i32* @STDOUT_FILENO
%66 = call i32 @dup2(i32 %64, i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %70
68: ; preds = %62
%69 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
70: ; preds = %62
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%72 = load i32, i32* %71
%73 = load i32, i32* @STDERR_FILENO
%74 = call i32 @dup2(i32 %72, i32 %73)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %5
br label %151
78: ; preds = %70
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%92 = load i32, i32* %91
%93 = call i32 @close(i32 %92)
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%95 = load i32, i32* %94
%96 = call i32 @close(i32 %95)
%97 = load i8*, i8** %6
%98 = load i8**, i8*** %7
%99 = load i8**, i8*** %8
%100 = call i32 @execve(i8* %97, i8** %98, i8** %99)
store i32 %100, i32* %11
%101 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%102 = load i32, i32* %11
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %50
%105 = load i32, i32* %10
%106 = icmp sgt i32 %105, 0
br i1 %106, label %107, label %117
107: ; preds = %104
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%109 = load i32, i32* %108
%110 = call i32 @close(i32 %109)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
br label %136
117: ; preds = %104
%118 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%119 = load i32, i32* %118
%120 = call i32 @close(i32 %119)
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%122 = load i32, i32* %121
%123 = call i32 @close(i32 %122)
%124 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%125 = load i32, i32* %124
%126 = call i32 @close(i32 %125)
%127 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%128 = load i32, i32* %127
%129 = call i32 @close(i32 %128)
%130 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%131 = load i32, i32* %130
%132 = call i32 @close(i32 %131)
%133 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%134 = load i32, i32* %133
%135 = call i32 @close(i32 %134)
br label %136
136: ; preds = %117, %107
br label %137
137: ; preds = %136
%138 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%139 = load i32, i32* %138
%140 = load i32*, i32** %9
%141 = getelementptr inbounds i32, i32* %140, i64 0
store i32 %139, i32* %141
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%143 = load i32, i32* %142
%144 = load i32*, i32** %9
%145 = getelementptr inbounds i32, i32* %144, i64 1
store i32 %143, i32* %145
%146 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%147 = load i32, i32* %146
%148 = load i32*, i32** %9
%149 = getelementptr inbounds i32, i32* %148, i64 2
store i32 %147, i32* %149
%150 = load i32, i32* %10
store i32 %150, i32* %5
br label %151
151: ; preds = %137, %76, %68, %60, %36, %24, %18
%152 = load i32, i32* %5
ret i32 %152
}

LLVM IR (-O2):
@.str = [41 x i8] c"allocating pipe for child stdin redirect\00"
@.str.1 = [42 x i8] c"allocating pipe for child stdout redirect\00"
@.str.2 = [42 x i8] c"allocating pipe for child stderr redirect\00"
@STDIN_FILENO = global i32 0
@.str.3 = [18 x i8] c"redirecting stdin\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [19 x i8] c"redirecting stdout\00"
@STDERR_FILENO = global i32 0
@.str.5 = [19 x i8] c"redirecting stderr\00"
@.str.6 = [26 x i8] c"exec of the child process\00"
define i32 @createChild(i8* %0, i8** %1, i8** %2, i32* nocapture writeonly %3) {
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = bitcast [2 x i32]* %5 to i8*
%9 = bitcast [2 x i32]* %6 to i8*
%10 = bitcast [2 x i32]* %7 to i8*
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%12 = call i64 @pipe(i32* %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %115
16: ; preds = %4
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%18 = call i64 @pipe(i32* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32, i32* %11
%22 = call i32 @close(i32 %21)
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%24 = load i32, i32* %23
%25 = call i32 @close(i32 %24)
%26 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %115
27: ; preds = %16
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%29 = call i64 @pipe(i32* %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %27
%32 = load i32, i32* %11
%33 = call i32 @close(i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%35 = load i32, i32* %34
%36 = call i32 @close(i32 %35)
%37 = load i32, i32* %17
%38 = call i32 @close(i32 %37)
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @close(i32 %40)
%42 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %115
43: ; preds = %27
%44 = call i32 (...) @fork()
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %86
46: ; preds = %43
%47 = load i32, i32* %11
%48 = load i32, i32* @STDIN_FILENO
%49 = call i32 @dup2(i32 %47, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %115
53: ; preds = %46
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%55 = load i32, i32* %54
%56 = load i32, i32* @STDOUT_FILENO
%57 = call i32 @dup2(i32 %55, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %115
61: ; preds = %53
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%63 = load i32, i32* %62
%64 = load i32, i32* @STDERR_FILENO
%65 = call i32 @dup2(i32 %63, i32 %64)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %115
69: ; preds = %61
%70 = load i32, i32* %11
%71 = call i32 @close(i32 %70)
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%73 = load i32, i32* %72
%74 = call i32 @close(i32 %73)
%75 = load i32, i32* %17
%76 = call i32 @close(i32 %75)
%77 = load i32, i32* %54
%78 = call i32 @close(i32 %77)
%79 = load i32, i32* %28
%80 = call i32 @close(i32 %79)
%81 = load i32, i32* %62
%82 = call i32 @close(i32 %81)
%83 = call i32 @execve(i8* %0, i8** %1, i8** %2)
%84 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%85 = call i32 @exit(i32 %83)
unreachable
86: ; preds = %43
%87 = icmp sgt i32 %44, 0
%88 = load i32, i32* %11
%89 = call i32 @close(i32 %88)
br i1 %87, label %90, label %93
90: ; preds = %86
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%92 = load i32, i32* %91
br label %103
93: ; preds = %86
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%95 = load i32, i32* %94
%96 = call i32 @close(i32 %95)
%97 = load i32, i32* %17
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%100 = load i32, i32* %99
%101 = call i32 @close(i32 %100)
%102 = load i32, i32* %28
br label %103
103: ; preds = %90, %93
%104 = phi i32 [ %92, %90 ], [ %102, %93 ]
%105 = call i32 @close(i32 %104)
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%110 = load i32, i32* %109
store i32 %110, i32* %3
%111 = load i32, i32* %17
%112 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %111, i32* %112
%113 = load i32, i32* %28
%114 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %113, i32* %114
br label %115
115: ; preds = %103, %67, %59, %51, %31, %20, %14
%116 = phi i32 [ -1, %14 ], [ -1, %20 ], [ -1, %31 ], [ -1, %51 ], [ -1, %59 ], [ -1, %67 ], [ %44, %103 ]
ret i32 %116
}