#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ SHUT_RD;
int /*<<< orphan*/ SHUT_WR;
int SOCK_CLOEXEC;
int SOCK_STREAM;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int errno;
int /*<<< orphan*/ execv(char const *, char **);
int /*<<< orphan*/ execve(char const *, char **, char **);
int /*<<< orphan*/ execvp(char const *, char **);
int /*<<< orphan*/ execvpe(char const *, char **, char **);
int /*<<< orphan*/ *fdopen(int, char const *);
int fork();
int /*<<< orphan*/ interpret_mode(char const *, int *, int *, int *);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socketpair(int /*<<< orphan*/, int, int /*<<< orphan*/, int *);
int popen2_impl(FILE **in_and_or_out, const char *program,
                const char *const argv[], const char *const envp[],
                int lookup_path, const char *mode) {
  int in, out, close_on_exec;
  interpret_mode(mode, &in, &out, &close_on_exec);
  int socket_type_and_flags = SOCK_STREAM;
  if (close_on_exec) {
    socket_type_and_flags |= SOCK_CLOEXEC;
  }
  int sv[2] = {-1, -1};
  int ret = socketpair(AF_UNIX, socket_type_and_flags, 0, sv);
  if (ret == -1)
    return -1;
  if (!in) {
    shutdown(sv[0], SHUT_RD);
    shutdown(sv[1], SHUT_WR);
  }
  if (!out) {
    shutdown(sv[0], SHUT_WR);
    shutdown(sv[1], SHUT_RD);
  }
  if (in_and_or_out) {
    *in_and_or_out = fdopen(sv[0], mode);
  }
  if (in_and_or_out && !*in_and_or_out) {
    int saved_errno = errno;
    close(sv[0]);
    close(sv[1]);
    errno = saved_errno;
    return -1;
  }
  int childpid = fork();
  if (!childpid) {
    close(sv[0]);
    if (in) {
      dup2(sv[1], 1);
    }
    if (out) {
      dup2(sv[1], 0);
    }
    if ((in && (sv[1] == 1)) || (out && (sv[1] == 0))) {
    } else {
      close(sv[1]);
    }
    if (lookup_path) {
      if (envp) {
        execvpe(program, (char **)argv, (char **)envp);
      } else {
        execvp(program, (char **)argv);
      }
    } else {
      if (envp) {
        execve(program, (char **)argv, (char **)envp);
      } else {
        execv(program, (char **)argv);
      }
    }
    _exit(ENOSYS);
  }
  close(sv[1]);
  return childpid;
}


