// File: establishment[P]sandman/src/lib.hpp
// Function: ProcessInitialiser::setupPipes()
void setupPipes() {
        if (config.swapPipeOpenOrder == false) {
            if (config.redirectStdin.size()) {
                close(0);
                if (open(config.redirectStdin.c_str(), O_RDONLY) != 0) {
                    Die("open(\"%s\"): %m", config.redirectStdin.c_str());
                }
            }

            if (config.redirectStdout.size()) {
                close(1);
                if (open(config.redirectStdout.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1) {
                    Die("open(\"%s\"): %m", config.redirectStdout.c_str());
                }
            }
        } else {
            if (config.redirectStdout.size()) {
                close(1);
                if (open(config.redirectStdout.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1) {
                    Die("open(\"%s\"): %m", config.redirectStdout.c_str());
                }
            }

            if (config.redirectStdin.size()) {
                close(0);
                if (open(config.redirectStdin.c_str(), O_RDONLY) != 0) {
                    Die("open(\"%s\"): %m", config.redirectStdin.c_str());
                }
            }
        }

        if (config.redirectStderr.size()) {
            close(2);
            if (open(config.redirectStderr.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666) != 2) {
                Die("open(\"%s\"): %m", config.redirectStderr.c_str());
            }
        } else {
            dup2(1, 2);
        }
    }

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
movb 0xe4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xac91d
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c3f0
cmpq $0x0, %rax
je 0xac8b2
xorl %edi, %edi
callq 0x8cb80
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c1f0
movq %rax, %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x8c430
cmpl $0x0, %eax
je 0xac8b0
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c1f0
movq %rax, %rsi
leaq 0x49a99(%rip), %rdi     # 0xf6342
movb $0x0, %al
callq 0x94bf0
jmp 0xac8b2
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c3f0
cmpq $0x0, %rax
je 0xac918
movl $0x1, %edi
callq 0x8cb80
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c1f0
movq %rax, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x8c430
cmpl $0x1, %eax
je 0xac916
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c1f0
movq %rax, %rsi
leaq 0x49a33(%rip), %rdi     # 0xf6342
movb $0x0, %al
callq 0x94bf0
jmp 0xac918
jmp 0xac9e0
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c3f0
cmpq $0x0, %rax
je 0xac983
movl $0x1, %edi
callq 0x8cb80
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c1f0
movq %rax, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x8c430
cmpl $0x1, %eax
je 0xac981
movq 0x8(%rsp), %rdi
addq $0x78, %rdi
callq 0x8c1f0
movq %rax, %rsi
leaq 0x499c8(%rip), %rdi     # 0xf6342
movb $0x0, %al
callq 0x94bf0
jmp 0xac983
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c3f0
cmpq $0x0, %rax
je 0xac9de
xorl %edi, %edi
callq 0x8cb80
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c1f0
movq %rax, %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x8c430
cmpl $0x0, %eax
je 0xac9dc
movq 0x8(%rsp), %rdi
addq $0x58, %rdi
callq 0x8c1f0
movq %rax, %rsi
leaq 0x4996d(%rip), %rdi     # 0xf6342
movb $0x0, %al
callq 0x94bf0
jmp 0xac9de
jmp 0xac9e0
movq 0x8(%rsp), %rdi
addq $0x98, %rdi
callq 0x8c3f0
cmpq $0x0, %rax
je 0xaca4f
movl $0x2, %edi
callq 0x8cb80
movq 0x8(%rsp), %rdi
addq $0x98, %rdi
callq 0x8c1f0
movq %rax, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x8c430
cmpl $0x2, %eax
je 0xaca4d
movq 0x8(%rsp), %rdi
addq $0x98, %rdi
callq 0x8c1f0
movq %rax, %rsi
leaq 0x498fc(%rip), %rdi     # 0xf6342
movb $0x0, %al
callq 0x94bf0
jmp 0xaca5e
movl $0x1, %edi
movl $0x2, %esi
callq 0x8c540
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)