#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 */
struct output {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ add_output(struct output *, char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ dup2(int, int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ output_errno(struct output *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ waitpid(int, int *, int /*<<< orphan*/);
int do_exec(char **args, int need_zero, struct output *output) {
  int pid, status, fds[2], n;
  char buf[256], **arg;
  if (output) {
    add_output(output, "*", -1);
    for (arg = args; *arg; arg++) {
      add_output(output, " ", -1);
      add_output(output, *arg, -1);
    }
    add_output(output, "\n", -1);
    if (pipe(fds) < 0) {
      perror("Creating pipe");
      output = NULL;
    }
  }
  if ((pid = fork()) == 0) {
    if (output) {
      close(fds[0]);
      if ((dup2(fds[1], 1) < 0) || (dup2(fds[1], 2) < 0))
        perror("dup2");
    }
    execvp(args[0], args);
    fprintf(stderr, "Failed to exec '%s'", args[0]);
    perror("");
    exit(1);
  } else if (pid < 0) {
    output_errno(output, "fork failed");
    return (-1);
  }
  if (output) {
    close(fds[1]);
    while ((n = read(fds[0], buf, sizeof(buf))) > 0)
      add_output(output, buf, n);
    if (n < 0)
      output_errno(output, "Reading command output");
  }
  if (waitpid(pid, &status, 0) < 0) {
    output_errno(output, "waitpid");
    return (-1);
  }
  if (need_zero && (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))) {
    sprintf(buf, "'%s' didn't exit with status 0\n", args[0]);
    add_output(output, buf, -1);
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<do_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12c7 <do_exec+0xd7>
mov    -0x20(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x148(%rbp),%rax
cmpq   $0x0,(%rax)
je     1286 <do_exec+0x96>
mov    -0x20(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
mov    -0x20(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    (%rax),%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
mov    -0x148(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x148(%rbp)
jmp    1231 <do_exec+0x41>
mov    -0x20(%rbp),%rdi
lea    0xde3(%rip),%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
lea    -0x30(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
jge    12c2 <do_exec+0xd2>
lea    0xd4f(%rip),%rdi
call   10b0 <perror@plt>
movq   $0x0,-0x20(%rbp)
jmp    12c7 <do_exec+0xd7>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    136e <do_exec+0x17e>
cmpq   $0x0,-0x20(%rbp)
je     132c <do_exec+0x13c>
mov    -0x30(%rbp),%edi
call   1050 <close@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
cmp    $0x0,%rax
jl     131b <do_exec+0x12b>
mov    -0x2c(%rbp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
cmp    $0x0,%rax
jge    1327 <do_exec+0x137>
lea    0xcf0(%rip),%rdi
call   10b0 <perror@plt>
jmp    132c <do_exec+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   10c0 <execvp@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcc4(%rip),%rsi
call   1080 <fprintf@plt>
lea    0xd16(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jge    1394 <do_exec+0x1a4>
mov    -0x20(%rbp),%rdi
lea    0xca8(%rip),%rsi
call   1030 <output_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a6 <do_exec+0x2b6>
jmp    1399 <do_exec+0x1a9>
cmpq   $0x0,-0x20(%rbp)
je     1403 <do_exec+0x213>
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
mov    -0x30(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0x100,%edx
call   1070 <read@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jle    13e4 <do_exec+0x1f4>
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   10d0 <add_output@plt>
jmp    13ac <do_exec+0x1bc>
cmpl   $0x0,-0x34(%rbp)
jge    13fe <do_exec+0x20e>
mov    -0x20(%rbp),%rdi
lea    0xc3e(%rip),%rsi
call   1030 <output_errno@plt>
jmp    1403 <do_exec+0x213>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
cmp    $0x0,%rax
jge    1437 <do_exec+0x247>
mov    -0x20(%rbp),%rdi
lea    0xc28(%rip),%rsi
call   1030 <output_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a6 <do_exec+0x2b6>
cmpl   $0x0,-0x14(%rbp)
je     149f <do_exec+0x2af>
mov    -0x28(%rbp),%edi
call   10e0 <WIFEXITED@plt>
cmp    $0x0,%eax
je     1464 <do_exec+0x274>
mov    -0x28(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     149f <do_exec+0x2af>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbdd(%rip),%rsi
call   10f0 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a6 <do_exec+0x2b6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_exec>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
test   %rdx,%rdx
je     129b <do_exec+0xab>
mov    %rdx,%rbx
lea    0xde8(%rip),%rsi
mov    %rdx,%rdi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
cmpq   $0x0,(%r14)
je     126c <do_exec+0x7c>
lea    0x8(%r14),%rbp
lea    0xdcc(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
mov    -0x8(%rbp),%rsi
mov    %rbx,%rdi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
cmpq   $0x0,0x0(%rbp)
lea    0x8(%rbp),%rbp
jne    1240 <do_exec+0x50>
lea    0xe01(%rip),%rsi
mov    %rbx,%rdi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
lea    0x4(%rsp),%rdi
call   1060 <pipe@plt>
test   %rax,%rax
jns    129d <do_exec+0xad>
lea    0xd6e(%rip),%rdi
call   10b0 <perror@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     13a8 <do_exec+0x1b8>
js     1379 <do_exec+0x189>
mov    %eax,%r12d
test   %rbx,%rbx
je     1315 <do_exec+0x125>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
mov    0x4(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    1302 <do_exec+0x112>
lea    0x10(%rsp),%rbp
nop
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   10d0 <add_output@plt>
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
jg     12e0 <do_exec+0xf0>
test   %eax,%eax
jns    1315 <do_exec+0x125>
lea    0xd2a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <output_errno@plt>
lea    0xc(%rsp),%rsi
xor    %ebp,%ebp
mov    %r12d,%edi
xor    %edx,%edx
call   10a0 <waitpid@plt>
test   %rax,%rax
js     1382 <do_exec+0x192>
test   %r15d,%r15d
je     1396 <do_exec+0x1a6>
mov    0xc(%rsp),%edi
call   10e0 <WIFEXITED@plt>
test   %eax,%eax
je     134b <do_exec+0x15b>
mov    0xc(%rsp),%edi
call   1090 <WEXITSTATUS@plt>
test   %rax,%rax
je     1396 <do_exec+0x1a6>
mov    (%r14),%rdx
lea    0xd01(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   10f0 <sprintf@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xffffffff,%edx
call   10d0 <add_output@plt>
jmp    1396 <do_exec+0x1a6>
lea    0xcab(%rip),%rsi
jmp    1389 <do_exec+0x199>
lea    0xcc5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <output_errno@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
test   %rbx,%rbx
je     13e8 <do_exec+0x1f8>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
mov    0x8(%rsp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
test   %rax,%rax
js     13dc <do_exec+0x1ec>
mov    0x8(%rsp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
test   %rax,%rax
jns    13e8 <do_exec+0x1f8>
lea    0xc2f(%rip),%rdi
call   10b0 <perror@plt>
mov    (%r14),%rdi
mov    %r14,%rsi
call   10c0 <execvp@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc11(%rip),%rsi
call   1080 <fprintf@plt>
lea    0xc63(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.output = type { i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [14 x i8] c"Creating pipe\00"
@.str.4 = [5 x i8] c"dup2\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Failed to exec '%s'\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"fork failed\00"
@.str.8 = [23 x i8] c"Reading command output\00"
@.str.9 = [8 x i8] c"waitpid\00"
@.str.10 = [32 x i8] c"'%s' didn't exit with status 0\0A\00"
define i32 @do_exec(i8** %0, i32 %1, %struct.output* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.output*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x i32]
%11 = alloca i32
%12 = alloca [256 x i8]
%13 = alloca i8**
store i8** %0, i8*** %5
store i32 %1, i32* %6
store %struct.output* %2, %struct.output** %7
%14 = load %struct.output*, %struct.output** %7
%15 = icmp ne %struct.output* %14, null
br i1 %15, label %16, label %43
16: ; preds = %3
%17 = load %struct.output*, %struct.output** %7
%18 = call i32 @add_output(%struct.output* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 -1)
%19 = load i8**, i8*** %5
store i8** %19, i8*** %13
br label %20
20: ; preds = %31, %16
%21 = load i8**, i8*** %13
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load %struct.output*, %struct.output** %7
%26 = call i32 @add_output(%struct.output* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 -1)
%27 = load %struct.output*, %struct.output** %7
%28 = load i8**, i8*** %13
%29 = load i8*, i8** %28
%30 = call i32 @add_output(%struct.output* %27, i8* %29, i32 -1)
br label %31
31: ; preds = %24
%32 = load i8**, i8*** %13
%33 = getelementptr inbounds i8*, i8** %32, i32 1
store i8** %33, i8*** %13
br label %20
34: ; preds = %20
%35 = load %struct.output*, %struct.output** %7
%36 = call i32 @add_output(%struct.output* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%38 = call i64 @pipe(i32* %37)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store %struct.output* null, %struct.output** %7
br label %42
42: ; preds = %40, %34
br label %43
43: ; preds = %42, %3
%44 = call i32 (...) @fork()
store i32 %44, i32* %8
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %78
46: ; preds = %43
%47 = load %struct.output*, %struct.output** %7
%48 = icmp ne %struct.output* %47, null
br i1 %48, label %49, label %65
49: ; preds = %46
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i32 @close(i32 %51)
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%54 = load i32, i32* %53
%55 = call i64 @dup2(i32 %54, i32 1)
%56 = icmp slt i64 %55, 0
br i1 %56, label %62, label %57
57: ; preds = %49
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%59 = load i32, i32* %58
%60 = call i64 @dup2(i32 %59, i32 2)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %57, %49
%63 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %62, %57
br label %65
65: ; preds = %64, %46
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = load i8**, i8*** %5
%70 = call i32 @execvp(i8* %68, i8** %69)
%71 = load i32, i32* @stderr
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 0
%74 = load i8*, i8** %73
%75 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %74)
%76 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %43
%79 = load i32, i32* %8
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = load %struct.output*, %struct.output** %7
%83 = call i32 @output_errno(%struct.output* %82, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %4
br label %138
84: ; preds = %78
br label %85
85: ; preds = %84
%86 = load %struct.output*, %struct.output** %7
%87 = icmp ne %struct.output* %86, null
br i1 %87, label %88, label %110
88: ; preds = %85
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%90 = load i32, i32* %89
%91 = call i32 @close(i32 %90)
br label %92
92: ; preds = %98, %88
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%94 = load i32, i32* %93
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%96 = call i32 @read(i32 %94, i8* %95, i32 256)
store i32 %96, i32* %11
%97 = icmp sgt i32 %96, 0
br i1 %97, label %98, label %103
98: ; preds = %92
%99 = load %struct.output*, %struct.output** %7
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%101 = load i32, i32* %11
%102 = call i32 @add_output(%struct.output* %99, i8* %100, i32 %101)
br label %92
103: ; preds = %92
%104 = load i32, i32* %11
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %103
%107 = load %struct.output*, %struct.output** %7
%108 = call i32 @output_errno(%struct.output* %107, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %109
109: ; preds = %106, %103
br label %110
110: ; preds = %109, %85
%111 = load i32, i32* %8
%112 = call i64 @waitpid(i32 %111, i32* %9, i32 0)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load %struct.output*, %struct.output** %7
%116 = call i32 @output_errno(%struct.output* %115, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %4
br label %138
117: ; preds = %110
%118 = load i32, i32* %6
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %137
120: ; preds = %117
%121 = load i32, i32* %9
%122 = call i32 @WIFEXITED(i32 %121)
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %128
124: ; preds = %120
%125 = load i32, i32* %9
%126 = call i64 @WEXITSTATUS(i32 %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %137
128: ; preds = %124, %120
%129 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 0
%132 = load i8*, i8** %131
%133 = call i32 @sprintf(i8* %129, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %132)
%134 = load %struct.output*, %struct.output** %7
%135 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%136 = call i32 @add_output(%struct.output* %134, i8* %135, i32 -1)
store i32 -1, i32* %4
br label %138
137: ; preds = %124, %117
store i32 0, i32* %4
br label %138
138: ; preds = %137, %128, %114, %81
%139 = load i32, i32* %4
ret i32 %139
}

LLVM IR (-O2):
%struct.output = type { i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [14 x i8] c"Creating pipe\00"
@.str.4 = [5 x i8] c"dup2\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Failed to exec '%s'\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"fork failed\00"
@.str.8 = [23 x i8] c"Reading command output\00"
@.str.9 = [8 x i8] c"waitpid\00"
@.str.10 = [32 x i8] c"'%s' didn't exit with status 0\0A\00"
define i32 @do_exec(i8** %0, i32 %1, %struct.output* %2) {
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca [256 x i8]
%7 = bitcast i32* %4 to i8*
%8 = bitcast [2 x i32]* %5 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = icmp eq %struct.output* %2, null
br i1 %10, label %30, label %11
11: ; preds = %3
%12 = tail call i32 @add_output(%struct.output* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 -1)
%13 = load i8*, i8** %0
%14 = icmp eq i8* %13, null
br i1 %14, label %23, label %15
15: ; preds = %11, %15
%16 = phi i8** [ %20, %15 ], [ %0, %11 ]
%17 = tail call i32 @add_output(%struct.output* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 -1)
%18 = load i8*, i8** %16
%19 = tail call i32 @add_output(%struct.output* %2, i8* %18, i32 -1)
%20 = getelementptr inbounds i8*, i8** %16, i64 1
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %15
23: ; preds = %15, %11
%24 = tail call i32 @add_output(%struct.output* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%26 = call i64 @pipe(i32* %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %23, %28, %3
%31 = phi %struct.output* [ null, %28 ], [ %2, %23 ], [ null, %3 ]
%32 = call i32 (...) @fork()
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %58
34: ; preds = %30
%35 = icmp eq %struct.output* %31, null
br i1 %35, label %50, label %36
36: ; preds = %34
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%38 = load i32, i32* %37
%39 = call i32 @close(i32 %38)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i64 @dup2(i32 %41, i32 1)
%43 = icmp slt i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %36
%45 = load i32, i32* %40
%46 = call i64 @dup2(i32 %45, i32 2)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44, %36
%49 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %44, %48, %34
%51 = load i8*, i8** %0
%52 = call i32 @execvp(i8* %51, i8** %0)
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %0
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %30
%59 = icmp slt i32 %32, 0
br i1 %59, label %60, label %62
60: ; preds = %58
%61 = call i32 @output_errno(%struct.output* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %102
62: ; preds = %58
%63 = icmp eq %struct.output* %31, null
br i1 %63, label %83, label %64
64: ; preds = %62
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%66 = load i32, i32* %65
%67 = call i32 @close(i32 %66)
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%69 = load i32, i32* %68
%70 = call i32 @read(i32 %69, i8* %9, i32 256)
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %64, %72
%73 = phi i32 [ %76, %72 ], [ %70, %64 ]
%74 = call i32 @add_output(%struct.output* %31, i8* %9, i32 %73)
%75 = load i32, i32* %68
%76 = call i32 @read(i32 %75, i8* %9, i32 256)
%77 = icmp sgt i32 %76, 0
br i1 %77, label %72, label %78
78: ; preds = %72, %64
%79 = phi i32 [ %70, %64 ], [ %76, %72 ]
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @output_errno(%struct.output* %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %83
83: ; preds = %78, %81, %62
%84 = call i64 @waitpid(i32 %32, i32* %4, i32 0)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = call i32 @output_errno(%struct.output* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %102
88: ; preds = %83
%89 = icmp eq i32 %1, 0
br i1 %89, label %102, label %90
90: ; preds = %88
%91 = load i32, i32* %4
%92 = call i32 @WIFEXITED(i32 %91)
%93 = icmp eq i32 %92, 0
br i1 %93, label %98, label %94
94: ; preds = %90
%95 = load i32, i32* %4
%96 = call i64 @WEXITSTATUS(i32 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %102, label %98
98: ; preds = %94, %90
%99 = load i8*, i8** %0
%100 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %99)
%101 = call i32 @add_output(%struct.output* %31, i8* %9, i32 -1)
br label %102
102: ; preds = %88, %94, %98, %86, %60
%103 = phi i32 [ -1, %60 ], [ -1, %86 ], [ -1, %98 ], [ 0, %94 ], [ 0, %88 ]
ret i32 %103
}