#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*/ zero;
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_port;
  int /*<<< orphan*/ sin6_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sin6;
typedef int /*<<< orphan*/ one;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int FD_CLOEXEC;
int /*<<< orphan*/ F_GETFD;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFD;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ IPPROTO_IPV6;
int /*<<< orphan*/ IPV6_MULTICAST_HOPS;
int /*<<< orphan*/ IPV6_MULTICAST_LOOP;
int /*<<< orphan*/ IPV6_RECVPKTINFO;
int O_NONBLOCK;
int /*<<< orphan*/ PF_INET6;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int errno;
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int hn_socket(int port) {
  struct sockaddr_in6 sin6;
  int s, rc;
  int saved_errno;
  int one = 1, zero = 0;
  s = socket(PF_INET6, SOCK_DGRAM, 0);
  if (s < 0)
    return -1;
  rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
  if (rc < 0)
    perror("setsockopt(SO_REUSEADDR)");
  rc = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &zero, sizeof(zero));
  if (rc < 0)
    perror("setsockopt(IPV6_MULTICAST_LOOP)");
  rc = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &one, sizeof(one));
  if (rc < 0)
    perror("setsockopt(IPV6_MULTICAST_HOPS)");
  rc = setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
  if (rc < 0) {
    perror("setsockopt(IPV6_RECVPKTINFO)");
    goto fail;
  }
  rc = fcntl(s, F_GETFD, 0);
  if (rc < 0)
    goto fail;
  rc = fcntl(s, F_SETFD, rc | FD_CLOEXEC);
  if (rc < 0)
    goto fail;
  rc = fcntl(s, F_GETFL, 0);
  if (rc < 0)
    goto fail;
  rc = fcntl(s, F_SETFL, (rc | O_NONBLOCK));
  if (rc < 0)
    goto fail;
  memset(&sin6, 0, sizeof(sin6));
  sin6.sin6_family = AF_INET6;
  sin6.sin6_port = htons(port);
  rc = bind(s, (struct sockaddr *)&sin6, sizeof(sin6));
  if (rc < 0)
    goto fail;
  return s;
fail:
  saved_errno = errno;
  close(s);
  errno = saved_errno;
  return -1;
}


