#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 fcntl(int, int /*<<< orphan*/, int);
int sockndelay(int sfd, int on) {
  return ((on) ? fcntl(sfd, F_SETFL, fcntl(sfd, F_GETFL, 0) | O_NONBLOCK)
               : fcntl(sfd, F_SETFL, fcntl(sfd, F_GETFL, 0) & ~O_NONBLOCK));
}


x86 assembly (clang, -O0):
<sockndelay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     116b <sockndelay+0x5b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    %eax,%edx
mov    0x2e8c(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    %eax,-0xc(%rbp)
jmp    11ae <sockndelay+0x9e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    %eax,%edx
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%edx
call   1030 <fcntl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockndelay>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2eb9(%rip),%rax
mov    (%rax),%r14d
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x2eaf(%rip),%rcx
mov    (%rcx),%edx
mov    %edx,%ecx
not    %ecx
and    %eax,%ecx
or     %eax,%edx
test   %ebx,%ebx
cmove  %ecx,%edx
mov    %ebp,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fcntl@plt>

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

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