#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*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ assert(int);
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/);
void __libc_check_standard_fds(void) {
  assert(fcntl((STDIN_FILENO), F_GETFD) != -1);
  assert(fcntl((STDOUT_FILENO), F_GETFD) != -1);
  assert(fcntl((STDERR_FILENO), F_GETFD) != -1);
}


x86 assembly (clang, -O0):
<__libc_check_standard_fds>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<__libc_check_standard_fds>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    0x2ea7(%rip),%rbx
mov    (%rbx),%esi
call   1030 <fcntl@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <fcntl@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <fcntl@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
pop    %rbx
jmp    1040 <assert@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define void @__libc_check_standard_fds() {
%1 = load i32, i32* @STDIN_FILENO
%2 = load i32, i32* @F_GETFD
%3 = call i32 @fcntl(i32 %1, i32 %2)
%4 = icmp ne i32 %3, -1
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i32, i32* @STDOUT_FILENO
%8 = load i32, i32* @F_GETFD
%9 = call i32 @fcntl(i32 %7, i32 %8)
%10 = icmp ne i32 %9, -1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* @STDERR_FILENO
%14 = load i32, i32* @F_GETFD
%15 = call i32 @fcntl(i32 %13, i32 %14)
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret void
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define void @__libc_check_standard_fds() {
%1 = load i32, i32* @STDIN_FILENO
%2 = load i32, i32* @F_GETFD
%3 = tail call i32 @fcntl(i32 %1, i32 %2)
%4 = icmp ne i32 %3, -1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = load i32, i32* @STDOUT_FILENO
%8 = load i32, i32* @F_GETFD
%9 = tail call i32 @fcntl(i32 %7, i32 %8)
%10 = icmp ne i32 %9, -1
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = load i32, i32* @STDERR_FILENO
%14 = load i32, i32* @F_GETFD
%15 = tail call i32 @fcntl(i32 %13, i32 %14)
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
ret void
}