#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*/ assert(int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ perror(char *);
void set_nonblocking(int fd) {
  int flags = fcntl(fd, F_GETFL);
  do {
    if (!(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0)) {
      perror("");
      assert(0);
    }
  } while (0);
}


x86 assembly (clang, -O0):
<set_nonblocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    0x2e81(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmp    $0x0,%eax
je     118c <set_nonblocking+0x5c>
lea    0xe80(%rip),%rdi
call   1050 <perror@plt>
xor    %edi,%edi
call   1040 <assert@plt>
jmp    1191 <set_nonblocking+0x61>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_nonblocking>:
push   %rbx
mov    %edi,%ebx
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    0x2e8e(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e95(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %eax,%eax
jne    1166 <set_nonblocking+0x36>
pop    %rbx
ret
lea    0xe93(%rip),%rdi
call   1050 <perror@plt>
xor    %edi,%edi
pop    %rbx
jmp    1040 <assert@plt>

LLVM IR (-O0):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str = [1 x i8] zeroinitializer
define void @set_nonblocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @F_GETFL
%6 = call i32 (i32, i32, ...) @fcntl(i32 %4, i32 %5)
store i32 %6, i32* %3
br label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = load i32, i32* @F_SETFL
%10 = load i32, i32* %3
%11 = load i32, i32* @O_NONBLOCK
%12 = or i32 %10, %11
%13 = call i32 (i32, i32, ...) @fcntl(i32 %8, i32 %9, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %7
%16 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @assert(i32 0)
br label %18
18: ; preds = %15, %7
br label %19
19: ; preds = %18
ret void
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str = [1 x i8] zeroinitializer
define void @set_nonblocking(i32 %0) {
%2 = load i32, i32* @F_GETFL
%3 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %2)
%4 = load i32, i32* @F_SETFL
%5 = load i32, i32* @O_NONBLOCK
%6 = or i32 %5, %3
%7 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %4, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @assert(i32 0)
br label %12
12: ; preds = %9, %1
ret void
}