#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_NOFOLLOW;
int O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ fix_single_std_fd(int, char *, int);
void fix_std_streams(void) {
  fix_single_std_fd(0, "/dev/full", O_RDONLY | O_NOFOLLOW);
  fix_single_std_fd(1, "/dev/null", O_WRONLY | O_NOFOLLOW);
  fix_single_std_fd(2, "/dev/null", O_WRONLY | O_NOFOLLOW);
}


x86 assembly (clang, -O0):
<fix_std_streams>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edx
mov    0x2ed4(%rip),%rax
or     (%rax),%edx
xor    %edi,%edi
lea    0xed1(%rip),%rsi
call   1030 <fix_single_std_fd@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    0x2eb4(%rip),%rax
or     (%rax),%edx
mov    $0x1,%edi
lea    0xeb8(%rip),%rsi
call   1030 <fix_single_std_fd@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    0x2e91(%rip),%rax
or     (%rax),%edx
mov    $0x2,%edi
lea    0xe95(%rip),%rsi
call   1030 <fix_single_std_fd@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_std_streams>:
push   %r15
push   %r14
push   %rbx
mov    0x2ec4(%rip),%rax
mov    0x2ed5(%rip),%r14
mov    (%r14),%edx
or     (%rax),%edx
lea    0xed1(%rip),%rsi
xor    %edi,%edi
call   1030 <fix_single_std_fd@plt>
mov    0x2e8b(%rip),%r15
mov    (%r14),%edx
or     (%r15),%edx
lea    0xec0(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <fix_single_std_fd@plt>
mov    (%r14),%edx
or     (%r15),%edx
mov    $0x2,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fix_single_std_fd@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/full\00"
@O_RDONLY = global i32 0
@O_NOFOLLOW = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define void @fix_std_streams() {
%1 = load i32, i32* @O_RDONLY
%2 = load i32, i32* @O_NOFOLLOW
%3 = or i32 %1, %2
%4 = call i32 @fix_single_std_fd(i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_NOFOLLOW
%7 = or i32 %5, %6
%8 = call i32 @fix_single_std_fd(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @O_WRONLY
%10 = load i32, i32* @O_NOFOLLOW
%11 = or i32 %9, %10
%12 = call i32 @fix_single_std_fd(i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/full\00"
@O_RDONLY = global i32 0
@O_NOFOLLOW = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define void @fix_std_streams() {
%1 = load i32, i32* @O_RDONLY
%2 = load i32, i32* @O_NOFOLLOW
%3 = or i32 %2, %1
%4 = tail call i32 @fix_single_std_fd(i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_NOFOLLOW
%7 = or i32 %6, %5
%8 = tail call i32 @fix_single_std_fd(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @O_WRONLY
%10 = load i32, i32* @O_NOFOLLOW
%11 = or i32 %10, %9
%12 = tail call i32 @fix_single_std_fd(i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11)
ret void
}