x86 assembly (clang, -O0):
<popen2_impl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rcx
call   10a0 <interpret_mode@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     121a <popen2_impl+0x5a>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
or     -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0xddf(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%esi
lea    -0x50(%rbp),%rcx
xor    %edx,%edx
call   1090 <socketpair@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    1255 <popen2_impl+0x95>
movl   $0xffffffff,-0x4(%rbp)
jmp    1423 <popen2_impl+0x263>
cmpl   $0x0,-0x3c(%rbp)
jne    1281 <popen2_impl+0xc1>
mov    -0x50(%rbp),%edi
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x4c(%rbp),%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
cmpl   $0x0,-0x40(%rbp)
jne    12ad <popen2_impl+0xed>
mov    -0x50(%rbp),%edi
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x4c(%rbp),%edi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
cmpq   $0x0,-0x10(%rbp)
je     12ce <popen2_impl+0x10e>
mov    -0x50(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   10b0 <fdopen@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     131b <popen2_impl+0x15b>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    131b <popen2_impl+0x15b>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
mov    -0x58(%rbp),%ecx
mov    0x2ca3(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1423 <popen2_impl+0x263>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jne    1415 <popen2_impl+0x255>
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x3c(%rbp)
je     134e <popen2_impl+0x18e>
mov    -0x4c(%rbp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
cmpl   $0x0,-0x40(%rbp)
je     1362 <popen2_impl+0x1a2>
mov    -0x4c(%rbp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1376 <popen2_impl+0x1b6>
cmpl   $0x1,-0x4c(%rbp)
je     138a <popen2_impl+0x1ca>
cmpl   $0x0,-0x40(%rbp)
je     138f <popen2_impl+0x1cf>
cmpl   $0x0,-0x4c(%rbp)
jne    138f <popen2_impl+0x1cf>
jmp    1397 <popen2_impl+0x1d7>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x2c(%rbp)
je     13d4 <popen2_impl+0x214>
cmpq   $0x0,-0x28(%rbp)
je     13c2 <popen2_impl+0x202>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <execvpe@plt>
jmp    13cf <popen2_impl+0x20f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <execvp@plt>
jmp    1407 <popen2_impl+0x247>
cmpq   $0x0,-0x28(%rbp)
je     13f5 <popen2_impl+0x235>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <execve@plt>
jmp    1402 <popen2_impl+0x242>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10d0 <execv@plt>
jmp    1407 <popen2_impl+0x247>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<popen2_impl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8d,%r13d
mov    %rcx,%r15
mov    %rdx,0x18(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x24(%rsp),%rcx
mov    %r9,%rdi
call   10a0 <interpret_mode@plt>
mov    0x2db8(%rip),%rax
mov    0x24(%rsp),%esi
test   %esi,%esi
je     1211 <popen2_impl+0x51>
mov    0x2de1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
movq   $0xffffffffffffffff,0x8(%rsp)
ff ff
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   1090 <socketpair@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     12f4 <popen2_impl+0x134>
cmpl   $0x0,0x14(%rsp)
je     1255 <popen2_impl+0x95>
cmpl   $0x0,0x10(%rsp)
je     1280 <popen2_impl+0xc0>
test   %rbp,%rbp
jne    12a9 <popen2_impl+0xe9>
jmp    12be <popen2_impl+0xfe>
mov    0x8(%rsp),%edi
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    0xc(%rsp),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
cmpl   $0x0,0x10(%rsp)
jne    124e <popen2_impl+0x8e>
mov    0x8(%rsp),%edi
mov    0x2d55(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    0xc(%rsp),%edi
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
test   %rbp,%rbp
je     12be <popen2_impl+0xfe>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   10b0 <fdopen@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     12d7 <popen2_impl+0x117>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1306 <popen2_impl+0x146>
mov    %eax,%r14d
mov    0xc(%rsp),%edi
call   1070 <close@plt>
jmp    12f4 <popen2_impl+0x134>
mov    0x2cd2(%rip),%rbx
mov    (%rbx),%ebp
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    %ebp,(%rbx)
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
call   1070 <close@plt>
cmpl   $0x0,0x14(%rsp)
je     1324 <popen2_impl+0x164>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
cmpl   $0x0,0x10(%rsp)
je     1336 <popen2_impl+0x176>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
cmpl   $0x0,0x14(%rsp)
mov    0xc(%rsp),%edi
je     1346 <popen2_impl+0x186>
cmp    $0x1,%edi
je     1356 <popen2_impl+0x196>
cmpl   $0x0,0x10(%rsp)
je     1351 <popen2_impl+0x191>
test   %edi,%edi
je     1356 <popen2_impl+0x196>
call   1070 <close@plt>
mov    %r12,%rdi
test   %r13d,%r13d
jne    136f <popen2_impl+0x1af>
test   %r15,%r15
jne    1380 <popen2_impl+0x1c0>
mov    0x18(%rsp),%rsi
call   10d0 <execv@plt>
jmp    139c <popen2_impl+0x1dc>
test   %r15,%r15
jne    138f <popen2_impl+0x1cf>
mov    0x18(%rsp),%rsi
call   10c0 <execvp@plt>
jmp    139c <popen2_impl+0x1dc>
mov    0x18(%rsp),%rsi
mov    %r15,%rdx
call   1080 <execve@plt>
jmp    139c <popen2_impl+0x1dc>
mov    0x18(%rsp),%rsi
mov    %r15,%rdx
call   1060 <execvpe@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@SOCK_STREAM = global i32 0
@SOCK_CLOEXEC = global i32 0
@__const.popen2_impl.sv = [2 x i32] [i32 -1, i32 -1]
@AF_UNIX = global i32 0
@SHUT_RD = global i32 0
@SHUT_WR = global i32 0
@errno = global i32 0
@ENOSYS = global i32 0
define i32 @popen2_impl(i32** %0, i8* %1, i8** %2, i8** %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [2 x i32]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32** %0, i32*** %8
store i8* %1, i8** %9
store i8** %2, i8*** %10
store i8** %3, i8*** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
%22 = load i8*, i8** %13
%23 = call i32 @interpret_mode(i8* %22, i32* %14, i32* %15, i32* %16)
%24 = load i32, i32* @SOCK_STREAM
store i32 %24, i32* %17
%25 = load i32, i32* %16
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %6
%28 = load i32, i32* @SOCK_CLOEXEC
%29 = load i32, i32* %17
%30 = or i32 %29, %28
store i32 %30, i32* %17
br label %31
31: ; preds = %27, %6
%32 = bitcast [2 x i32]* %18 to i8*
%33 = load i32, i32* @AF_UNIX
%34 = load i32, i32* %17
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%36 = call i32 @socketpair(i32 %33, i32 %34, i32 0, i32* %35)
store i32 %36, i32* %19
%37 = load i32, i32* %19
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %40
39: ; preds = %31
store i32 -1, i32* %7
br label %166
40: ; preds = %31
%41 = load i32, i32* %14
%42 = icmp ne i32 %41, 0
br i1 %42, label %52, label %43
43: ; preds = %40
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%45 = load i32, i32* %44
%46 = load i32, i32* @SHUT_RD
%47 = call i32 @shutdown(i32 %45, i32 %46)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%49 = load i32, i32* %48
%50 = load i32, i32* @SHUT_WR
%51 = call i32 @shutdown(i32 %49, i32 %50)
br label %52
52: ; preds = %43, %40
%53 = load i32, i32* %15
%54 = icmp ne i32 %53, 0
br i1 %54, label %64, label %55
55: ; preds = %52
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%57 = load i32, i32* %56
%58 = load i32, i32* @SHUT_WR
%59 = call i32 @shutdown(i32 %57, i32 %58)
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%61 = load i32, i32* %60
%62 = load i32, i32* @SHUT_RD
%63 = call i32 @shutdown(i32 %61, i32 %62)
br label %64
64: ; preds = %55, %52
%65 = load i32**, i32*** %8
%66 = icmp ne i32** %65, null
br i1 %66, label %67, label %73
67: ; preds = %64
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%69 = load i32, i32* %68
%70 = load i8*, i8** %13
%71 = call i32* @fdopen(i32 %69, i8* %70)
%72 = load i32**, i32*** %8
store i32* %71, i32** %72
br label %73
73: ; preds = %67, %64
%74 = load i32**, i32*** %8
%75 = icmp ne i32** %74, null
br i1 %75, label %76, label %89
76: ; preds = %73
%77 = load i32**, i32*** %8
%78 = load i32*, i32** %77
%79 = icmp ne i32* %78, null
br i1 %79, label %89, label %80
80: ; preds = %76
%81 = load i32, i32* @errno
store i32 %81, i32* %20
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = load i32, i32* %20
store i32 %88, i32* @errno
store i32 -1, i32* %7
br label %166
89: ; preds = %76, %73
%90 = call i32 (...) @fork()
store i32 %90, i32* %21
%91 = load i32, i32* %21
%92 = icmp ne i32 %91, 0
br i1 %92, label %161, label %93
93: ; preds = %89
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%95 = load i32, i32* %94
%96 = call i32 @close(i32 %95)
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %93
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @dup2(i32 %101, i32 1)
br label %103
103: ; preds = %99, %93
%104 = load i32, i32* %15
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %103
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%108 = load i32, i32* %107
%109 = call i32 @dup2(i32 %108, i32 0)
br label %110
110: ; preds = %106, %103
%111 = load i32, i32* %14
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %117
113: ; preds = %110
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%115 = load i32, i32* %114
%116 = icmp eq i32 %115, 1
br i1 %116, label %124, label %117
117: ; preds = %113, %110
%118 = load i32, i32* %15
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %117
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%122 = load i32, i32* %121
%123 = icmp eq i32 %122, 0
br i1 %123, label %124, label %125
124: ; preds = %120, %113
br label %129
125: ; preds = %120, %117
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%127 = load i32, i32* %126
%128 = call i32 @close(i32 %127)
br label %129
129: ; preds = %125, %124
%130 = load i32, i32* %12
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %145
132: ; preds = %129
%133 = load i8**, i8*** %11
%134 = icmp ne i8** %133, null
br i1 %134, label %135, label %140
135: ; preds = %132
%136 = load i8*, i8** %9
%137 = load i8**, i8*** %10
%138 = load i8**, i8*** %11
%139 = call i32 @execvpe(i8* %136, i8** %137, i8** %138)
br label %144
140: ; preds = %132
%141 = load i8*, i8** %9
%142 = load i8**, i8*** %10
%143 = call i32 @execvp(i8* %141, i8** %142)
br label %144
144: ; preds = %140, %135
br label %158
145: ; preds = %129
%146 = load i8**, i8*** %11
%147 = icmp ne i8** %146, null
br i1 %147, label %148, label %153
148: ; preds = %145
%149 = load i8*, i8** %9
%150 = load i8**, i8*** %10
%151 = load i8**, i8*** %11
%152 = call i32 @execve(i8* %149, i8** %150, i8** %151)
br label %157
153: ; preds = %145
%154 = load i8*, i8** %9
%155 = load i8**, i8*** %10
%156 = call i32 @execv(i8* %154, i8** %155)
br label %157
157: ; preds = %153, %148
br label %158
158: ; preds = %157, %144
%159 = load i32, i32* @ENOSYS
%160 = call i32 @_exit(i32 %159)
unreachable
161: ; preds = %89
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%163 = load i32, i32* %162
%164 = call i32 @close(i32 %163)
%165 = load i32, i32* %21
store i32 %165, i32* %7
br label %166
166: ; preds = %161, %80, %39
%167 = load i32, i32* %7
ret i32 %167
}

LLVM IR (-O2):
@SOCK_STREAM = global i32 0
@SOCK_CLOEXEC = global i32 0
@AF_UNIX = global i32 0
@SHUT_RD = global i32 0
@SHUT_WR = global i32 0
@errno = global i32 0
@ENOSYS = global i32 0
define i32 @popen2_impl(i32** %0, i8* %1, i8** %2, i8** %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = bitcast i64* %10 to [2 x i32]*
%12 = bitcast i32* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = bitcast i32* %9 to i8*
%15 = call i32 @interpret_mode(i8* %5, i32* %7, i32* %8, i32* %9)
%16 = load i32, i32* @SOCK_STREAM
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 0
%19 = load i32, i32* @SOCK_CLOEXEC
%20 = select i1 %18, i32 0, i32 %19
%21 = or i32 %20, %16
%22 = bitcast i64* %10 to i8*
store i64 -1, i64* %10
%23 = load i32, i32* @AF_UNIX
%24 = bitcast i64* %10 to i32*
%25 = call i32 @socketpair(i32 %23, i32 %21, i32 0, i32* %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %115, label %27
27: ; preds = %6
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i32, i32* %24
%32 = load i32, i32* @SHUT_RD
%33 = call i32 @shutdown(i32 %31, i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%35 = load i32, i32* %34
%36 = load i32, i32* @SHUT_WR
%37 = call i32 @shutdown(i32 %35, i32 %36)
br label %38
38: ; preds = %30, %27
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = load i32, i32* %24
%43 = load i32, i32* @SHUT_WR
%44 = call i32 @shutdown(i32 %42, i32 %43)
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%46 = load i32, i32* %45
%47 = load i32, i32* @SHUT_RD
%48 = call i32 @shutdown(i32 %46, i32 %47)
br label %49
49: ; preds = %41, %38
%50 = icmp eq i32** %0, null
br i1 %50, label %62, label %51
51: ; preds = %49
%52 = load i32, i32* %24
%53 = call i32* @fdopen(i32 %52, i8* %5)
store i32* %53, i32** %0
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = load i32, i32* @errno
%57 = load i32, i32* %24
%58 = call i32 @close(i32 %57)
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%60 = load i32, i32* %59
%61 = call i32 @close(i32 %60)
store i32 %56, i32* @errno
br label %115
62: ; preds = %49, %51
%63 = call i32 (...) @fork()
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %111
65: ; preds = %62
%66 = load i32, i32* %24
%67 = call i32 @close(i32 %66)
%68 = load i32, i32* %7
%69 = icmp eq i32 %68, 0
br i1 %69, label %74, label %70
70: ; preds = %65
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%72 = load i32, i32* %71
%73 = call i32 @dup2(i32 %72, i32 1)
br label %74
74: ; preds = %70, %65
%75 = load i32, i32* %8
%76 = icmp eq i32 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %74
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32 @dup2(i32 %79, i32 0)
br label %81
81: ; preds = %77, %74
%82 = load i32, i32* %7
%83 = icmp ne i32 %82, 0
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%85 = load i32, i32* %84
%86 = icmp eq i32 %85, 1
%87 = select i1 %83, i1 %86, i1 false
br i1 %87, label %95, label %88
88: ; preds = %81
%89 = load i32, i32* %8
%90 = icmp ne i32 %89, 0
%91 = icmp eq i32 %85, 0
%92 = select i1 %90, i1 %91, i1 false
br i1 %92, label %95, label %93
93: ; preds = %88
%94 = call i32 @close(i32 %85)
br label %95
95: ; preds = %81, %88, %93
%96 = icmp eq i32 %4, 0
%97 = icmp eq i8** %3, null
br i1 %96, label %103, label %98
98: ; preds = %95
br i1 %97, label %101, label %99
99: ; preds = %98
%100 = call i32 @execvpe(i8* %1, i8** %2, i8** %3)
br label %108
101: ; preds = %98
%102 = call i32 @execvp(i8* %1, i8** %2)
br label %108
103: ; preds = %95
br i1 %97, label %106, label %104
104: ; preds = %103
%105 = call i32 @execve(i8* %1, i8** %2, i8** %3)
br label %108
106: ; preds = %103
%107 = call i32 @execv(i8* %1, i8** %2)
br label %108
108: ; preds = %104, %106, %99, %101
%109 = load i32, i32* @ENOSYS
%110 = call i32 @_exit(i32 %109)
unreachable
111: ; preds = %62
%112 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%113 = load i32, i32* %112
%114 = call i32 @close(i32 %113)
br label %115
115: ; preds = %6, %111, %55
%116 = phi i32 [ %63, %111 ], [ -1, %55 ], [ -1, %6 ]
ret i32 %116
}