#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 O_APPEND;
int O_CREAT;
int O_RDONLY;
int O_RDWR;
int O_WRONLY;
int STDERR_FILENO;
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
void stdIOfiles(char *stdout_fn, char *stderr_fn, char *stdin_fn) {
  int fe = -1, fi = -1, fo = -1, fm = -1;
  if ((fm = open("/dev/null", O_RDWR, 0)) != -1) {
    if (strcmp(stdin_fn, "-") == 0) {
    } else if (strcmp(stdin_fn, "") != 0) {
      if ((fi = open(stdin_fn, O_RDONLY, 0)) != -1) {
        fprintf(stderr,
                "Info: Unable to open %s for stdin input, duping /dev/null "
                "intead\n",
                stdin_fn);
        (void)dup2(fi, STDIN_FILENO);
      } else {
        (void)dup2(fm, STDIN_FILENO);
      }
    } else {
      (void)dup2(fm, STDIN_FILENO);
    }
    if (strcmp(stdout_fn, "-") == 0) {
    } else if (strcmp(stdout_fn, "") != 0) {
      if ((fo = open(stdout_fn, O_WRONLY | O_CREAT, 0764)) != -1) {
        (void)dup2(fo, STDOUT_FILENO);
      } else if ((fo = open(stdout_fn, O_RDWR | O_APPEND, 0764)) != -1) {
        (void)dup2(fo, STDOUT_FILENO);
      } else {
        fprintf(stderr,
                "Info: Unable to open %s for stdout output, duping /dev/null "
                "intead\n",
                stdout_fn);
        (void)dup2(fm, STDOUT_FILENO);
      }
    } else {
      (void)dup2(fm, STDOUT_FILENO);
    }
    if (strcmp(stderr_fn, "&1") == 0) {
      if (fo != -1) {
        (void)dup2(fo, STDERR_FILENO);
      } else {
        (void)dup2(fm, STDERR_FILENO);
      }
    } else if (strcmp(stderr_fn, "-") == 0) {
    } else if (strcmp(stderr_fn, "") != 0) {
      if ((fe = open(stderr_fn, O_WRONLY | O_CREAT, 0764)) != -1) {
        (void)dup2(fe, STDERR_FILENO);
      } else if ((fe = open(stderr_fn, O_RDWR | O_APPEND, 0764)) != -1) {
        (void)dup2(fe, STDERR_FILENO);
      } else {
        fprintf(stderr,
                "Info: Unable to open %s for stderr error, duping /dev/null "
                "intead\n",
                stderr_fn);
        (void)dup2(fm, STDERR_FILENO);
      }
    } else {
      (void)dup2(fm, STDERR_FILENO);
    }
    if (fm > STDERR_FILENO) {
      (void)close(fm);
    }
  } else {
    fprintf(stderr,
            "Info: unable to redirect stdout, stderr, stdin - oh well...\n");
  }
}


