#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 errno;
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int setnonblocking(int conn_sock) {
  do {
    if ((fcntl(conn_sock, F_SETFL, fcntl(conn_sock, F_GETFL, 0) | O_NONBLOCK)) <
        0) {
      int old_errno = errno;
      perror("fcntl(conn_sock, F_SETFL, fcntl(conn_sock, F_GETFL, 0) | "
             "O_NONBLOCK)");
      exit(old_errno);
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<setnonblocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    %eax,%edx
mov    0x2e79(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0x0,%eax
jge    119f <setnonblocking+0x6f>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    0xe6e(%rip),%rdi
call   1040 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <exit@plt>
jmp    11a4 <setnonblocking+0x74>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setnonblocking>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e9c(%rip),%rax
mov    (%rax),%ebp
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x2e93(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <fcntl@plt>
test   %eax,%eax
js     116f <setnonblocking+0x3f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%ebx
lea    0xe81(%rip),%rdi
call   1040 <perror@plt>
mov    %ebx,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i32 0
@.str = [69 x i8] c"fcntl(conn_sock, F_SETFL, fcntl(conn_sock, F_GETFL, 0) | O_NONBLOCK)\00"
define i32 @setnonblocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %1
%5 = load i32, i32* %2
%6 = load i32, i32* @F_SETFL
%7 = load i32, i32* %2
%8 = load i32, i32* @F_GETFL
%9 = call i32 @fcntl(i32 %7, i32 %8, i32 0)
%10 = load i32, i32* @O_NONBLOCK
%11 = or i32 %9, %10
%12 = call i32 @fcntl(i32 %5, i32 %6, i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %4
%15 = load i32, i32* @errno
store i32 %15, i32* %3
%16 = call i32 @perror(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %4
br label %20
20: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i32 0
@.str = [69 x i8] c"fcntl(conn_sock, F_SETFL, fcntl(conn_sock, F_GETFL, 0) | O_NONBLOCK)\00"
define i32 @setnonblocking(i32 %0) {
%2 = load i32, i32* @F_SETFL
%3 = load i32, i32* @F_GETFL
%4 = tail call i32 @fcntl(i32 %0, i32 %3, i32 0)
%5 = load i32, i32* @O_NONBLOCK
%6 = or i32 %5, %4
%7 = tail call i32 @fcntl(i32 %0, i32 %2, i32 %6)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = tail call i32 @perror(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 %10)
unreachable
13: ; preds = %1
ret i32 0
}