#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*/ O_WRONLY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ listen(int, int);
int open(char *, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  int sock_stream;
  int sock_dgram;
  int fd_null;
  sock_stream = socket(PF_INET, SOCK_STREAM, 0);
  sock_dgram = socket(PF_INET, SOCK_DGRAM, 0);
  fd_null = open("/dev/null", O_WRONLY);
  listen(-1, 0);
  listen(fd_null, 0);
  listen(sock_dgram, 0);
  listen(sock_stream, 0);
  listen(sock_stream, -1);
  close(sock_stream);
  close(sock_dgram);
  close(fd_null);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x10(%rbp)
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    -0x8(%rbp),%edi
mov    $0xffffffff,%esi
call   1040 <listen@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e85(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%edi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,%r14d
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <listen@plt>
mov    %ebx,%edi
mov    $0xffffffff,%esi
call   1040 <listen@plt>
mov    %ebx,%edi
call   1030 <close@plt>
mov    %r14d,%edi
call   1030 <close@plt>
mov    %ebp,%edi
call   1030 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @PF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = call i32 @socket(i32 %5, i32 %6, i32 0)
store i32 %7, i32* %2
%8 = load i32, i32* @PF_INET
%9 = load i32, i32* @SOCK_DGRAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %3
%11 = load i32, i32* @O_WRONLY
%12 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %4
%13 = call i32 @listen(i32 -1, i32 0)
%14 = load i32, i32* %4
%15 = call i32 @listen(i32 %14, i32 0)
%16 = load i32, i32* %3
%17 = call i32 @listen(i32 %16, i32 0)
%18 = load i32, i32* %2
%19 = call i32 @listen(i32 %18, i32 0)
%20 = load i32, i32* %2
%21 = call i32 @listen(i32 %20, i32 -1)
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* %3
%25 = call i32 @close(i32 %24)
%26 = load i32, i32* %4
%27 = call i32 @close(i32 %26)
ret i32 0
}

LLVM IR (-O2):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = load i32, i32* @PF_INET
%2 = load i32, i32* @SOCK_STREAM
%3 = tail call i32 @socket(i32 %1, i32 %2, i32 0)
%4 = load i32, i32* @PF_INET
%5 = load i32, i32* @SOCK_DGRAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = load i32, i32* @O_WRONLY
%8 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @listen(i32 -1, i32 0)
%10 = tail call i32 @listen(i32 %8, i32 0)
%11 = tail call i32 @listen(i32 %6, i32 0)
%12 = tail call i32 @listen(i32 %3, i32 0)
%13 = tail call i32 @listen(i32 %3, i32 -1)
%14 = tail call i32 @close(i32 %3)
%15 = tail call i32 @close(i32 %6)
%16 = tail call i32 @close(i32 %8)
ret i32 0
}