#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 FD_CLOEXEC;
int /*<<< orphan*/ F_GETFD;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFD;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ errno;
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
scalar_t__ pipe(int *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int normal_setup(const char *pProgram, int uUp, int dDown, int *cClientIn,
                 int *cClientOut, int *fFarIn, int *fFarOut) {
  if (!cClientIn || !cClientOut || !fFarIn || !fFarOut) {
    fprintf(stderr, "%s: internal error\n", pProgram);
    return -1;
  }
  int from_client[2] = {-1, -1};
  int from_far[2] = {-1, -1};
  if (uUp && pipe(from_client) < 0) {
    fprintf(stderr, "%s: could not create pipes: %s\n", pProgram,
            strerror(errno));
    return -1;
  }
  if (dDown && pipe(from_far) < 0) {
    fprintf(stderr, "%s: could not create pipes: %s\n", pProgram,
            strerror(errno));
    return -1;
  }
  if (dDown)
    *fFarIn = dup((3 + 32));
  if (uUp)
    *fFarOut = dup((4 + 32));
  if ((dDown && *fFarIn < 0) || (uUp && *fFarOut < 0)) {
    fprintf(stderr, "%s: could not duplicate descriptors\n", pProgram);
    return -1;
  }
  if (dDown) {
    fcntl(from_far[0], F_SETFL, fcntl((3 + 32), F_GETFL));
    dup2(from_far[0], (3 + 32));
    *cClientOut = from_far[1];
    close(from_far[0]);
  }
  if (uUp) {
    fcntl(from_client[1], F_SETFL, fcntl((4 + 32), F_GETFL));
    dup2(from_client[1], (4 + 32));
    *cClientIn = from_client[0];
    close(from_client[1]);
  }
  if (uUp)
    fcntl(*cClientIn, F_SETFD, fcntl(*cClientIn, F_GETFD) | FD_CLOEXEC);
  if (dDown)
    fcntl(*cClientOut, F_SETFD, fcntl(*cClientOut, F_GETFD) | FD_CLOEXEC);
  if (dDown)
    fcntl(*fFarIn, F_SETFD, fcntl(*fFarIn, F_GETFD) | FD_CLOEXEC);
  if (uUp)
    fcntl(*fFarOut, F_SETFD, fcntl(*fFarOut, F_GETFD) | FD_CLOEXEC);
  if (dDown)
    fcntl(*fFarIn, F_SETFL, fcntl(*fFarIn, F_GETFL) | O_NONBLOCK);
  if (uUp)
    fcntl(*cClientIn, F_SETFL, fcntl(*cClientIn, F_GETFL) | O_NONBLOCK);
  return 0;
}


x86 assembly (clang, -O0):
<normal_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c1 <normal_setup+0x51>
cmpq   $0x0,-0x28(%rbp)
je     11c1 <normal_setup+0x51>
cmpq   $0x0,-0x30(%rbp)
je     11c1 <normal_setup+0x51>
cmpq   $0x0,0x10(%rbp)
jne    11e8 <normal_setup+0x78>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160c <normal_setup+0x49c>
mov    0xe6d(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe62(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1261 <normal_setup+0xf1>
lea    -0x38(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    1261 <normal_setup+0xf1>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160c <normal_setup+0x49c>
cmpl   $0x0,-0x18(%rbp)
je     12c4 <normal_setup+0x154>
lea    -0x40(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    12c4 <normal_setup+0x154>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160c <normal_setup+0x49c>
cmpl   $0x0,-0x18(%rbp)
je     12e0 <normal_setup+0x170>
mov    $0x23,%edi
call   1050 <dup@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x14(%rbp)
je     12fc <normal_setup+0x18c>
mov    $0x24,%edi
call   1050 <dup@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x18(%rbp)
je     1313 <normal_setup+0x1a3>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jl     132a <normal_setup+0x1ba>
cmpl   $0x0,-0x14(%rbp)
je     1351 <normal_setup+0x1e1>
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1351 <normal_setup+0x1e1>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160c <normal_setup+0x49c>
cmpl   $0x0,-0x18(%rbp)
je     13af <normal_setup+0x23f>
mov    -0x40(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    0x2c60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2c34(%rip),%rax
mov    (%rax),%esi
mov    $0x23,%edi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x40(%rbp),%edi
mov    $0x23,%esi
call   1040 <dup2@plt>
mov    -0x3c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x14(%rbp)
je     140d <normal_setup+0x29d>
mov    -0x34(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2c02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2bd6(%rip),%rax
mov    (%rax),%esi
mov    $0x24,%edi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x34(%rbp),%edi
mov    $0x24,%esi
call   1040 <dup2@plt>
mov    -0x38(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x14(%rbp)
je     145a <normal_setup+0x2ea>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2ba9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    0x2b77(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%esi
mov    %eax,%edx
mov    0x2b6f(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmpl   $0x0,-0x18(%rbp)
je     14a7 <normal_setup+0x337>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2b5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    0x2b2a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%esi
mov    %eax,%edx
mov    0x2b22(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmpl   $0x0,-0x18(%rbp)
je     14fa <normal_setup+0x38a>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    0x2b0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
mov    0x2ada(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%esi
mov    %eax,%edx
mov    0x2acf(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmpl   $0x0,-0x14(%rbp)
je     1553 <normal_setup+0x3e3>
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    0x2ab9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x88(%rbp)
mov    0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2a84(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%esi
mov    %eax,%edx
mov    0x2a76(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmpl   $0x0,-0x18(%rbp)
je     15ac <normal_setup+0x43c>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    0x2a58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
mov    0x2a23(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%esi
mov    %eax,%edx
mov    0x2a45(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmpl   $0x0,-0x14(%rbp)
je     1605 <normal_setup+0x495>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    0x29ff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    0x29ca(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%esi
mov    %eax,%edx
mov    0x29ec(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normal_setup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
test   %rcx,%rcx
je     1455 <normal_setup+0x2e5>
mov    %r8,%rbp
test   %r8,%r8
je     1455 <normal_setup+0x2e5>
mov    %r9,%r13
test   %r9,%r9
je     1455 <normal_setup+0x2e5>
cmpq   $0x0,0x50(%rsp)
je     1455 <normal_setup+0x2e5>
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movq   $0xffffffffffffffff,0x8(%rsp)
ff ff
test   %esi,%esi
je     11e0 <normal_setup+0x70>
lea    0x10(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     1476 <normal_setup+0x306>
test   %r15d,%r15d
je     1206 <normal_setup+0x96>
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     1476 <normal_setup+0x306>
mov    $0x23,%edi
call   1050 <dup@plt>
mov    %eax,0x0(%r13)
test   %r12d,%r12d
je     121c <normal_setup+0xac>
mov    $0x24,%edi
call   1050 <dup@plt>
mov    0x50(%rsp),%rcx
mov    %eax,(%rcx)
test   %r15d,%r15d
je     122c <normal_setup+0xbc>
cmpl   $0x0,0x0(%r13)
js     14aa <normal_setup+0x33a>
test   %r12d,%r12d
je     123f <normal_setup+0xcf>
mov    0x50(%rsp),%rax
cmpl   $0x0,(%rax)
js     14aa <normal_setup+0x33a>
test   %r15d,%r15d
je     1297 <normal_setup+0x127>
mov    0x8(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x2d75(%rip),%rax
mov    (%rax),%ebx
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
mov    $0x23,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x4(%rsp),%edi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x8(%rsp),%edi
mov    $0x23,%esi
call   1040 <dup2@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x0(%rbp)
mov    0x8(%rsp),%edi
call   1060 <close@plt>
test   %r12d,%r12d
je     132d <normal_setup+0x1bd>
mov    0x14(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x2d19(%rip),%rax
mov    (%rax),%ebx
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
mov    $0x24,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x4(%rsp),%edi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x14(%rsp),%edi
mov    $0x24,%esi
call   1040 <dup2@plt>
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    (%r14),%ebx
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2ca4(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    0x4(%rsp),%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %r15d,%r15d
je     139b <normal_setup+0x22b>
mov    0x0(%rbp),%ebx
mov    0x2c94(%rip),%rax
mov    (%rax),%ebp
mov    0x2c6b(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2c69(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x0(%r13),%ebx
mov    0x2c5f(%rip),%rax
mov    (%rax),%ebp
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2c34(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %r12d,%r12d
je     13d8 <normal_setup+0x268>
mov    0x50(%rsp),%rax
mov    (%rax),%ebx
mov    0x2c22(%rip),%rax
mov    (%rax),%ebp
mov    0x2bf9(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2bf7(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %r15d,%r15d
je     1412 <normal_setup+0x2a2>
mov    0x0(%r13),%ebx
mov    0x2be0(%rip),%rax
mov    (%rax),%ebp
mov    0x2bb7(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2be5(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %r12d,%r12d
je     14bc <normal_setup+0x34c>
mov    (%r14),%ebp
mov    0x2ba3(%rip),%rax
mov    (%rax),%r14d
mov    0x2b79(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2ba5(%rip),%rcx
or     (%rcx),%eax
mov    %ebp,%edi
mov    %r14d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
jmp    14be <normal_setup+0x34e>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
lea    0xb9b(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    14be <normal_setup+0x34e>
mov    0x2b5b(%rip),%rax
mov    (%rax),%ebp
mov    0x2b32(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xb80(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    14be <normal_setup+0x34e>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
lea    0xb7a(%rip),%rsi
jmp    1465 <normal_setup+0x2f5>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"%s: internal error\0A\00"
@__const.normal_setup.from_client = [2 x i32] [i32 -1, i32 -1]
@__const.normal_setup.from_far = [2 x i32] [i32 -1, i32 -1]
@.str.1 = [32 x i8] c"%s: could not create pipes: %s\0A\00"
@errno = global i32 0
@.str.2 = [37 x i8] c"%s: could not duplicate descriptors\0A\00"
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@F_SETFD = global i32 0
@F_GETFD = global i32 0
@FD_CLOEXEC = global i32 0
@O_NONBLOCK = global i32 0
define i32 @normal_setup(i8* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca [2 x i32]
%17 = alloca [2 x i32]
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
%18 = load i32*, i32** %12
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %29
20: ; preds = %7
%21 = load i32*, i32** %13
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32*, i32** %14
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32*, i32** %15
%28 = icmp ne i32* %27, null
br i1 %28, label %33, label %29
29: ; preds = %26, %23, %20, %7
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %9
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %31)
store i32 -1, i32* %8
br label %214
33: ; preds = %26
%34 = bitcast [2 x i32]* %16 to i8*
%35 = bitcast [2 x i32]* %17 to i8*
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %48
38: ; preds = %33
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%40 = call i64 @pipe(i32* %39)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %9
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %44, i8* %46)
store i32 -1, i32* %8
br label %214
48: ; preds = %38, %33
%49 = load i32, i32* %11
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %61
51: ; preds = %48
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%53 = call i64 @pipe(i32* %52)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %9
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %57, i8* %59)
store i32 -1, i32* %8
br label %214
61: ; preds = %51, %48
%62 = load i32, i32* %11
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = call i32 @dup(i32 35)
%66 = load i32*, i32** %14
store i32 %65, i32* %66
br label %67
67: ; preds = %64, %61
%68 = load i32, i32* %10
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = call i32 @dup(i32 36)
%72 = load i32*, i32** %15
store i32 %71, i32* %72
br label %73
73: ; preds = %70, %67
%74 = load i32, i32* %11
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i32*, i32** %14
%78 = load i32, i32* %77
%79 = icmp slt i32 %78, 0
br i1 %79, label %87, label %80
80: ; preds = %76, %73
%81 = load i32, i32* %10
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %91
83: ; preds = %80
%84 = load i32*, i32** %15
%85 = load i32, i32* %84
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %83, %76
%88 = load i32, i32* @stderr
%89 = load i8*, i8** %9
%90 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %89)
store i32 -1, i32* %8
br label %214
91: ; preds = %83, %80
%92 = load i32, i32* %11
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %110
94: ; preds = %91
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%96 = load i32, i32* %95
%97 = load i32, i32* @F_SETFL
%98 = load i32, i32* @F_GETFL
%99 = call i32 (i32, i32, ...) @fcntl(i32 35, i32 %98)
%100 = call i32 (i32, i32, ...) @fcntl(i32 %96, i32 %97, i32 %99)
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%102 = load i32, i32* %101
%103 = call i32 @dup2(i32 %102, i32 35)
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%105 = load i32, i32* %104
%106 = load i32*, i32** %13
store i32 %105, i32* %106
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%108 = load i32, i32* %107
%109 = call i32 @close(i32 %108)
br label %110
110: ; preds = %94, %91
%111 = load i32, i32* %10
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %129
113: ; preds = %110
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%115 = load i32, i32* %114
%116 = load i32, i32* @F_SETFL
%117 = load i32, i32* @F_GETFL
%118 = call i32 (i32, i32, ...) @fcntl(i32 36, i32 %117)
%119 = call i32 (i32, i32, ...) @fcntl(i32 %115, i32 %116, i32 %118)
%120 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%121 = load i32, i32* %120
%122 = call i32 @dup2(i32 %121, i32 36)
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%124 = load i32, i32* %123
%125 = load i32*, i32** %12
store i32 %124, i32* %125
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%127 = load i32, i32* %126
%128 = call i32 @close(i32 %127)
br label %129
129: ; preds = %113, %110
%130 = load i32, i32* %10
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %143
132: ; preds = %129
%133 = load i32*, i32** %12
%134 = load i32, i32* %133
%135 = load i32, i32* @F_SETFD
%136 = load i32*, i32** %12
%137 = load i32, i32* %136
%138 = load i32, i32* @F_GETFD
%139 = call i32 (i32, i32, ...) @fcntl(i32 %137, i32 %138)
%140 = load i32, i32* @FD_CLOEXEC
%141 = or i32 %139, %140
%142 = call i32 (i32, i32, ...) @fcntl(i32 %134, i32 %135, i32 %141)
br label %143
143: ; preds = %132, %129
%144 = load i32, i32* %11
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %157
146: ; preds = %143
%147 = load i32*, i32** %13
%148 = load i32, i32* %147
%149 = load i32, i32* @F_SETFD
%150 = load i32*, i32** %13
%151 = load i32, i32* %150
%152 = load i32, i32* @F_GETFD
%153 = call i32 (i32, i32, ...) @fcntl(i32 %151, i32 %152)
%154 = load i32, i32* @FD_CLOEXEC
%155 = or i32 %153, %154
%156 = call i32 (i32, i32, ...) @fcntl(i32 %148, i32 %149, i32 %155)
br label %157
157: ; preds = %146, %143
%158 = load i32, i32* %11
%159 = icmp ne i32 %158, 0
br i1 %159, label %160, label %171
160: ; preds = %157
%161 = load i32*, i32** %14
%162 = load i32, i32* %161
%163 = load i32, i32* @F_SETFD
%164 = load i32*, i32** %14
%165 = load i32, i32* %164
%166 = load i32, i32* @F_GETFD
%167 = call i32 (i32, i32, ...) @fcntl(i32 %165, i32 %166)
%168 = load i32, i32* @FD_CLOEXEC
%169 = or i32 %167, %168
%170 = call i32 (i32, i32, ...) @fcntl(i32 %162, i32 %163, i32 %169)
br label %171
171: ; preds = %160, %157
%172 = load i32, i32* %10
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %185
174: ; preds = %171
%175 = load i32*, i32** %15
%176 = load i32, i32* %175
%177 = load i32, i32* @F_SETFD
%178 = load i32*, i32** %15
%179 = load i32, i32* %178
%180 = load i32, i32* @F_GETFD
%181 = call i32 (i32, i32, ...) @fcntl(i32 %179, i32 %180)
%182 = load i32, i32* @FD_CLOEXEC
%183 = or i32 %181, %182
%184 = call i32 (i32, i32, ...) @fcntl(i32 %176, i32 %177, i32 %183)
br label %185
185: ; preds = %174, %171
%186 = load i32, i32* %11
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %199
188: ; preds = %185
%189 = load i32*, i32** %14
%190 = load i32, i32* %189
%191 = load i32, i32* @F_SETFL
%192 = load i32*, i32** %14
%193 = load i32, i32* %192
%194 = load i32, i32* @F_GETFL
%195 = call i32 (i32, i32, ...) @fcntl(i32 %193, i32 %194)
%196 = load i32, i32* @O_NONBLOCK
%197 = or i32 %195, %196
%198 = call i32 (i32, i32, ...) @fcntl(i32 %190, i32 %191, i32 %197)
br label %199
199: ; preds = %188, %185
%200 = load i32, i32* %10
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %213
202: ; preds = %199
%203 = load i32*, i32** %12
%204 = load i32, i32* %203
%205 = load i32, i32* @F_SETFL
%206 = load i32*, i32** %12
%207 = load i32, i32* %206
%208 = load i32, i32* @F_GETFL
%209 = call i32 (i32, i32, ...) @fcntl(i32 %207, i32 %208)
%210 = load i32, i32* @O_NONBLOCK
%211 = or i32 %209, %210
%212 = call i32 (i32, i32, ...) @fcntl(i32 %204, i32 %205, i32 %211)
br label %213
213: ; preds = %202, %199
store i32 0, i32* %8
br label %214
214: ; preds = %213, %87, %55, %42, %29
%215 = load i32, i32* %8
ret i32 %215
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"%s: internal error\0A\00"
@.str.1 = [32 x i8] c"%s: could not create pipes: %s\0A\00"
@errno = global i32 0
@.str.2 = [37 x i8] c"%s: could not duplicate descriptors\0A\00"
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@F_SETFD = global i32 0
@F_GETFD = global i32 0
@FD_CLOEXEC = global i32 0
@O_NONBLOCK = global i32 0
define i32 @normal_setup(i8* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i64
%9 = bitcast i64* %8 to [2 x i32]*
%10 = alloca i64
%11 = bitcast i64* %10 to [2 x i32]*
%12 = icmp ne i32* %3, null
%13 = icmp ne i32* %4, null
%14 = and i1 %12, %13
%15 = icmp ne i32* %5, null
%16 = and i1 %14, %15
%17 = icmp ne i32* %6, null
%18 = and i1 %16, %17
br i1 %18, label %22, label %19
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %142
22: ; preds = %7
%23 = bitcast i64* %8 to i8*
store i64 -1, i64* %8
%24 = bitcast i64* %10 to i8*
store i64 -1, i64* %10
%25 = icmp eq i32 %1, 0
br i1 %25, label %35, label %26
26: ; preds = %22
%27 = bitcast i64* %8 to i32*
%28 = call i64 @pipe(i32* %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %33)
br label %140
35: ; preds = %26, %22
%36 = icmp eq i32 %2, 0
br i1 %36, label %48, label %37
37: ; preds = %35
%38 = bitcast i64* %10 to i32*
%39 = call i64 @pipe(i32* %38)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %44)
br label %140
46: ; preds = %37
%47 = call i32 @dup(i32 35)
store i32 %47, i32* %5
br label %48
48: ; preds = %35, %46
br i1 %25, label %51, label %49
49: ; preds = %48
%50 = call i32 @dup(i32 36)
store i32 %50, i32* %6
br label %51
51: ; preds = %49, %48
br i1 %36, label %55, label %52
52: ; preds = %51
%53 = load i32, i32* %5
%54 = icmp slt i32 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %52, %51
br i1 %25, label %62, label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56, %52
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %140
62: ; preds = %56, %55
br i1 %36, label %76, label %63
63: ; preds = %62
%64 = bitcast i64* %10 to i32*
%65 = load i32, i32* %64
%66 = load i32, i32* @F_SETFL
%67 = load i32, i32* @F_GETFL
%68 = call i32 (i32, i32, ...) @fcntl(i32 35, i32 %67)
%69 = call i32 (i32, i32, ...) @fcntl(i32 %65, i32 %66, i32 %68)
%70 = load i32, i32* %64
%71 = call i32 @dup2(i32 %70, i32 35)
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%73 = load i32, i32* %72
store i32 %73, i32* %4
%74 = load i32, i32* %64
%75 = call i32 @close(i32 %74)
br label %76
76: ; preds = %63, %62
br i1 %25, label %97, label %77
77: ; preds = %76
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%79 = load i32, i32* %78
%80 = load i32, i32* @F_SETFL
%81 = load i32, i32* @F_GETFL
%82 = call i32 (i32, i32, ...) @fcntl(i32 36, i32 %81)
%83 = call i32 (i32, i32, ...) @fcntl(i32 %79, i32 %80, i32 %82)
%84 = load i32, i32* %78
%85 = call i32 @dup2(i32 %84, i32 36)
%86 = bitcast i64* %8 to i32*
%87 = load i32, i32* %86
store i32 %87, i32* %3
%88 = load i32, i32* %78
%89 = call i32 @close(i32 %88)
%90 = load i32, i32* %3
%91 = load i32, i32* @F_SETFD
%92 = load i32, i32* @F_GETFD
%93 = call i32 (i32, i32, ...) @fcntl(i32 %90, i32 %92)
%94 = load i32, i32* @FD_CLOEXEC
%95 = or i32 %94, %93
%96 = call i32 (i32, i32, ...) @fcntl(i32 %90, i32 %91, i32 %95)
br label %97
97: ; preds = %76, %77
br i1 %36, label %113, label %98
98: ; preds = %97
%99 = load i32, i32* %4
%100 = load i32, i32* @F_SETFD
%101 = load i32, i32* @F_GETFD
%102 = call i32 (i32, i32, ...) @fcntl(i32 %99, i32 %101)
%103 = load i32, i32* @FD_CLOEXEC
%104 = or i32 %103, %102
%105 = call i32 (i32, i32, ...) @fcntl(i32 %99, i32 %100, i32 %104)
%106 = load i32, i32* %5
%107 = load i32, i32* @F_SETFD
%108 = load i32, i32* @F_GETFD
%109 = call i32 (i32, i32, ...) @fcntl(i32 %106, i32 %108)
%110 = load i32, i32* @FD_CLOEXEC
%111 = or i32 %110, %109
%112 = call i32 (i32, i32, ...) @fcntl(i32 %106, i32 %107, i32 %111)
br label %113
113: ; preds = %97, %98
br i1 %25, label %122, label %114
114: ; preds = %113
%115 = load i32, i32* %6
%116 = load i32, i32* @F_SETFD
%117 = load i32, i32* @F_GETFD
%118 = call i32 (i32, i32, ...) @fcntl(i32 %115, i32 %117)
%119 = load i32, i32* @FD_CLOEXEC
%120 = or i32 %119, %118
%121 = call i32 (i32, i32, ...) @fcntl(i32 %115, i32 %116, i32 %120)
br label %122
122: ; preds = %114, %113
br i1 %36, label %131, label %123
123: ; preds = %122
%124 = load i32, i32* %5
%125 = load i32, i32* @F_SETFL
%126 = load i32, i32* @F_GETFL
%127 = call i32 (i32, i32, ...) @fcntl(i32 %124, i32 %126)
%128 = load i32, i32* @O_NONBLOCK
%129 = or i32 %128, %127
%130 = call i32 (i32, i32, ...) @fcntl(i32 %124, i32 %125, i32 %129)
br label %131
131: ; preds = %123, %122
br i1 %25, label %140, label %132
132: ; preds = %131
%133 = load i32, i32* %3
%134 = load i32, i32* @F_SETFL
%135 = load i32, i32* @F_GETFL
%136 = call i32 (i32, i32, ...) @fcntl(i32 %133, i32 %135)
%137 = load i32, i32* @O_NONBLOCK
%138 = or i32 %137, %136
%139 = call i32 (i32, i32, ...) @fcntl(i32 %133, i32 %134, i32 %138)
br label %140
140: ; preds = %131, %132, %59, %41, %30
%141 = phi i32 [ -1, %30 ], [ -1, %41 ], [ -1, %59 ], [ 0, %132 ], [ 0, %131 ]
br label %142
142: ; preds = %140, %19
%143 = phi i32 [ %141, %140 ], [ -1, %19 ]
ret i32 %143
}