#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*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int ndelay_on(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int socket_udp(void) {
  int s = 0;
  s = socket(AF_INET, SOCK_DGRAM, 0);
  if (s == -1)
    return -1;
  if (ndelay_on(s) == -1) {
    close(s);
    return -1;
  }
  return s;
}


x86 assembly (clang, -O0):
<socket_udp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1171 <socket_udp+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <socket_udp+0x6c>
mov    -0x8(%rbp),%edi
call   1040 <ndelay_on@plt>
cmp    $0xffffffff,%eax
jne    1196 <socket_udp+0x66>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <socket_udp+0x6c>
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   %rbp
push   %rbx
push   %rax
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     116f <socket_udp+0x3f>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <ndelay_on@plt>
cmp    $0xffffffff,%eax
je     1168 <socket_udp+0x38>
mov    %ebp,%ebx
jmp    116f <socket_udp+0x3f>
mov    %ebp,%edi
call   1030 <close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define i32 @socket_udp() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = load i32, i32* @AF_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 %18
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 @ndelay_on(i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
store i32 -1, i32* %1
br label %18
16: ; preds = %9
%17 = load i32, i32* %2
store i32 %17, i32* %1
br label %18
18: ; preds = %16, %13, %8
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define i32 @socket_udp() {
%1 = load i32, i32* @AF_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 %10, label %5
5: ; preds = %0
%6 = tail call i32 @ndelay_on(i32 %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @close(i32 %3)
br label %10
10: ; preds = %5, %0, %8
%11 = phi i32 [ -1, %8 ], [ -1, %0 ], [ %3, %5 ]
ret i32 %11
}