#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ client_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
unsigned int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int daemonize();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned int);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  int listenfd, connfd;
  struct sockaddr_in client_addr, server_addr;
  socklen_t client_addr_len, server_addr_len;
  unsigned int port_number;
  char *str = "Daemon - laboratorium PUS\n";
  int socket_option;
  if (argc != 2) {
    fprintf(stderr, "Invocation: %s <PORT>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  port_number = atoi(argv[1]);
  listenfd = socket(PF_INET, SOCK_STREAM, 0);
  if (listenfd == -1) {
    perror("socket()");
    exit(EXIT_FAILURE);
  }
  socket_option = 1;
  if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &socket_option,
                 sizeof(int)) == -1) {
    perror("setsockopt()");
    exit(EXIT_FAILURE);
  }
  memset(&server_addr, 0, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  server_addr.sin_port = htons(port_number);
  server_addr_len = sizeof(server_addr);
  fprintf(stdout, "Binding to port %u...\n", port_number);
  if (bind(listenfd, (struct sockaddr *)&server_addr, server_addr_len) == -1) {
    perror("bind()");
    exit(EXIT_FAILURE);
  }
  if (listen(listenfd, 2) == -1) {
    perror("listen()");
    exit(EXIT_FAILURE);
  }
  fprintf(stdout, "Server is listening for incoming connection...\n");
  if (daemonize() == -1) {
    fprintf(stderr, "daemon() failed!\n");
    exit(EXIT_FAILURE);
  }
  client_addr_len = sizeof(client_addr);
  connfd = accept(listenfd, (struct sockaddr *)&client_addr, &client_addr_len);
  if (connfd == -1) {
    exit(EXIT_FAILURE);
  }
  if (send(connfd, str, strlen(str), 0) == -1) {
    exit(EXIT_FAILURE);
  }
  close(connfd);
  close(listenfd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xde3(%rip),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1257 <main+0x57>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12a7 <main+0xa7>
lea    0xd9e(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d30(%rip),%rax
mov    (%rax),%esi
mov    0x2cd7(%rip),%rax
mov    (%rax),%edx
lea    -0x54(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12f5 <main+0xf5>
lea    0xd59(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x44(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x38(%rbp)
movl   $0xc,-0x40(%rbp)
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1380 <main+0x180>
lea    0xcf2(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    13b0 <main+0x1b0>
lea    0xcc9(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1040 <daemonize@plt>
cmp    $0xffffffff,%eax
jne    13fc <main+0x1fc>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
movl   $0xc,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    142e <main+0x22e>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    146c <main+0x26c>
mov    0x2b4b(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    0x2b1d(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jne    1246 <main+0x46>
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebp
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
jne    126e <main+0x6e>
lea    0xdf3(%rip),%rdi
call   10e0 <perror@plt>
jmp    1260 <main+0x60>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdc2(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    %eax,%ebx
movl   $0x1,(%rsp)
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12ac <main+0xac>
lea    0xd96(%rip),%rdi
call   10e0 <perror@plt>
jmp    1260 <main+0x60>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %eax,0x8(%rsp)
mov    0x2cb7(%rip),%r15
mov    (%r15),%edi
lea    0xd4d(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1329 <main+0x129>
lea    0xd40(%rip),%rdi
call   10e0 <perror@plt>
jmp    1260 <main+0x60>
mov    %ebx,%edi
mov    $0x2,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    134b <main+0x14b>
lea    0xd25(%rip),%rdi
call   10e0 <perror@plt>
jmp    1260 <main+0x60>
mov    (%r15),%edi
lea    0xd1a(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1040 <daemonize@plt>
cmp    $0xffffffff,%eax
jne    1384 <main+0x184>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
lea    0xd27(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1260 <main+0x60>
movl   $0xc,0x4(%rsp)
lea    0x18(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
call   10f0 <accept@plt>
cmp    $0xffffffff,%eax
je     1260 <main+0x60>
mov    %eax,%ebp
lea    0xc51(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     1260 <main+0x60>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [27 x i8] c"Daemon - laboratorium PUS\0A\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Invocation: %s <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [9 x i8] c"socket()\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [13 x i8] c"setsockopt()\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@stdout = global i32 0
@.str.4 = [23 x i8] c"Binding to port %u...\0A\00"
@.str.5 = [7 x i8] c"bind()\00"
@.str.6 = [9 x i8] c"listen()\00"
@.str.7 = [48 x i8] c"Server is listening for incoming connection...\0A\00"
@.str.8 = [18 x i8] c"daemon() failed!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %13
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %12
%30 = load i32, i32* @PF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %25
%36 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %25
store i32 1, i32* %14
%40 = load i32, i32* %6
%41 = load i32, i32* @SOL_SOCKET
%42 = load i32, i32* @SO_REUSEADDR
%43 = call i32 @setsockopt(i32 %40, i32 %41, i32 %42, i32* %14, i32 4)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %39
%50 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %51, i32* %52
%53 = load i32, i32* @INADDR_ANY
%54 = call i32 @htonl(i32 %53)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i32 %54, i32* %56
%57 = load i32, i32* %12
%58 = call i32 @htons(i32 %57)
%59 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %58, i32* %59
store i32 12, i32* %11
%60 = load i32, i32* @stdout
%61 = load i32, i32* %12
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %6
%64 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%65 = load i32, i32* %11
%66 = call i32 @bind(i32 %63, %struct.sockaddr* %64, i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %72
68: ; preds = %49
%69 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %49
%73 = load i32, i32* %6
%74 = call i32 @listen(i32 %73, i32 2)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %72
%81 = load i32, i32* @stdout
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0))
%83 = call i32 (...) @daemonize()
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %90
85: ; preds = %80
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %80
store i32 12, i32* %10
%91 = load i32, i32* %6
%92 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%93 = call i32 @accept(i32 %91, %struct.sockaddr* %92, i32* %10)
store i32 %93, i32* %7
%94 = load i32, i32* %7
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %99
96: ; preds = %90
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %90
%100 = load i32, i32* %7
%101 = load i8*, i8** %13
%102 = load i8*, i8** %13
%103 = call i32 @strlen(i8* %102)
%104 = call i32 @send(i32 %100, i8* %101, i32 %103, i32 0)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %109
106: ; preds = %99
%107 = load i32, i32* @EXIT_FAILURE
%108 = call i32 @exit(i32 %107)
unreachable
109: ; preds = %99
%110 = load i32, i32* %7
%111 = call i32 @close(i32 %110)
%112 = load i32, i32* %6
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* @EXIT_SUCCESS
%115 = call i32 @exit(i32 %114)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [27 x i8] c"Daemon - laboratorium PUS\0A\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Invocation: %s <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [9 x i8] c"socket()\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [13 x i8] c"setsockopt()\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@stdout = global i32 0
@.str.4 = [23 x i8] c"Binding to port %u...\0A\00"
@.str.5 = [7 x i8] c"bind()\00"
@.str.6 = [9 x i8] c"listen()\00"
@.str.7 = [48 x i8] c"Server is listening for incoming connection...\0A\00"
@.str.8 = [18 x i8] c"daemon() failed!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %18, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = load i32, i32* @PF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = tail call i32 @socket(i32 %22, i32 %23, i32 0)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %30
26: ; preds = %18
%27 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %18
store i32 1, i32* %6
%31 = load i32, i32* @SOL_SOCKET
%32 = load i32, i32* @SO_REUSEADDR
%33 = call i32 @setsockopt(i32 %24, i32 %31, i32 %32, i32* %6, i32 4)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %30
%40 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%41 = load i32, i32* @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %41, i32* %42
%43 = load i32, i32* @INADDR_ANY
%44 = call i32 @htonl(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %44, i32* %45
%46 = call i32 @htons(i32 %21)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* @stdout
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%50 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%51 = call i32 @bind(i32 %24, %struct.sockaddr* %50, i32 12)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %57
53: ; preds = %39
%54 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %39
%58 = call i32 @listen(i32 %24, i32 2)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %57
%65 = load i32, i32* @stdout
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0))
%67 = call i32 (...) @daemonize()
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %74
69: ; preds = %64
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %64
store i32 12, i32* %5
%75 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%76 = call i32 @accept(i32 %24, %struct.sockaddr* %75, i32* %5)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %74
%82 = call i32 @strlen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%83 = call i32 @send(i32 %76, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %82, i32 0)
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %81
%89 = call i32 @close(i32 %76)
%90 = call i32 @close(i32 %24)
%91 = load i32, i32* @EXIT_SUCCESS
%92 = call i32 @exit(i32 %91)
unreachable
}