#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sa;
typedef int /*<<< orphan*/ reuseaddr;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int AI_ADDRCONFIG;
int AI_PASSIVE;
scalar_t__ EINTR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SOMAXCONN;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ handle_session(int);
char *inet_ntoa(int /*<<< orphan*/);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  const char *hostname = 0;
  const char *portname = "mysql-proxy";
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = 0;
  hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
  struct addrinfo *res = 0;
  int err = getaddrinfo(hostname, portname, &hints, &res);
  if (err != 0)
    perror("failed to resolve local socket address (err=%d)");
  int server_fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if (server_fd == -1)
    perror("%s");
  int reuseaddr = 1;
  if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
                 sizeof(reuseaddr)) == -1)
    perror("%s");
  if (bind(server_fd, res->ai_addr, res->ai_addrlen) == -1)
    perror("%s");
  freeaddrinfo(res);
  if (listen(server_fd, SOMAXCONN))
    perror("failed to listen for connections (errno=%d)");
  while (1) {
    struct sockaddr_in sa;
    socklen_t sa_len = sizeof(sa);
    int session_fd = accept(server_fd, (struct sockaddr *)&sa, &sa_len);
    if (session_fd == -1) {
      if (errno == EINTR)
        continue;
      perror("failed to accept connection (errno=%d)");
    }
    fprintf(stderr, "Server: connect from host %s, port %hd.\n",
            inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
    handle_session(session_fd);
    close(session_fd);
    close(server_fd);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xde8(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    0x2d34(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1297 <main+0xa7>
lea    0xd7a(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    12cb <main+0xdb>
lea    0xd76(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x50(%rbp),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    0x2cbb(%rip),%rax
mov    (%rax),%edx
lea    -0x54(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    130b <main+0x11b>
lea    0xd36(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x50(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1336 <main+0x146>
lea    0xd0b(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x48(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x50(%rbp),%edi
mov    0x2c77(%rip),%rax
mov    (%rax),%esi
call   1080 <listen@plt>
cmp    $0x0,%rax
je     1366 <main+0x176>
lea    0xcde(%rip),%rdi
call   10b0 <perror@plt>
jmp    136b <main+0x17b>
movl   $0x8,-0x64(%rbp)
mov    -0x50(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x64(%rbp),%rdx
call   10c0 <accept@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    13ba <main+0x1ca>
mov    0x2c1a(%rip),%rax
mov    (%rax),%rax
mov    0x2c08(%rip),%rcx
cmp    (%rcx),%rax
jne    13ae <main+0x1be>
jmp    136b <main+0x17b>
lea    0xcb6(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x60(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x70(%rbp)
mov    -0x5c(%rbp),%edi
call   1090 <ntohs@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %eax,%ecx
lea    0xca8(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x68(%rbp),%edi
call   10f0 <handle_session@plt>
mov    -0x68(%rbp),%edi
call   1060 <close@plt>
mov    -0x50(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x44(%rsp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
movq   $0x0,0x38(%rsp)
mov    0x2da4(%rip),%rax
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x28(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xda5(%rip),%rsi
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     127a <main+0x8a>
lea    0xd97(%rip),%rdi
call   10b0 <perror@plt>
mov    0x10(%rsp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    12a2 <main+0xb2>
lea    0xd9f(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,0x24(%rsp)
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
mov    0x2ce6(%rip),%rax
mov    (%rax),%edx
lea    0x24(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12e0 <main+0xf0>
lea    0xd61(%rip),%rdi
call   10b0 <perror@plt>
mov    0x10(%rsp),%rax
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    %r14d,%edi
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1304 <main+0x114>
lea    0xd3d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x10(%rsp),%rdi
call   1100 <freeaddrinfo@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1080 <listen@plt>
test   %rax,%rax
je     1330 <main+0x140>
lea    0xd14(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x8,0xc(%rsp)
lea    0x18(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r14d,%edi
call   10c0 <accept@plt>
cmp    $0xffffffff,%eax
jne    1395 <main+0x1a5>
mov    0x2c5a(%rip),%r12
mov    0x2c4b(%rip),%r13
lea    0x18(%rsp),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    (%r12),%rax
cmp    0x0(%r13),%rax
jne    1399 <main+0x1a9>
movl   $0x8,0xc(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10c0 <accept@plt>
cmp    $0xffffffff,%eax
je     1370 <main+0x180>
mov    %eax,%ebp
jmp    13aa <main+0x1ba>
lea    0xccb(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%ebp
mov    0x2c17(%rip),%rax
mov    (%rax),%r15d
mov    0x18(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rbx
mov    0x1c(%rsp),%edi
call   1090 <ntohs@plt>
lea    0xcc2(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1070 <fprintf@plt>
mov    %ebp,%edi
call   10f0 <handle_session@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i64, i32, i32 }
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"mysql-proxy\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [48 x i8] c"failed to resolve local socket address (err=%d)\00"
@.str.2 = [3 x i8] c"%s\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@SOMAXCONN = global i32 0
@.str.3 = [44 x i8] c"failed to listen for connections (errno=%d)\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.4 = [39 x i8] c"failed to accept connection (errno=%d)\00"
@stderr = global i32 0
@.str.5 = [41 x i8] c"Server: connect from host %s, port %hd.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %7
%16 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 32)
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %19, i32* %20
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i64 0, i64* %21
%22 = load i32, i32* @AI_PASSIVE
%23 = load i32, i32* @AI_ADDRCONFIG
%24 = or i32 %22, %23
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 0
store i32 %24, i32* %25
store %struct.addrinfo* null, %struct.addrinfo** %9
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = call i32 @getaddrinfo(i8* %26, i8* %27, %struct.addrinfo* %8, %struct.addrinfo** %9)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %2
%34 = load %struct.addrinfo*, %struct.addrinfo** %9
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i32 0, i32 5
%36 = load i32, i32* %35
%37 = load %struct.addrinfo*, %struct.addrinfo** %9
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i32 0, i32 4
%39 = load i32, i32* %38
%40 = load %struct.addrinfo*, %struct.addrinfo** %9
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 3
%42 = load i64, i64* %41
%43 = call i32 @socket(i32 %36, i32 %39, i64 %42)
store i32 %43, i32* %11
%44 = load i32, i32* %11
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %33
%47 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46, %33
store i32 1, i32* %12
%49 = load i32, i32* %11
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_REUSEADDR
%52 = call i32 @setsockopt(i32 %49, i32 %50, i32 %51, i32* %12, i32 4)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %56
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %48
%57 = load i32, i32* %11
%58 = load %struct.addrinfo*, %struct.addrinfo** %9
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 2
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %9
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 1
%63 = load i32, i32* %62
%64 = call i32 @bind(i32 %57, i32 %60, i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %68
66: ; preds = %56
%67 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %68
68: ; preds = %66, %56
%69 = load %struct.addrinfo*, %struct.addrinfo** %9
%70 = call i32 @freeaddrinfo(%struct.addrinfo* %69)
%71 = load i32, i32* %11
%72 = load i32, i32* @SOMAXCONN
%73 = call i64 @listen(i32 %71, i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %68
%76 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %75, %68
br label %78
78: ; preds = %77, %88
store i32 8, i32* %14
%79 = load i32, i32* %11
%80 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%81 = call i32 @accept(i32 %79, %struct.sockaddr* %80, i32* %14)
store i32 %81, i32* %15
%82 = load i32, i32* %15
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %91
84: ; preds = %78
%85 = load i64, i64* @errno
%86 = load i64, i64* @EINTR
%87 = icmp eq i64 %85, %86
br i1 %87, label %88, label %89
88: ; preds = %84
br label %78
89: ; preds = %84
%90 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %91
91: ; preds = %89, %78
%92 = load i32, i32* @stderr
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i8* @inet_ntoa(i32 %94)
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%97 = load i32, i32* %96
%98 = call i32 @ntohs(i32 %97)
%99 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %95, i32 %98)
%100 = load i32, i32* %15
%101 = call i32 @handle_session(i32 %100)
%102 = load i32, i32* %15
%103 = call i32 @close(i32 %102)
%104 = load i32, i32* %11
%105 = call i32 @close(i32 %104)
%106 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i64, i32, i32 }
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"mysql-proxy\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [48 x i8] c"failed to resolve local socket address (err=%d)\00"
@.str.2 = [3 x i8] c"%s\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@SOMAXCONN = global i32 0
@.str.3 = [44 x i8] c"failed to listen for connections (errno=%d)\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.4 = [39 x i8] c"failed to accept connection (errno=%d)\00"
@stderr = global i32 0
@.str.5 = [41 x i8] c"Server: connect from host %s, port %hd.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = bitcast %struct.addrinfo* %3 to i8*
%9 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%10 = load i32, i32* @AF_UNSPEC
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %10, i32* %11
%12 = load i32, i32* @SOCK_STREAM
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i64 0, i64* %14
%15 = load i32, i32* @AI_PASSIVE
%16 = load i32, i32* @AI_ADDRCONFIG
%17 = or i32 %16, %15
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i32 %17, i32* %18
%19 = bitcast %struct.addrinfo** %4 to i8*
store %struct.addrinfo* null, %struct.addrinfo** %4
%20 = call i32 @getaddrinfo(i8* null, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %2
%23 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %2
%25 = load %struct.addrinfo*, %struct.addrinfo** %4
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %25, i64 0, i32 5
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %25, i64 0, i32 4
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %25, i64 0, i32 3
%31 = load i64, i64* %30
%32 = call i32 @socket(i32 %27, i32 %29, i64 %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %24
%37 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_REUSEADDR
%40 = call i32 @setsockopt(i32 %32, i32 %38, i32 %39, i32* %5, i32 4)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
%45 = load %struct.addrinfo*, %struct.addrinfo** %4
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 2
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 1
%49 = load i32, i32* %48
%50 = call i32 @bind(i32 %32, i32 %47, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %44
%55 = load %struct.addrinfo*, %struct.addrinfo** %4
%56 = call i32 @freeaddrinfo(%struct.addrinfo* %55)
%57 = load i32, i32* @SOMAXCONN
%58 = call i64 @listen(i32 %32, i32 %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %54
%61 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %60, %54
%63 = bitcast %struct.sockaddr_in* %6 to i8*
%64 = bitcast i32* %7 to i8*
%65 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
store i32 8, i32* %7
%66 = call i32 @accept(i32 %32, %struct.sockaddr* %65, i32* %7)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %77
68: ; preds = %62, %72
%69 = load i64, i64* @errno
%70 = load i64, i64* @EINTR
%71 = icmp eq i64 %69, %70
br i1 %71, label %72, label %75
72: ; preds = %68
store i32 8, i32* %7
%73 = call i32 @accept(i32 %32, %struct.sockaddr* %65, i32* %7)
%74 = icmp eq i32 %73, -1
br i1 %74, label %68, label %77
75: ; preds = %68
%76 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %77
77: ; preds = %72, %62, %75
%78 = phi i32 [ -1, %75 ], [ %66, %62 ], [ %73, %72 ]
%79 = load i32, i32* @stderr
%80 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%81 = load i32, i32* %80
%82 = call i8* @inet_ntoa(i32 %81)
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
%84 = load i32, i32* %83
%85 = call i32 @ntohs(i32 %84)
%86 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %82, i32 %85)
%87 = call i32 @handle_session(i32 %78)
%88 = call i32 @close(i32 %78)
%89 = call i32 @close(i32 %32)
%90 = call i32 @exit(i32 0)
unreachable
}