#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 */
typedef int /*<<< orphan*/ val;

/* Variables and functions */
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ TCP_NODELAY;
int /*<<< orphan*/ anetSetError(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int anetSetTcpNoDelay(char *err, int fd, int val) {
  if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) == -1) {
    anetSetError(err, "setsockopt TCP_NODELAY: %s", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<anetSetTcpNoDelay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    11a3 <anetSetTcpNoDelay+0x73>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe6e(%rip),%rsi
call   1040 <anetSetError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <anetSetTcpNoDelay+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<anetSetTcpNoDelay>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%eax
mov    %rdi,%rbx
mov    %edx,0xc(%rsp)
mov    0x2e9b(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%edx
lea    0xc(%rsp),%rcx
mov    %eax,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    118f <anetSetTcpNoDelay+0x5f>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1040 <anetSetError@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str = [27 x i8] c"setsockopt TCP_NODELAY: %s\00"
@errno = global i32 0
define i32 @anetSetTcpNoDelay(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %6
%9 = load i32, i32* @IPPROTO_TCP
%10 = load i32, i32* @TCP_NODELAY
%11 = call i32 @setsockopt(i32 %8, i32 %9, i32 %10, i32* %7, i32 4)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @anetSetError(i8* %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 -1, i32* %4
br label %19
18: ; preds = %3
store i32 0, i32* %4
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str = [27 x i8] c"setsockopt TCP_NODELAY: %s\00"
@errno = global i32 0
define i32 @anetSetTcpNoDelay(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = load i32, i32* @IPPROTO_TCP
%6 = load i32, i32* @TCP_NODELAY
%7 = call i32 @setsockopt(i32 %1, i32 %5, i32 %6, i32* %4, i32 4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @anetSetError(i8* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %3, %9
%14 = phi i32 [ -1, %9 ], [ 0, %3 ]
ret i32 %14
}