x86 assembly (clang, -O0):
<stdIOfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     14df <stdIOfiles+0x38f>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <stdIOfiles+0x72>
jmp    1259 <stdIOfiles+0x109>
mov    -0x18(%rbp),%rdi
lea    0xf47(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1243 <stdIOfiles+0xf3>
mov    -0x18(%rbp),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
je     122d <stdIOfiles+0xdd>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%edi
mov    0x2d8f(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    123e <stdIOfiles+0xee>
mov    -0x28(%rbp),%edi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1254 <stdIOfiles+0x104>
mov    -0x28(%rbp),%edi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1259 <stdIOfiles+0x109>
mov    -0x8(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1278 <stdIOfiles+0x128>
jmp    1362 <stdIOfiles+0x212>
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     134c <stdIOfiles+0x1fc>
mov    -0x8(%rbp),%rdi
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
mov    0x2d52(%rip),%rax
or     (%rax),%esi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     12d4 <stdIOfiles+0x184>
mov    -0x24(%rbp),%edi
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1347 <stdIOfiles+0x1f7>
mov    -0x8(%rbp),%rdi
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
mov    0x2cb0(%rip),%rax
or     (%rax),%esi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1316 <stdIOfiles+0x1c6>
mov    -0x24(%rbp),%edi
mov    0x2cde(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1342 <stdIOfiles+0x1f2>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%edi
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1347 <stdIOfiles+0x1f7>
jmp    135d <stdIOfiles+0x20d>
mov    -0x28(%rbp),%edi
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    1362 <stdIOfiles+0x212>
mov    -0x10(%rbp),%rdi
lea    0xd25(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    13b2 <stdIOfiles+0x262>
cmpl   $0xffffffff,-0x24(%rbp)
je     139c <stdIOfiles+0x24c>
mov    -0x24(%rbp),%edi
mov    0x2c28(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    13ad <stdIOfiles+0x25d>
mov    -0x28(%rbp),%edi
mov    0x2c12(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    14c0 <stdIOfiles+0x370>
mov    -0x10(%rbp),%rdi
lea    0xc4d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    13d1 <stdIOfiles+0x281>
jmp    14bb <stdIOfiles+0x36b>
mov    -0x10(%rbp),%rdi
lea    0xd38(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14a5 <stdIOfiles+0x355>
mov    -0x10(%rbp),%rdi
mov    0x2baa(%rip),%rax
mov    (%rax),%esi
mov    0x2bf9(%rip),%rax
or     (%rax),%esi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     142d <stdIOfiles+0x2dd>
mov    -0x1c(%rbp),%edi
mov    0x2b97(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    14a0 <stdIOfiles+0x350>
mov    -0x10(%rbp),%rdi
mov    0x2ba0(%rip),%rax
mov    (%rax),%esi
mov    0x2b57(%rip),%rax
or     (%rax),%esi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     146f <stdIOfiles+0x31f>
mov    -0x1c(%rbp),%edi
mov    0x2b55(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    149b <stdIOfiles+0x34b>
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc12(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%edi
mov    0x2b24(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    14a0 <stdIOfiles+0x350>
jmp    14b6 <stdIOfiles+0x366>
mov    -0x28(%rbp),%edi
mov    0x2b09(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
jmp    14bb <stdIOfiles+0x36b>
jmp    14c0 <stdIOfiles+0x370>
mov    -0x28(%rbp),%eax
mov    0x2aee(%rip),%rcx
cmp    (%rcx),%eax
jle    14da <stdIOfiles+0x38a>
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
jmp    14f6 <stdIOfiles+0x3a6>
mov    0x2ada(%rip),%rax
mov    (%rax),%edi
lea    0xbe9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdIOfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e6d(%rip),%r13
mov    0x0(%r13),%esi
lea    0xe8a(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     129f <stdIOfiles+0x14f>
mov    %eax,%r15d
lea    0xe7a(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11fb <stdIOfiles+0xab>
lea    0xf70(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
mov    %r15d,%edi
test   %rax,%rax
je     11ed <stdIOfiles+0x9d>
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    %r15d,%edi
cmp    $0xffffffff,%eax
je     11ed <stdIOfiles+0x9d>
mov    %eax,%ebx
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
lea    0xe08(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12c4 <stdIOfiles+0x174>
lea    0xefa(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcmp@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     12cb <stdIOfiles+0x17b>
mov    0x2d69(%rip),%rax
mov    0x2dba(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r12,%rdi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,%edi
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    12ce <stdIOfiles+0x17e>
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
or     0x0(%r13),%esi
mov    %r12,%rdi
mov    $0x1f4,%edx
call   1070 <open@plt>
mov    %eax,%edi
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    12ce <stdIOfiles+0x17e>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15d,%edi
mov    $0xffffffff,%ebp
jmp    12ce <stdIOfiles+0x17e>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    12dc <stdIOfiles+0x18c>
mov    %r15d,%edi
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
lea    0xdaf(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     136c <stdIOfiles+0x21c>
lea    0xd13(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     13a9 <stdIOfiles+0x259>
lea    0xe05(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1398 <stdIOfiles+0x248>
mov    0x2c7d(%rip),%rax
mov    0x2cce(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
mov    $0x1f4,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
jne    135f <stdIOfiles+0x20f>
mov    0x2c51(%rip),%rax
mov    (%rax),%esi
or     0x0(%r13),%esi
mov    %r14,%rdi
mov    $0x1f4,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     137e <stdIOfiles+0x22e>
mov    0x2c52(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
jmp    13a4 <stdIOfiles+0x254>
mov    0x2c45(%rip),%rax
mov    (%rax),%esi
cmp    $0xffffffff,%ebp
je     13a1 <stdIOfiles+0x251>
mov    %ebp,%edi
jmp    13a4 <stdIOfiles+0x254>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2c19(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1030 <dup2@plt>
mov    0x2c08(%rip),%rax
cmp    (%rax),%r15d
jle    13cb <stdIOfiles+0x27b>
mov    %r15d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <close@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [1 x i8] zeroinitializer
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [66 x i8] c"Info: Unable to open %s for stdin input, duping /dev/null intead\0A\00"
@STDIN_FILENO = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@STDOUT_FILENO = global i32 0
@O_APPEND = global i32 0
@.str.4 = [68 x i8] c"Info: Unable to open %s for stdout output, duping /dev/null intead\0A\00"
@.str.5 = [3 x i8] c"&1\00"
@STDERR_FILENO = global i32 0
@.str.6 = [67 x i8] c"Info: Unable to open %s for stderr error, duping /dev/null intead\0A\00"
@.str.7 = [61 x i8] c"Info: unable to redirect stdout, stderr, stdin - oh well...\0A\00"
define void @stdIOfiles(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 -1, i32* %7
store i32 -1, i32* %8
store i32 -1, i32* %9
store i32 -1, i32* %10
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11, i32 0)
store i32 %12, i32* %10
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %160
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %45
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = load i32, i32* @O_RDONLY
%26 = call i32 @open(i8* %24, i32 %25, i32 0)
store i32 %26, i32* %8
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %6
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %8
%33 = load i32, i32* @STDIN_FILENO
%34 = call i32 @dup2(i32 %32, i32 %33)
br label %39
35: ; preds = %23
%36 = load i32, i32* %10
%37 = load i32, i32* @STDIN_FILENO
%38 = call i32 @dup2(i32 %36, i32 %37)
br label %39
39: ; preds = %35, %28
br label %44
40: ; preds = %19
%41 = load i32, i32* %10
%42 = load i32, i32* @STDIN_FILENO
%43 = call i32 @dup2(i32 %41, i32 %42)
br label %44
44: ; preds = %40, %39
br label %45
45: ; preds = %44, %18
%46 = load i8*, i8** %4
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
br label %90
50: ; preds = %45
%51 = load i8*, i8** %4
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %85
54: ; preds = %50
%55 = load i8*, i8** %4
%56 = load i32, i32* @O_WRONLY
%57 = load i32, i32* @O_CREAT
%58 = or i32 %56, %57
%59 = call i32 @open(i8* %55, i32 %58, i32 500)
store i32 %59, i32* %9
%60 = icmp ne i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %54
%62 = load i32, i32* %9
%63 = load i32, i32* @STDOUT_FILENO
%64 = call i32 @dup2(i32 %62, i32 %63)
br label %84
65: ; preds = %54
%66 = load i8*, i8** %4
%67 = load i32, i32* @O_RDWR
%68 = load i32, i32* @O_APPEND
%69 = or i32 %67, %68
%70 = call i32 @open(i8* %66, i32 %69, i32 500)
store i32 %70, i32* %9
%71 = icmp ne i32 %70, -1
br i1 %71, label %72, label %76
72: ; preds = %65
%73 = load i32, i32* %9
%74 = load i32, i32* @STDOUT_FILENO
%75 = call i32 @dup2(i32 %73, i32 %74)
br label %83
76: ; preds = %65
%77 = load i32, i32* @stderr
%78 = load i8*, i8** %4
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i8* %78)
%80 = load i32, i32* %10
%81 = load i32, i32* @STDOUT_FILENO
%82 = call i32 @dup2(i32 %80, i32 %81)
br label %83
83: ; preds = %76, %72
br label %84
84: ; preds = %83, %61
br label %89
85: ; preds = %50
%86 = load i32, i32* %10
%87 = load i32, i32* @STDOUT_FILENO
%88 = call i32 @dup2(i32 %86, i32 %87)
br label %89
89: ; preds = %85, %84
br label %90
90: ; preds = %89, %49
%91 = load i8*, i8** %5
%92 = call i64 @strcmp(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %106
94: ; preds = %90
%95 = load i32, i32* %9
%96 = icmp ne i32 %95, -1
br i1 %96, label %97, label %101
97: ; preds = %94
%98 = load i32, i32* %9
%99 = load i32, i32* @STDERR_FILENO
%100 = call i32 @dup2(i32 %98, i32 %99)
br label %105
101: ; preds = %94
%102 = load i32, i32* %10
%103 = load i32, i32* @STDERR_FILENO
%104 = call i32 @dup2(i32 %102, i32 %103)
br label %105
105: ; preds = %101, %97
br label %152
106: ; preds = %90
%107 = load i8*, i8** %5
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %106
br label %151
111: ; preds = %106
%112 = load i8*, i8** %5
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %146
115: ; preds = %111
%116 = load i8*, i8** %5
%117 = load i32, i32* @O_WRONLY
%118 = load i32, i32* @O_CREAT
%119 = or i32 %117, %118
%120 = call i32 @open(i8* %116, i32 %119, i32 500)
store i32 %120, i32* %7
%121 = icmp ne i32 %120, -1
br i1 %121, label %122, label %126
122: ; preds = %115
%123 = load i32, i32* %7
%124 = load i32, i32* @STDERR_FILENO
%125 = call i32 @dup2(i32 %123, i32 %124)
br label %145
126: ; preds = %115
%127 = load i8*, i8** %5
%128 = load i32, i32* @O_RDWR
%129 = load i32, i32* @O_APPEND
%130 = or i32 %128, %129
%131 = call i32 @open(i8* %127, i32 %130, i32 500)
store i32 %131, i32* %7
%132 = icmp ne i32 %131, -1
br i1 %132, label %133, label %137
133: ; preds = %126
%134 = load i32, i32* %7
%135 = load i32, i32* @STDERR_FILENO
%136 = call i32 @dup2(i32 %134, i32 %135)
br label %144
137: ; preds = %126
%138 = load i32, i32* @stderr
%139 = load i8*, i8** %5
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i8* %139)
%141 = load i32, i32* %10
%142 = load i32, i32* @STDERR_FILENO
%143 = call i32 @dup2(i32 %141, i32 %142)
br label %144
144: ; preds = %137, %133
br label %145
145: ; preds = %144, %122
br label %150
146: ; preds = %111
%147 = load i32, i32* %10
%148 = load i32, i32* @STDERR_FILENO
%149 = call i32 @dup2(i32 %147, i32 %148)
br label %150
150: ; preds = %146, %145
br label %151
151: ; preds = %150, %110
br label %152
152: ; preds = %151, %105
%153 = load i32, i32* %10
%154 = load i32, i32* @STDERR_FILENO
%155 = icmp sgt i32 %153, %154
br i1 %155, label %156, label %159
156: ; preds = %152
%157 = load i32, i32* %10
%158 = call i32 @close(i32 %157)
br label %159
159: ; preds = %156, %152
br label %163
160: ; preds = %3
%161 = load i32, i32* @stderr
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
br label %163
163: ; preds = %160, %159
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [1 x i8] zeroinitializer
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [66 x i8] c"Info: Unable to open %s for stdin input, duping /dev/null intead\0A\00"
@STDIN_FILENO = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@STDOUT_FILENO = global i32 0
@O_APPEND = global i32 0
@.str.4 = [68 x i8] c"Info: Unable to open %s for stdout output, duping /dev/null intead\0A\00"
@.str.5 = [3 x i8] c"&1\00"
@STDERR_FILENO = global i32 0
@.str.6 = [67 x i8] c"Info: Unable to open %s for stderr error, duping /dev/null intead\0A\00"
@.str.7 = [61 x i8] c"Info: unable to redirect stdout, stderr, stdin - oh well...\0A\00"
define void @stdIOfiles(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %98, label %7
7: ; preds = %3
%8 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 @open(i8* %2, i32 %14, i32 0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %20
20: ; preds = %10, %13, %17
%21 = phi i32 [ %15, %17 ], [ %5, %13 ], [ %5, %10 ]
%22 = load i32, i32* @STDIN_FILENO
%23 = tail call i32 @dup2(i32 %21, i32 %22)
br label %24
24: ; preds = %20, %7
%25 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %50, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %45, label %30
30: ; preds = %27
%31 = load i32, i32* @O_WRONLY
%32 = load i32, i32* @O_CREAT
%33 = or i32 %32, %31
%34 = tail call i32 @open(i8* %0, i32 %33, i32 500)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %45
36: ; preds = %30
%37 = load i32, i32* @O_RDWR
%38 = load i32, i32* @O_APPEND
%39 = or i32 %38, %37
%40 = tail call i32 @open(i8* %0, i32 %39, i32 500)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %45
45: ; preds = %27, %36, %30, %42
%46 = phi i32 [ %5, %42 ], [ %34, %30 ], [ %40, %36 ], [ %5, %27 ]
%47 = phi i32 [ -1, %42 ], [ %34, %30 ], [ %40, %36 ], [ -1, %27 ]
%48 = load i32, i32* @STDOUT_FILENO
%49 = tail call i32 @dup2(i32 %46, i32 %48)
br label %50
50: ; preds = %45, %24
%51 = phi i32 [ -1, %24 ], [ %47, %45 ]
%52 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = icmp eq i32 %51, -1
%56 = load i32, i32* @STDERR_FILENO
br i1 %55, label %59, label %57
57: ; preds = %54
%58 = tail call i32 @dup2(i32 %51, i32 %56)
br label %93
59: ; preds = %54
%60 = tail call i32 @dup2(i32 %5, i32 %56)
br label %93
61: ; preds = %50
%62 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %93, label %64
64: ; preds = %61
%65 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %90, label %67
67: ; preds = %64
%68 = load i32, i32* @O_WRONLY
%69 = load i32, i32* @O_CREAT
%70 = or i32 %69, %68
%71 = tail call i32 @open(i8* %1, i32 %70, i32 500)
%72 = icmp eq i32 %71, -1
br i1 %72, label %76, label %73
73: ; preds = %67
%74 = load i32, i32* @STDERR_FILENO
%75 = tail call i32 @dup2(i32 %71, i32 %74)
br label %93
76: ; preds = %67
%77 = load i32, i32* @O_RDWR
%78 = load i32, i32* @O_APPEND
%79 = or i32 %78, %77
%80 = tail call i32 @open(i8* %1, i32 %79, i32 500)
%81 = icmp eq i32 %80, -1
br i1 %81, label %85, label %82
82: ; preds = %76
%83 = load i32, i32* @STDERR_FILENO
%84 = tail call i32 @dup2(i32 %80, i32 %83)
br label %93
85: ; preds = %76
%86 = load i32, i32* @stderr
%87 = tail call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%88 = load i32, i32* @STDERR_FILENO
%89 = tail call i32 @dup2(i32 %5, i32 %88)
br label %93
90: ; preds = %64
%91 = load i32, i32* @STDERR_FILENO
%92 = tail call i32 @dup2(i32 %5, i32 %91)
br label %93
93: ; preds = %61, %73, %85, %82, %90, %57, %59
%94 = load i32, i32* @STDERR_FILENO
%95 = icmp sgt i32 %5, %94
br i1 %95, label %96, label %101
96: ; preds = %93
%97 = tail call i32 @close(i32 %5)
br label %101
98: ; preds = %3
%99 = load i32, i32* @stderr
%100 = tail call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
br label %101
101: ; preds = %93, %96, %98
ret void
}