#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;
scalar_t__ O_NDELAY;
int fcntl(int, int /*<<< orphan*/, int);
void httpd_set_ndelay(int fd) {
  int flags = -1;
  int nflags = -1;
  flags = fcntl(fd, F_GETFL, 0);
  if (flags != -1) {
    nflags = flags & ~(int)O_NDELAY;
    if (nflags != flags) {
      fcntl(fd, F_SETFL, nflags);
    }
  }
}


x86 assembly (clang, -O0):
<httpd_set_ndelay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1183 <httpd_set_ndelay+0x73>
mov    -0x8(%rbp),%eax
mov    0x2e85(%rip),%rcx
mov    (%rcx),%rcx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     117e <httpd_set_ndelay+0x6e>
mov    -0x4(%rbp),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1030 <fcntl@plt>
jmp    1183 <httpd_set_ndelay+0x73>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_set_ndelay>:
push   %rbx
mov    %edi,%ebx
mov    0x2eb6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1139 <httpd_set_ndelay+0x29>
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%edx
not    %edx
and    %eax,%edx
cmp    %eax,%edx
jne    113b <httpd_set_ndelay+0x2b>
pop    %rbx
ret
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
pop    %rbx
jmp    1030 <fcntl@plt>

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

LLVM IR (-O2):
@F_GETFL = global i32 0
@O_NDELAY = global i64 0
@F_SETFL = global i32 0
define void @httpd_set_ndelay(i32 %0) {
%2 = load i32, i32* @F_GETFL
%3 = tail call i32 @fcntl(i32 %0, i32 %2, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = load i64, i64* @O_NDELAY
%7 = trunc i64 %6 to i32
%8 = xor i32 %7, -1
%9 = and i32 %3, %8
%10 = icmp eq i32 %9, %3
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = load i32, i32* @F_SETFL
%13 = tail call i32 @fcntl(i32 %0, i32 %12, i32 %9)
br label %14
14: ; preds = %5, %11, %1
ret void
}