#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 */
typedef int /*<<< orphan*/ v6only;
struct sockaddr_in6 {
  int sin6_family;
  int /*<<< orphan*/ sin6_addr;
  int /*<<< orphan*/ sin6_port;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int sin_family;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ reuseaddr;
typedef int /*<<< orphan*/ addr6;
typedef int /*<<< orphan*/ addr4;

/* Variables and functions */
int AF_INET;
int AF_INET6;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IPV6;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ IPV6_V6ONLY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ in6addr_any;
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open_port(int ipv6, int any) {
  int fd = -1;
  int reuseaddr = 1;
  int v6only = 1;
  int addrlen;
  int ret = -1;
  struct sockaddr *addr;
  int family = ipv6 ? AF_INET6 : AF_INET;
  struct sockaddr_in6 addr6 = {.sin6_family = AF_INET6,
                               .sin6_port = htons(9999),
                               .sin6_addr = in6addr_any};
  struct sockaddr_in addr4 = {
      .sin_family = AF_INET,
      .sin_port = htons(9999),
      .sin_addr.s_addr = any ? htonl(INADDR_ANY) : inet_addr("127.0.0.1"),
  };
  if (ipv6) {
    addr = (struct sockaddr *)&addr6;
    addrlen = sizeof(addr6);
  } else {
    addr = (struct sockaddr *)&addr4;
    addrlen = sizeof(addr4);
  }
  if ((fd = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    perror("socket");
    goto out;
  }
  if (ipv6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&v6only,
                         sizeof(v6only)) < 0) {
    perror("setsockopt IPV6_V6ONLY");
    goto out;
  }
  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)) <
      0) {
    perror("setsockopt SO_REUSEADDR");
    goto out;
  }
  if (bind(fd, addr, addrlen) < 0) {
    perror("bind");
    goto out;
  }
  if (any)
    return fd;
  if (listen(fd, 1) < 0) {
    perror("listen");
    goto out;
  }
  return fd;
out:
  close(fd);
  return ret;
}


