#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_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ STDOUT_FILENO;
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/, ...);
void stdout_nonblock_set(int yes) {
  int flags = fcntl(STDOUT_FILENO, F_GETFL);
  fcntl(STDOUT_FILENO, F_SETFL, yes ? flags & ~O_NONBLOCK : flags | O_NONBLOCK);
}


x86 assembly (clang, -O0):
<stdout_nonblock_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ece(%rip),%rax
mov    (%rax),%edi
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0x8(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1172 <stdout_nonblock_set+0x62>
mov    -0x8(%rbp),%eax
mov    0x2e7d(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    1181 <stdout_nonblock_set+0x71>
mov    -0x8(%rbp),%eax
mov    0x2e64(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdout_nonblock_set>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ed3(%rip),%r14
mov    (%r14),%edi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    (%r14),%edi
mov    0x2e96(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e9d(%rip),%rcx
mov    (%rcx),%edx
mov    %edx,%ecx
not    %ecx
and    %eax,%ecx
or     %eax,%edx
test   %ebx,%ebx
cmovne %ecx,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fcntl@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define void @stdout_nonblock_set(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* @STDOUT_FILENO
%5 = load i32, i32* @F_GETFL
%6 = call i32 (i32, i32, ...) @fcntl(i32 %4, i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* @STDOUT_FILENO
%8 = load i32, i32* @F_SETFL
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i32, i32* %3
%13 = load i32, i32* @O_NONBLOCK
%14 = xor i32 %13, -1
%15 = and i32 %12, %14
br label %20
16: ; preds = %1
%17 = load i32, i32* %3
%18 = load i32, i32* @O_NONBLOCK
%19 = or i32 %17, %18
br label %20
20: ; preds = %16, %11
%21 = phi i32 [ %15, %11 ], [ %19, %16 ]
%22 = call i32 (i32, i32, ...) @fcntl(i32 %7, i32 %8, i32 %21)
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define void @stdout_nonblock_set(i32 %0) {
%2 = load i32, i32* @STDOUT_FILENO
%3 = load i32, i32* @F_GETFL
%4 = tail call i32 (i32, i32, ...) @fcntl(i32 %2, i32 %3)
%5 = load i32, i32* @STDOUT_FILENO
%6 = load i32, i32* @F_SETFL
%7 = icmp eq i32 %0, 0
%8 = load i32, i32* @O_NONBLOCK
%9 = xor i32 %8, -1
%10 = and i32 %4, %9
%11 = or i32 %8, %4
%12 = select i1 %7, i32 %11, i32 %10
%13 = tail call i32 (i32, i32, ...) @fcntl(i32 %5, i32 %6, i32 %12)
ret void
}