x86 assembly (clang, -O0):
<hn_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11cb <hn_socket+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e8 <hn_socket+0x268>
mov    -0x14(%rbp),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1208 <hn_socket+0x88>
lea    0xdfd(%rip),%rdi
call   1090 <perror@plt>
mov    -0x14(%rbp),%edi
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
mov    0x2ddd(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1245 <hn_socket+0xc5>
lea    0xdd9(%rip),%rdi
call   1090 <perror@plt>
mov    -0x14(%rbp),%edi
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1282 <hn_socket+0x102>
lea    0xdbc(%rip),%rdi
call   1090 <perror@plt>
mov    -0x14(%rbp),%edi
mov    0x2ce4(%rip),%rax
mov    (%rax),%esi
mov    0x2d53(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12c4 <hn_socket+0x144>
lea    0xd9f(%rip),%rdi
call   1090 <perror@plt>
jmp    13c1 <hn_socket+0x241>
mov    -0x14(%rbp),%edi
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12e9 <hn_socket+0x169>
jmp    13c1 <hn_socket+0x241>
mov    -0x14(%rbp),%edi
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
mov    0x2c99(%rip),%rax
or     (%rax),%edx
call   1040 <fcntl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1318 <hn_socket+0x198>
jmp    13c1 <hn_socket+0x241>
mov    -0x14(%rbp),%edi
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    133d <hn_socket+0x1bd>
jmp    13c1 <hn_socket+0x241>
mov    -0x14(%rbp),%edi
mov    0x2c59(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
mov    0x2c75(%rip),%rax
or     (%rax),%edx
call   1040 <fcntl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    136c <hn_socket+0x1ec>
jmp    13c1 <hn_socket+0x241>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1080 <bind@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13b6 <hn_socket+0x236>
jmp    13c1 <hn_socket+0x241>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13e8 <hn_socket+0x268>
mov    0x2bc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x1c(%rbp),%ecx
mov    0x2bb1(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hn_socket>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
movl   $0x1,(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    $0xffffffff,%r12d
test   %eax,%eax
js     1375 <hn_socket+0x1f5>
mov    %eax,%ebp
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
js     1322 <hn_socket+0x1a2>
mov    0x2d78(%rip),%rbx
mov    (%rbx),%esi
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
js     1333 <hn_socket+0x1b3>
mov    (%rbx),%esi
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
js     1344 <hn_socket+0x1c4>
mov    (%rbx),%esi
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
js     1355 <hn_socket+0x1d5>
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
js     1361 <hn_socket+0x1e1>
mov    0x2d24(%rip),%rcx
mov    (%rcx),%esi
mov    0x2d0b(%rip),%rcx
or     (%rcx),%eax
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
js     1361 <hn_socket+0x1e1>
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
js     1361 <hn_socket+0x1e1>
mov    0x2cdf(%rip),%rcx
mov    (%rcx),%esi
mov    0x2cfe(%rip),%rcx
or     (%rcx),%eax
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
js     1361 <hn_socket+0x1e1>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %r14d,%edi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x8,%edx
call   1080 <bind@plt>
test   %eax,%eax
js     1361 <hn_socket+0x1e1>
mov    %ebp,%r12d
jmp    1375 <hn_socket+0x1f5>
lea    0xcd7(%rip),%rdi
call   1090 <perror@plt>
jmp    11f1 <hn_socket+0x71>
lea    0xcdf(%rip),%rdi
call   1090 <perror@plt>
jmp    121d <hn_socket+0x9d>
lea    0xcee(%rip),%rdi
call   1090 <perror@plt>
jmp    1240 <hn_socket+0xc0>
lea    0xcfd(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c28(%rip),%r14
mov    (%r14),%ebx
mov    %ebp,%edi
call   1070 <close@plt>
mov    %ebx,(%r14)
mov    %r12d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@IPPROTO_IPV6 = global i32 0
@IPV6_MULTICAST_LOOP = global i32 0
@.str.1 = [32 x i8] c"setsockopt(IPV6_MULTICAST_LOOP)\00"
@IPV6_MULTICAST_HOPS = global i32 0
@.str.2 = [32 x i8] c"setsockopt(IPV6_MULTICAST_HOPS)\00"
@IPV6_RECVPKTINFO = global i32 0
@.str.3 = [29 x i8] c"setsockopt(IPV6_RECVPKTINFO)\00"
@F_GETFD = global i32 0
@F_SETFD = global i32 0
@FD_CLOEXEC = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@AF_INET6 = global i32 0
@errno = global i32 0
define i32 @hn_socket(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in6
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* @PF_INET6
%11 = load i32, i32* @SOCK_DGRAM
%12 = call i32 @socket(i32 %10, i32 %11, i32 0)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 -1, i32* %2
br label %106
16: ; preds = %1
%17 = load i32, i32* %5
%18 = load i32, i32* @SOL_SOCKET
%19 = load i32, i32* @SO_REUSEADDR
%20 = call i32 @setsockopt(i32 %17, i32 %18, i32 %19, i32* %8, i32 4)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %16
%26 = load i32, i32* %5
%27 = load i32, i32* @IPPROTO_IPV6
%28 = load i32, i32* @IPV6_MULTICAST_LOOP
%29 = call i32 @setsockopt(i32 %26, i32 %27, i32 %28, i32* %9, i32 4)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %25
%35 = load i32, i32* %5
%36 = load i32, i32* @IPPROTO_IPV6
%37 = load i32, i32* @IPV6_MULTICAST_HOPS
%38 = call i32 @setsockopt(i32 %35, i32 %36, i32 %37, i32* %8, i32 4)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %34
%44 = load i32, i32* %5
%45 = load i32, i32* @IPPROTO_IPV6
%46 = load i32, i32* @IPV6_RECVPKTINFO
%47 = call i32 @setsockopt(i32 %44, i32 %45, i32 %46, i32* %8, i32 4)
store i32 %47, i32* %6
%48 = load i32, i32* %6
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %101
52: ; preds = %43
%53 = load i32, i32* %5
%54 = load i32, i32* @F_GETFD
%55 = call i32 @fcntl(i32 %53, i32 %54, i32 0)
store i32 %55, i32* %6
%56 = load i32, i32* %6
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %52
br label %101
59: ; preds = %52
%60 = load i32, i32* %5
%61 = load i32, i32* @F_SETFD
%62 = load i32, i32* %6
%63 = load i32, i32* @FD_CLOEXEC
%64 = or i32 %62, %63
%65 = call i32 @fcntl(i32 %60, i32 %61, i32 %64)
store i32 %65, i32* %6
%66 = load i32, i32* %6
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %59
br label %101
69: ; preds = %59
%70 = load i32, i32* %5
%71 = load i32, i32* @F_GETFL
%72 = call i32 @fcntl(i32 %70, i32 %71, i32 0)
store i32 %72, i32* %6
%73 = load i32, i32* %6
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %69
br label %101
76: ; preds = %69
%77 = load i32, i32* %5
%78 = load i32, i32* @F_SETFL
%79 = load i32, i32* %6
%80 = load i32, i32* @O_NONBLOCK
%81 = or i32 %79, %80
%82 = call i32 @fcntl(i32 %77, i32 %78, i32 %81)
store i32 %82, i32* %6
%83 = load i32, i32* %6
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %76
br label %101
86: ; preds = %76
%87 = call i32 @memset(%struct.sockaddr_in6* %4, i32 0, i32 8)
%88 = load i32, i32* @AF_INET6
%89 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i32 0, i32 1
store i32 %88, i32* %89
%90 = load i32, i32* %3
%91 = call i32 @htons(i32 %90)
%92 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i32 0, i32 0
store i32 %91, i32* %92
%93 = load i32, i32* %5
%94 = bitcast %struct.sockaddr_in6* %4 to %struct.sockaddr*
%95 = call i32 @bind(i32 %93, %struct.sockaddr* %94, i32 8)
store i32 %95, i32* %6
%96 = load i32, i32* %6
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %86
br label %101
99: ; preds = %86
%100 = load i32, i32* %5
store i32 %100, i32* %2
br label %106
101: ; preds = %98, %85, %75, %68, %58, %50
%102 = load i32, i32* @errno
store i32 %102, i32* %7
%103 = load i32, i32* %5
%104 = call i32 @close(i32 %103)
%105 = load i32, i32* %7
store i32 %105, i32* @errno
store i32 -1, i32* %2
br label %106
106: ; preds = %101, %99, %15
%107 = load i32, i32* %2
ret i32 %107
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@IPPROTO_IPV6 = global i32 0
@IPV6_MULTICAST_LOOP = global i32 0
@.str.1 = [32 x i8] c"setsockopt(IPV6_MULTICAST_LOOP)\00"
@IPV6_MULTICAST_HOPS = global i32 0
@.str.2 = [32 x i8] c"setsockopt(IPV6_MULTICAST_HOPS)\00"
@IPV6_RECVPKTINFO = global i32 0
@.str.3 = [29 x i8] c"setsockopt(IPV6_RECVPKTINFO)\00"
@F_GETFD = global i32 0
@F_SETFD = global i32 0
@FD_CLOEXEC = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@AF_INET6 = global i32 0
@errno = global i32 0
define i32 @hn_socket(i32 %0) {
%2 = alloca %struct.sockaddr_in6
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.sockaddr_in6* %2 to i8*
%6 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = load i32, i32* @PF_INET6
%9 = load i32, i32* @SOCK_DGRAM
%10 = tail call i32 @socket(i32 %8, i32 %9, i32 0)
%11 = icmp slt i32 %10, 0
br i1 %11, label %72, label %12
12: ; preds = %1
%13 = load i32, i32* @SOL_SOCKET
%14 = load i32, i32* @SO_REUSEADDR
%15 = call i32 @setsockopt(i32 %10, i32 %13, i32 %14, i32* %3, i32 4)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = load i32, i32* @IPPROTO_IPV6
%21 = load i32, i32* @IPV6_MULTICAST_LOOP
%22 = call i32 @setsockopt(i32 %10, i32 %20, i32 %21, i32* %4, i32 4)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = load i32, i32* @IPPROTO_IPV6
%28 = load i32, i32* @IPV6_MULTICAST_HOPS
%29 = call i32 @setsockopt(i32 %10, i32 %27, i32 %28, i32* %3, i32 4)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %26
%34 = load i32, i32* @IPPROTO_IPV6
%35 = load i32, i32* @IPV6_RECVPKTINFO
%36 = call i32 @setsockopt(i32 %10, i32 %34, i32 %35, i32* %3, i32 4)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %69
40: ; preds = %33
%41 = load i32, i32* @F_GETFD
%42 = call i32 @fcntl(i32 %10, i32 %41, i32 0)
%43 = icmp slt i32 %42, 0
br i1 %43, label %69, label %44
44: ; preds = %40
%45 = load i32, i32* @F_SETFD
%46 = load i32, i32* @FD_CLOEXEC
%47 = or i32 %46, %42
%48 = call i32 @fcntl(i32 %10, i32 %45, i32 %47)
%49 = icmp slt i32 %48, 0
br i1 %49, label %69, label %50
50: ; preds = %44
%51 = load i32, i32* @F_GETFL
%52 = call i32 @fcntl(i32 %10, i32 %51, i32 0)
%53 = icmp slt i32 %52, 0
br i1 %53, label %69, label %54
54: ; preds = %50
%55 = load i32, i32* @F_SETFL
%56 = load i32, i32* @O_NONBLOCK
%57 = or i32 %56, %52
%58 = call i32 @fcntl(i32 %10, i32 %55, i32 %57)
%59 = icmp slt i32 %58, 0
br i1 %59, label %69, label %60
60: ; preds = %54
%61 = call i32 @memset(%struct.sockaddr_in6* %2, i32 0, i32 8)
%62 = load i32, i32* @AF_INET6
%63 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %2, i64 0, i32 1
store i32 %62, i32* %63
%64 = call i32 @htons(i32 %0)
%65 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %2, i64 0, i32 0
store i32 %64, i32* %65
%66 = bitcast %struct.sockaddr_in6* %2 to %struct.sockaddr*
%67 = call i32 @bind(i32 %10, %struct.sockaddr* %66, i32 8)
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %60, %54, %50, %44, %40, %38
%70 = load i32, i32* @errno
%71 = call i32 @close(i32 %10)
store i32 %70, i32* @errno
br label %72
72: ; preds = %60, %1, %69
%73 = phi i32 [ -1, %69 ], [ -1, %1 ], [ %10, %60 ]
ret i32 %73
}