x86 assembly (clang, -O0):
<open_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0xffffffff,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11d5 <open_port+0x45>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    11e1 <open_port+0x51>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x270f,%edi
call   1040 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
lea    -0x48(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1244 <open_port+0xb4>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x5c(%rbp)
jmp    1253 <open_port+0xc3>
lea    0xdb5(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    %ecx,(%rax)
mov    $0x270f,%edi
call   1040 <htons@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1287 <open_port+0xf7>
lea    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0xc,-0x1c(%rbp)
jmp    1296 <open_port+0x106>
lea    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0xc,-0x1c(%rbp)
mov    -0x2c(%rbp),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
mov    0x2d1f(%rip),%rax
mov    (%rax),%edx
call   10b0 <socket@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    12cd <open_port+0x13d>
lea    0xd47(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c7 <open_port+0x237>
cmpl   $0x0,-0x8(%rbp)
je     1316 <open_port+0x186>
mov    -0x10(%rbp),%edi
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
mov    0x2cbe(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1316 <open_port+0x186>
lea    0xd05(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c7 <open_port+0x237>
mov    -0x10(%rbp),%edi
mov    0x2cc0(%rip),%rax
mov    (%rax),%esi
mov    0x2c6f(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1355 <open_port+0x1c5>
lea    0xcdd(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c7 <open_port+0x237>
mov    -0x10(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <bind@plt>
cmp    $0x0,%rax
jge    137f <open_port+0x1ef>
lea    0xccb(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c7 <open_port+0x237>
cmpl   $0x0,-0xc(%rbp)
je     1394 <open_port+0x204>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13d5 <open_port+0x245>
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1080 <listen@plt>
cmp    $0x0,%rax
jge    13bc <open_port+0x22c>
lea    0xc93(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c7 <open_port+0x237>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13d5 <open_port+0x245>
mov    -0x10(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_port>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %edi,%r15d
movl   $0x1,0x4(%rsp)
movl   $0x1,(%rsp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    0x2e19(%rip),%rbx
mov    %eax,%ebp
test   %edi,%edi
jne    11c7 <open_port+0x37>
mov    (%rbx),%ebp
mov    %eax,0x18(%rsp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    $0x270f,%edi
call   1040 <htons@plt>
mov    %eax,0x20(%rsp)
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
test   %r14d,%r14d
je     1201 <open_port+0x71>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
jmp    120d <open_port+0x7d>
lea    0xdf8(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    $0x270f,%edi
call   1040 <htons@plt>
test   %r15d,%r15d
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%rax
lea    0x18(%rsp),%rbx
cmove  %rax,%rbx
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   10b0 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12db <open_port+0x14b>
test   %r15d,%r15d
je     127f <open_port+0xef>
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     12f6 <open_port+0x166>
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     12e4 <open_port+0x154>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
test   %rax,%rax
js     12ed <open_port+0x15d>
test   %r14d,%r14d
jne    130e <open_port+0x17e>
mov    %ebp,%edi
mov    $0x1,%esi
call   1080 <listen@plt>
test   %rax,%rax
jns    130e <open_port+0x17e>
lea    0xd6c(%rip),%rdi
jmp    12fd <open_port+0x16d>
lea    0xd28(%rip),%rdi
jmp    12fd <open_port+0x16d>
lea    0xd3d(%rip),%rdi
jmp    12fd <open_port+0x16d>
lea    0xd4c(%rip),%rdi
jmp    12fd <open_port+0x16d>
lea    0xd14(%rip),%rdi
call   10a0 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@AF_INET = global i32 0
@in6addr_any = global i32 0
@INADDR_ANY = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@IPPROTO_IPV6 = global i32 0
@IPV6_V6ONLY = global i32 0
@.str.2 = [23 x i8] c"setsockopt IPV6_V6ONLY\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [24 x i8] c"setsockopt SO_REUSEADDR\00"
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"listen\00"
define i32 @open_port(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in6
%6 = alloca %struct.sockaddr_in
%7 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%9 = icmp eq i32 %0, 0
%10 = load i32, i32* @AF_INET6
%11 = load i32, i32* @AF_INET
%12 = select i1 %9, i32 %11, i32 %10
%13 = bitcast %struct.sockaddr_in6* %5 to i8*
%14 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 0
store i32 %10, i32* %14
%15 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 1
%16 = load i32, i32* @in6addr_any
store i32 %16, i32* %15
%17 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 2
%18 = tail call i32 @htons(i32 9999)
store i32 %18, i32* %17
%19 = bitcast %struct.sockaddr_in* %6 to i8*
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%21 = load i32, i32* @AF_INET
store i32 %21, i32* %20
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
%23 = icmp eq i32 %1, 0
br i1 %23, label %27, label %24
24: ; preds = %2
%25 = load i32, i32* @INADDR_ANY
%26 = tail call i32 @htonl(i32 %25)
br label %29
27: ; preds = %2
%28 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %26, %24 ], [ %28, %27 ]
store i32 %30, i32* %22
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
%32 = tail call i32 @htons(i32 9999)
store i32 %32, i32* %31
%33 = bitcast %struct.sockaddr_in6* %5 to %struct.sockaddr*
%34 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%35 = select i1 %9, %struct.sockaddr* %34, %struct.sockaddr* %33
%36 = load i32, i32* @SOCK_STREAM
%37 = load i32, i32* @IPPROTO_TCP
%38 = tail call i32 @socket(i32 %12, i32 %36, i32 %37)
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %68
42: ; preds = %29
br i1 %9, label %50, label %43
43: ; preds = %42
%44 = load i32, i32* @IPPROTO_IPV6
%45 = load i32, i32* @IPV6_V6ONLY
%46 = call i64 @setsockopt(i32 %38, i32 %44, i32 %45, i32* %4, i32 4)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %68
50: ; preds = %43, %42
%51 = load i32, i32* @SOL_SOCKET
%52 = load i32, i32* @SO_REUSEADDR
%53 = call i64 @setsockopt(i32 %38, i32 %51, i32 %52, i32* %3, i32 4)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %68
57: ; preds = %50
%58 = call i64 @bind(i32 %38, %struct.sockaddr* %35, i32 12)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %68
62: ; preds = %57
br i1 %23, label %63, label %70
63: ; preds = %62
%64 = call i64 @listen(i32 %38, i32 1)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %60, %55, %48, %40
%69 = call i32 @close(i32 %38)
br label %70
70: ; preds = %63, %62, %68
%71 = phi i32 [ -1, %68 ], [ %38, %62 ], [ %38, %63 ]
ret i32 %71
}