#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*/ IPPROTO_TCP;
int /*<<< orphan*/ TCP_NODELAY;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ gettext(char *);
int /*<<< orphan*/ set_error(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int set_no_delay(int fd) {
  int flag = 1;
  if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) <
      0) {
    set_error(gettext("could not set TCP_NODELAY on socket (%s)"),
              strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_no_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    11b3 <set_no_delay+0x73>
lea    0xe79(%rip),%rdi
call   1040 <gettext@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%esi
call   1050 <set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <set_no_delay+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_no_delay>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    11a3 <set_no_delay+0x63>
lea    0xe80(%rip),%rdi
call   1040 <gettext@plt>
mov    %eax,%ebx
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <set_error@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str = [41 x i8] c"could not set TCP_NODELAY on socket (%s)\00"
@errno = global i32 0
define i32 @set_no_delay(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* @IPPROTO_TCP
%7 = load i32, i32* @TCP_NODELAY
%8 = bitcast i32* %4 to i8*
%9 = call i64 @setsockopt(i32 %5, i32 %6, i32 %7, i8* %8, i32 4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = call i32 @gettext(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @errno
%14 = call i32 @strerror(i32 %13)
%15 = call i32 @set_error(i32 %12, i32 %14)
store i32 -1, i32* %2
br label %17
16: ; preds = %1
store i32 0, i32* %2
br label %17
17: ; preds = %16, %11
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str = [41 x i8] c"could not set TCP_NODELAY on socket (%s)\00"
@errno = global i32 0
define i32 @set_no_delay(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = load i32, i32* @IPPROTO_TCP
%5 = load i32, i32* @TCP_NODELAY
%6 = call i64 @setsockopt(i32 %0, i32 %4, i32 %5, i8* %3, i32 4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = call i32 @gettext(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @set_error(i32 %9, i32 %11)
br label %13
13: ; preds = %1, %8
%14 = phi i32 [ -1, %8 ], [ 0, %1 ]
ret i32 %14
}