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


x86 assembly (clang, -O0):
<isstdiomissing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0xffffffff,%ecx
mov    %al,-0x1(%rbp)
je     1186 <isstdiomissing+0x76>
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0xffffffff,%ecx
mov    %al,-0x1(%rbp)
je     1186 <isstdiomissing+0x76>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isstdiomissing>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    0x2eb4(%rip),%r14
mov    (%r14),%esi
call   1030 <fcntl@plt>
mov    $0x1,%ebx
cmp    $0xffffffff,%eax
je     1165 <isstdiomissing+0x55>
mov    0x2eb3(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1165 <isstdiomissing+0x55>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%esi
call   1030 <fcntl@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define i32 @isstdiomissing() {
%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 %15, label %5
5: ; preds = %0
%6 = load i32, i32* @STDOUT_FILENO
%7 = load i32, i32* @F_GETFD
%8 = call i32 @fcntl(i32 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load i32, i32* @STDERR_FILENO
%12 = load i32, i32* @F_GETFD
%13 = call i32 @fcntl(i32 %11, i32 %12)
%14 = icmp eq i32 %13, -1
br label %15
15: ; preds = %10, %5, %0
%16 = phi i1 [ true, %5 ], [ true, %0 ], [ %14, %10 ]
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@F_GETFD = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define i32 @isstdiomissing() {
%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 %16, label %5
5: ; preds = %0
%6 = load i32, i32* @STDOUT_FILENO
%7 = load i32, i32* @F_GETFD
%8 = tail call i32 @fcntl(i32 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = load i32, i32* @STDERR_FILENO
%12 = load i32, i32* @F_GETFD
%13 = tail call i32 @fcntl(i32 %11, i32 %12)
%14 = icmp eq i32 %13, -1
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %10, %5, %0
%17 = phi i32 [ 1, %5 ], [ 1, %0 ], [ %15, %10 ]
ret i32 %17
}