#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_SETFD;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ blocking_disable(int);
int /*<<< orphan*/ enable_bsd_fragmentation(int);
int /*<<< orphan*/ enable_linux_fragmentation(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int socket_udp(void) {
  int fd = socket(PF_INET, SOCK_DGRAM, 0);
  if (fd == -1)
    return -1;
  fcntl(fd, F_SETFD, 1);
  blocking_disable(fd);
  enable_bsd_fragmentation(fd);
  enable_linux_fragmentation(fd);
  return fd;
}


x86 assembly (clang, -O0):
<socket_udp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    118a <socket_udp+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11be <socket_udp+0x6e>
mov    -0x8(%rbp),%edi
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
call   1030 <fcntl@plt>
mov    -0x8(%rbp),%edi
call   1050 <blocking_disable@plt>
mov    -0x8(%rbp),%edi
call   1060 <enable_bsd_fragmentation@plt>
mov    -0x8(%rbp),%edi
call   1040 <enable_linux_fragmentation@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_udp>:
push   %rbx
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     119b <socket_udp+0x4b>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <fcntl@plt>
mov    %ebx,%edi
call   1050 <blocking_disable@plt>
mov    %ebx,%edi
call   1060 <enable_bsd_fragmentation@plt>
mov    %ebx,%edi
call   1040 <enable_linux_fragmentation@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@F_SETFD = global i32 0
define i32 @socket_udp() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @PF_INET
%4 = load i32, i32* @SOCK_DGRAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %20
9: ; preds = %0
%10 = load i32, i32* %2
%11 = load i32, i32* @F_SETFD
%12 = call i32 @fcntl(i32 %10, i32 %11, i32 1)
%13 = load i32, i32* %2
%14 = call i32 @blocking_disable(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @enable_bsd_fragmentation(i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @enable_linux_fragmentation(i32 %17)
%19 = load i32, i32* %2
store i32 %19, i32* %1
br label %20
20: ; preds = %9, %8
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@F_SETFD = global i32 0
define i32 @socket_udp() {
%1 = load i32, i32* @PF_INET
%2 = load i32, i32* @SOCK_DGRAM
%3 = tail call i32 @socket(i32 %1, i32 %2, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %11, label %5
5: ; preds = %0
%6 = load i32, i32* @F_SETFD
%7 = tail call i32 @fcntl(i32 %3, i32 %6, i32 1)
%8 = tail call i32 @blocking_disable(i32 %3)
%9 = tail call i32 @enable_bsd_fragmentation(i32 %3)
%10 = tail call i32 @enable_linux_fragmentation(i32 %3)
br label %11
11: ; preds = %0, %5
ret i32 %3
}