#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 /*<<< orphan*/ F_GETFD;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdinout_open(int /*<<< orphan*/, char *,
                                 int /*<<< orphan*/);
void stdinout_preinit() {
  if (fcntl(STDIN_FILENO, F_GETFD) == -1) {
    stdinout_open(STDIN_FILENO, "/dev/null", O_RDONLY);
  }
  if (fcntl(STDOUT_FILENO, F_GETFD) == -1) {
    stdinout_open(STDOUT_FILENO, "/dev/full", O_WRONLY);
  }
}


x86 assembly (clang, -O0):
<stdinout_preinit>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    1162 <stdinout_preinit+0x42>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
lea    0xea3(%rip),%rsi
call   1040 <stdinout_open@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    11a0 <stdinout_preinit+0x80>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
lea    0xe6f(%rip),%rsi
call   1040 <stdinout_open@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdinout_preinit>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e9c(%rip),%r14
mov    (%r14),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    1158 <stdinout_preinit+0x38>
mov    (%rbx),%edi
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
lea    0xead(%rip),%rsi
call   1040 <stdinout_open@plt>
mov    0x2e91(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1176 <stdinout_preinit+0x56>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    (%rbx),%edi
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
lea    0xe82(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <stdinout_open@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.1 = [10 x i8] c"/dev/full\00"
@O_WRONLY = global i32 0
define void @stdinout_preinit() {
%1 = load i32, i32* @STDIN_FILENO
%2 = load i32, i32* @F_GETFD
%3 = call i32 @fcntl(i32 %1, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @STDIN_FILENO
%7 = load i32, i32* @O_RDONLY
%8 = call i32 @stdinout_open(i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %5, %0
%10 = load i32, i32* @STDOUT_FILENO
%11 = load i32, i32* @F_GETFD
%12 = call i32 @fcntl(i32 %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* @STDOUT_FILENO
%16 = load i32, i32* @O_WRONLY
%17 = call i32 @stdinout_open(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.1 = [10 x i8] c"/dev/full\00"
@O_WRONLY = global i32 0
define void @stdinout_preinit() {
%1 = load i32, i32* @STDIN_FILENO
%2 = load i32, i32* @F_GETFD
%3 = tail call i32 @fcntl(i32 %1, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @STDIN_FILENO
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @stdinout_open(i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %5, %0
%10 = load i32, i32* @STDOUT_FILENO
%11 = load i32, i32* @F_GETFD
%12 = tail call i32 @fcntl(i32 %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* @STDOUT_FILENO
%16 = load i32, i32* @O_WRONLY
%17 = tail call i32 @stdinout_open(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %9
ret void
}