#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*/ one;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCP_NODELAY;
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int Dpi_make_socket_fd() {
  int fd, one = 1, ret = -1;
  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
    setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
    ret = fd;
  }
  return ret;
}


x86 assembly (clang, -O0):
<Dpi_make_socket_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
je     1185 <Dpi_make_socket_fd+0x65>
mov    -0x4(%rbp),%edi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dpi_make_socket_fd>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1171 <Dpi_make_socket_fd+0x51>
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
define i32 @Dpi_make_socket_fd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %2
store i32 -1, i32* %3
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %1
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i32, i32* %1
%10 = load i32, i32* @IPPROTO_TCP
%11 = load i32, i32* @TCP_NODELAY
%12 = call i32 @setsockopt(i32 %9, i32 %10, i32 %11, i32* %2, i32 4)
%13 = load i32, i32* %1
store i32 %13, i32* %3
br label %14
14: ; preds = %8, %0
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
define i32 @Dpi_make_socket_fd() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i32, i32* @IPPROTO_TCP
%9 = load i32, i32* @TCP_NODELAY
%10 = call i32 @setsockopt(i32 %5, i32 %8, i32 %9, i32* %1, i32 4)
br label %11
11: ; preds = %7, %0
ret i32 %5
}