#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  scalar_t__ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin1;
typedef int /*<<< orphan*/ sin0;
typedef int /*<<< orphan*/ optval;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int IPPROTO_IP;
int IPPROTO_UDP;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int SOL_SOCKET;
int SO_OOBINLINE;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ getsockopt(int, int, int, int *, int *);
int open(char *, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  int sock_stream;
  int fd_null;
  struct sockaddr_in sin0, sin1;
  socklen_t sinlen;
  int optval;
  socklen_t optlen;
  sin0.sin_family = AF_INET;
  sin0.sin_port = 0;
  sin0.sin_addr.s_addr = INADDR_ANY;
  sinlen = sizeof(sin1);
  optlen = sizeof(optval);
  sock_stream = socket(PF_INET, SOCK_STREAM, 0);
  bind(sock_stream, (struct sockaddr *)&sin0, sizeof(sin0));
  fd_null = open("/dev/null", O_WRONLY);
  getsockopt(-1, SOL_SOCKET, SO_OOBINLINE, &optval, &optlen);
  getsockopt(fd_null, SOL_SOCKET, SO_OOBINLINE, &optval, &optlen);
  getsockopt(sock_stream, SOL_SOCKET, SO_OOBINLINE, (void *)-1, &optlen);
  getsockopt(sock_stream, SOL_SOCKET, SO_OOBINLINE, &optval, (socklen_t *)-1);
  getsockopt(sock_stream, 500, SO_OOBINLINE, &optval, &optlen);
  getsockopt(sock_stream, -1, SO_OOBINLINE, &optval, &optlen);
  getsockopt(sock_stream, IPPROTO_UDP, SO_OOBINLINE, &optval, &optlen);
  getsockopt(sock_stream, IPPROTO_IP, -1, &optval, &optlen);
  getsockopt(sock_stream, SOL_SOCKET, SO_OOBINLINE, &optval, &optlen);
  close(sock_stream);
  close(fd_null);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movl   $0x18,-0x44(%rbp)
movl   $0x4,-0x4c(%rbp)
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    0x2e23(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   1050 <bind@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
lea    0xe36(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    0x2dd6(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0xc(%rbp),%edi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
mov    0x2daf(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2d68(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
mov    $0xffffffffffffffff,%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2d4c(%rip),%rax
mov    (%rax),%edx
mov    $0x1f4,%esi
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2d2e(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
mov    0x2d07(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
mov    0x2cc7(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <getsockopt@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movl   $0x4,0x8(%rsp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1050 <bind@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
lea    0xe3b(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%r14d
mov    0x2e14(%rip),%r12
mov    (%r12),%esi
mov    0x2dd9(%rip),%r13
mov    0x0(%r13),%edx
lea    0xc(%rsp),%rbp
lea    0x8(%rsp),%r15
mov    $0xffffffff,%edi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    (%r12),%esi
mov    0x0(%r13),%edx
mov    %r14d,%edi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    (%r12),%esi
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    (%r12),%esi
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    $0xffffffffffffffff,%r8
call   1040 <getsockopt@plt>
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    $0x1f4,%esi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    $0xffffffff,%esi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0xffffffff,%edx
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    (%r12),%esi
mov    0x0(%r13),%edx
mov    %ebx,%edi
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <getsockopt@plt>
mov    %ebx,%edi
call   1030 <close@plt>
mov    %r14d,%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i64, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
@SOL_SOCKET = global i32 0
@SO_OOBINLINE = global i32 0
@IPPROTO_UDP = global i32 0
@IPPROTO_IP = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
store i64 0, i64* %11
%12 = load i32, i32* @INADDR_ANY
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
store i32 %12, i32* %14
store i32 24, i32* %6
store i32 4, i32* %8
%15 = load i32, i32* @PF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%20 = call i32 @bind(i32 %18, %struct.sockaddr* %19, i32 24)
%21 = load i32, i32* @O_WRONLY
%22 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* @SOL_SOCKET
%24 = load i32, i32* @SO_OOBINLINE
%25 = call i32 @getsockopt(i32 -1, i32 %23, i32 %24, i32* %7, i32* %8)
%26 = load i32, i32* %3
%27 = load i32, i32* @SOL_SOCKET
%28 = load i32, i32* @SO_OOBINLINE
%29 = call i32 @getsockopt(i32 %26, i32 %27, i32 %28, i32* %7, i32* %8)
%30 = load i32, i32* %2
%31 = load i32, i32* @SOL_SOCKET
%32 = load i32, i32* @SO_OOBINLINE
%33 = call i32 @getsockopt(i32 %30, i32 %31, i32 %32, i32* inttoptr (i64 -1 to i32*), i32* %8)
%34 = load i32, i32* %2
%35 = load i32, i32* @SOL_SOCKET
%36 = load i32, i32* @SO_OOBINLINE
%37 = call i32 @getsockopt(i32 %34, i32 %35, i32 %36, i32* %7, i32* inttoptr (i64 -1 to i32*))
%38 = load i32, i32* %2
%39 = load i32, i32* @SO_OOBINLINE
%40 = call i32 @getsockopt(i32 %38, i32 500, i32 %39, i32* %7, i32* %8)
%41 = load i32, i32* %2
%42 = load i32, i32* @SO_OOBINLINE
%43 = call i32 @getsockopt(i32 %41, i32 -1, i32 %42, i32* %7, i32* %8)
%44 = load i32, i32* %2
%45 = load i32, i32* @IPPROTO_UDP
%46 = load i32, i32* @SO_OOBINLINE
%47 = call i32 @getsockopt(i32 %44, i32 %45, i32 %46, i32* %7, i32* %8)
%48 = load i32, i32* %2
%49 = load i32, i32* @IPPROTO_IP
%50 = call i32 @getsockopt(i32 %48, i32 %49, i32 -1, i32* %7, i32* %8)
%51 = load i32, i32* %2
%52 = load i32, i32* @SOL_SOCKET
%53 = load i32, i32* @SO_OOBINLINE
%54 = call i32 @getsockopt(i32 %51, i32 %52, i32 %53, i32* %7, i32* %8)
%55 = load i32, i32* %2
%56 = call i32 @close(i32 %55)
%57 = load i32, i32* %3
%58 = call i32 @close(i32 %57)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i64, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
@SOL_SOCKET = global i32 0
@SO_OOBINLINE = global i32 0
@IPPROTO_UDP = global i32 0
@IPPROTO_IP = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca i32
%4 = bitcast %struct.sockaddr_in* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i64 0, i64* %9
%10 = load i32, i32* @INADDR_ANY
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %10, i32* %11
store i32 4, i32* %3
%12 = load i32, i32* @PF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%16 = call i32 @bind(i32 %14, %struct.sockaddr* %15, i32 24)
%17 = load i32, i32* @O_WRONLY
%18 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @SOL_SOCKET
%20 = load i32, i32* @SO_OOBINLINE
%21 = call i32 @getsockopt(i32 -1, i32 %19, i32 %20, i32* %2, i32* %3)
%22 = load i32, i32* @SOL_SOCKET
%23 = load i32, i32* @SO_OOBINLINE
%24 = call i32 @getsockopt(i32 %18, i32 %22, i32 %23, i32* %2, i32* %3)
%25 = load i32, i32* @SOL_SOCKET
%26 = load i32, i32* @SO_OOBINLINE
%27 = call i32 @getsockopt(i32 %14, i32 %25, i32 %26, i32* inttoptr (i64 -1 to i32*), i32* %3)
%28 = load i32, i32* @SOL_SOCKET
%29 = load i32, i32* @SO_OOBINLINE
%30 = call i32 @getsockopt(i32 %14, i32 %28, i32 %29, i32* %2, i32* inttoptr (i64 -1 to i32*))
%31 = load i32, i32* @SO_OOBINLINE
%32 = call i32 @getsockopt(i32 %14, i32 500, i32 %31, i32* %2, i32* %3)
%33 = load i32, i32* @SO_OOBINLINE
%34 = call i32 @getsockopt(i32 %14, i32 -1, i32 %33, i32* %2, i32* %3)
%35 = load i32, i32* @IPPROTO_UDP
%36 = load i32, i32* @SO_OOBINLINE
%37 = call i32 @getsockopt(i32 %14, i32 %35, i32 %36, i32* %2, i32* %3)
%38 = load i32, i32* @IPPROTO_IP
%39 = call i32 @getsockopt(i32 %14, i32 %38, i32 -1, i32* %2, i32* %3)
%40 = load i32, i32* @SOL_SOCKET
%41 = load i32, i32* @SO_OOBINLINE
%42 = call i32 @getsockopt(i32 %14, i32 %40, i32 %41, i32* %2, i32* %3)
%43 = call i32 @close(i32 %14)
%44 = call i32 @close(i32 %18)
ret i32 0
}