#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_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ listen(int, int);
char *malloc(int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, int *, int, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int server(char *port, int pings, int size) {
  printf("starting server\n");
  struct addrinfo hints, *res;
  int error, server_socket;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  error = getaddrinfo(NULL, port, &hints, &res);
  if (error) {
    printf("server error: %s\n", gai_strerror(error));
    return -1;
  }
  server_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if (server_socket < 0) {
    printf("server error: could not create socket\n");
    return -1;
  }
  int yes = 1;
  if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) <
      0) {
    printf("server error: could not set socket options\n");
    return -1;
  }
  if (bind(server_socket, res->ai_addr, res->ai_addrlen) < 0) {
    printf("server error: could not bind to socket\n");
    return -1;
  }
  listen(server_socket, 5);
  int client_socket;
  struct sockaddr_storage client_addr;
  socklen_t addr_size;
  client_socket =
      accept(server_socket, (struct sockaddr *)&client_addr, &addr_size);
  int i = 0, counter = 0;
  for (i = 0; i < pings; i++) {
    char *buf = malloc(size);
    ssize_t read = 0;
    for (; size - read;)
      read += recv(client_socket, buf, size - read, 0);
    counter++;
    free(buf);
  }
  size_t sent = 0;
  for (; sizeof(int) - sent;)
    sent += send(client_socket, &counter, sizeof(int) - sent, 0);
  freeaddrinfo(res);
  return 0;
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     127e <server+0x9e>
mov    -0x3c(%rbp),%edi
call   1080 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1441 <server+0x261>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    12bf <server+0xdf>
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1441 <server+0x261>
movl   $0x1,-0x44(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
mov    0x2ce7(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
jge    130e <server+0x12e>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1441 <server+0x261>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    1347 <server+0x167>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1441 <server+0x261>
mov    -0x40(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
mov    -0x40(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13f0 <server+0x210>
mov    -0x18(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x6c(%rbp),%eax
cmp    $0x0,%eax
je     13d0 <server+0x1f0>
mov    -0x48(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x18(%rbp),%edx
sub    -0x6c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %rax,%rcx
movslq -0x6c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x6c(%rbp)
jmp    139b <server+0x1bb>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    137c <server+0x19c>
movq   $0x0,-0x78(%rbp)
mov    $0x4,%eax
sub    -0x78(%rbp),%rax
cmp    $0x0,%rax
je     1431 <server+0x251>
mov    -0x48(%rbp),%edi
mov    $0x4,%eax
sub    -0x78(%rbp),%rax
mov    %eax,%edx
lea    -0x5c(%rbp),%rsi
xor    %ecx,%ecx
call   1060 <send@plt>
add    -0x78(%rbp),%rax
mov    %rax,-0x78(%rbp)
jmp    13f8 <server+0x218>
mov    -0x38(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xe04(%rip),%rdi
call   1050 <puts@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
lea    0x8(%rsp),%rcx
xor    %edi,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
je     1281 <server+0x91>
mov    %eax,%edi
call   1090 <gai_strerror@plt>
lea    0xd8e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    13c0 <server+0x1d0>
mov    0x8(%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   1110 <socket@plt>
test   %eax,%eax
js     1368 <server+0x178>
mov    %eax,%ebp
movl   $0x1,0x14(%rsp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
mov    0x2d0a(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
test   %rax,%rax
js     13ab <server+0x1bb>
mov    0x8(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   10d0 <bind@plt>
test   %rax,%rax
js     13b4 <server+0x1c4>
mov    %ebp,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
lea    0x18(%rsp),%rsi
lea    0x1c(%rsp),%rdx
mov    %ebp,%edi
call   10e0 <accept@plt>
mov    %eax,%r13d
movl   $0x0,0x4(%rsp)
test   %r14d,%r14d
jle    1371 <server+0x181>
xor    %r12d,%r12d
jmp    1336 <server+0x146>
nop
add    $0x1,%r12d
mov    %r12d,0x4(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    %r14d,%r12d
je     1371 <server+0x181>
mov    %r15d,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
test   %r15d,%r15d
je     1320 <server+0x130>
xor    %ebp,%ebp
mov    %r15d,%edx
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1040 <recv@plt>
add    %eax,%ebp
mov    %r15d,%edx
sub    %ebp,%edx
jne    1350 <server+0x160>
jmp    1320 <server+0x130>
lea    0xd05(%rip),%rdi
jmp    13bb <server+0x1cb>
xor    %ebx,%ebx
lea    0x4(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edx
sub    %ebx,%edx
mov    %r13d,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1070 <send@plt>
add    %rax,%rbx
cmp    $0x4,%rbx
jne    1380 <server+0x190>
mov    0x8(%rsp),%rdi
call   1100 <freeaddrinfo@plt>
xor    %eax,%eax
jmp    13c5 <server+0x1d5>
lea    0xc97(%rip),%rdi
jmp    13bb <server+0x1cb>
lea    0xc67(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"starting server\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.1 = [18 x i8] c"server error: %s\0A\00"
@.str.2 = [39 x i8] c"server error: could not create socket\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.3 = [44 x i8] c"server error: could not set socket options\0A\00"
@.str.4 = [40 x i8] c"server error: could not bind to socket\0A\00"
define i32 @server(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.sockaddr_storage
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 24)
%23 = load i32, i32* @PF_INET
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_STREAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %25, i32* %26
%27 = load i32, i32* @AI_PASSIVE
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %27, i32* %28
%29 = load i8*, i8** %5
%30 = call i32 @getaddrinfo(i32* null, i8* %29, %struct.addrinfo* %8, %struct.addrinfo** %9)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %3
%34 = load i32, i32* %10
%35 = call i8* @gai_strerror(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %35)
store i32 -1, i32* %4
br label %125
37: ; preds = %3
%38 = load %struct.addrinfo*, %struct.addrinfo** %9
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 4
%40 = load i32, i32* %39
%41 = load %struct.addrinfo*, %struct.addrinfo** %9
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 3
%43 = load i32, i32* %42
%44 = load %struct.addrinfo*, %struct.addrinfo** %9
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %40, i32 %43, i32 %46)
store i32 %47, i32* %11
%48 = load i32, i32* %11
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %37
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %125
52: ; preds = %37
store i32 1, i32* %12
%53 = load i32, i32* %11
%54 = load i32, i32* @SOL_SOCKET
%55 = load i32, i32* @SO_REUSEADDR
%56 = call i64 @setsockopt(i32 %53, i32 %54, i32 %55, i32* %12, i32 4)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %52
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %125
60: ; preds = %52
%61 = load i32, i32* %11
%62 = load %struct.addrinfo*, %struct.addrinfo** %9
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %62, i32 0, i32 1
%64 = load i32, i32* %63
%65 = load %struct.addrinfo*, %struct.addrinfo** %9
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i64 @bind(i32 %61, i32 %64, i32 %67)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %60
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %4
br label %125
72: ; preds = %60
%73 = load i32, i32* %11
%74 = call i32 @listen(i32 %73, i32 5)
%75 = load i32, i32* %11
%76 = bitcast %struct.sockaddr_storage* %14 to %struct.sockaddr*
%77 = call i32 @accept(i32 %75, %struct.sockaddr* %76, i32* %15)
store i32 %77, i32* %13
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %16
br label %78
78: ; preds = %106, %72
%79 = load i32, i32* %16
%80 = load i32, i32* %6
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %109
82: ; preds = %78
%83 = load i32, i32* %7
%84 = call i8* @malloc(i32 %83)
store i8* %84, i8** %18
store i32 0, i32* %19
br label %85
85: ; preds = %90, %82
%86 = load i32, i32* %7
%87 = load i32, i32* %19
%88 = sub nsw i32 %86, %87
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %101
90: ; preds = %85
%91 = load i32, i32* %13
%92 = load i8*, i8** %18
%93 = load i32, i32* %7
%94 = load i32, i32* %19
%95 = sub nsw i32 %93, %94
%96 = call i64 @recv(i32 %91, i8* %92, i32 %95, i32 0)
%97 = load i32, i32* %19
%98 = sext i32 %97 to i64
%99 = add nsw i64 %98, %96
%100 = trunc i64 %99 to i32
store i32 %100, i32* %19
br label %85
101: ; preds = %85
%102 = load i32, i32* %17
%103 = add nsw i32 %102, 1
store i32 %103, i32* %17
%104 = load i8*, i8** %18
%105 = call i32 @free(i8* %104)
br label %106
106: ; preds = %101
%107 = load i32, i32* %16
%108 = add nsw i32 %107, 1
store i32 %108, i32* %16
br label %78
109: ; preds = %78
store i64 0, i64* %20
br label %110
110: ; preds = %114, %109
%111 = load i64, i64* %20
%112 = sub i64 4, %111
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %122
114: ; preds = %110
%115 = load i32, i32* %13
%116 = load i64, i64* %20
%117 = sub i64 4, %116
%118 = trunc i64 %117 to i32
%119 = call i64 @send(i32 %115, i32* %17, i32 %118, i32 0)
%120 = load i64, i64* %20
%121 = add i64 %120, %119
store i64 %121, i64* %20
br label %110
122: ; preds = %110
%123 = load %struct.addrinfo*, %struct.addrinfo** %9
%124 = call i32 @freeaddrinfo(%struct.addrinfo* %123)
store i32 0, i32* %4
br label %125
125: ; preds = %122, %70, %58, %50, %33
%126 = load i32, i32* %4
ret i32 %126
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.1 = [18 x i8] c"server error: %s\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@str = [16 x i8] c"starting server\00"
@str.5 = [39 x i8] c"server error: could not bind to socket\00"
@str.6 = [43 x i8] c"server error: could not set socket options\00"
@str.7 = [38 x i8] c"server error: could not create socket\00"
define i32 @server(i8* %0, i32 %1, i32 %2) {
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca i32
%7 = alloca %struct.sockaddr_storage
%8 = alloca i32
%9 = alloca i32
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%11 = bitcast %struct.addrinfo* %4 to i8*
%12 = bitcast %struct.addrinfo** %5 to i8*
%13 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 24)
%14 = load i32, i32* @PF_INET
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %14, i32* %15
%16 = load i32, i32* @SOCK_STREAM
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %16, i32* %17
%18 = load i32, i32* @AI_PASSIVE
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 5
store i32 %18, i32* %19
%20 = call i32 @getaddrinfo(i32* null, i8* %0, %struct.addrinfo* %4, %struct.addrinfo** %5)
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %3
%23 = call i8* @gai_strerror(i32 %20)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %95
25: ; preds = %3
%26 = load %struct.addrinfo*, %struct.addrinfo** %5
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 4
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 3
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 2
%32 = load i32, i32* %31
%33 = call i32 @socket(i32 %28, i32 %30, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %25
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.7, i64 0, i64 0))
br label %95
37: ; preds = %25
%38 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%39 = load i32, i32* @SOL_SOCKET
%40 = load i32, i32* @SO_REUSEADDR
%41 = call i64 @setsockopt(i32 %33, i32 %39, i32 %40, i32* %6, i32 4)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.6, i64 0, i64 0))
br label %93
45: ; preds = %37
%46 = load %struct.addrinfo*, %struct.addrinfo** %5
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 1
%48 = load i32, i32* %47
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 0
%50 = load i32, i32* %49
%51 = call i64 @bind(i32 %33, i32 %48, i32 %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %45
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
br label %93
55: ; preds = %45
%56 = call i32 @listen(i32 %33, i32 5)
%57 = bitcast %struct.sockaddr_storage* %7 to i8*
%58 = bitcast i32* %8 to i8*
%59 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%60 = call i32 @accept(i32 %33, %struct.sockaddr* %59, i32* %8)
%61 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%62 = icmp sgt i32 %1, 0
br i1 %62, label %63, label %82
63: ; preds = %55
%64 = icmp eq i32 %2, 0
br label %65
65: ; preds = %63, %77
%66 = phi i32 [ 0, %63 ], [ %78, %77 ]
%67 = phi i32 [ 0, %63 ], [ %80, %77 ]
%68 = call i8* @malloc(i32 %2)
br i1 %64, label %77, label %69
69: ; preds = %65, %69
%70 = phi i32 [ %75, %69 ], [ %2, %65 ]
%71 = phi i32 [ %74, %69 ], [ 0, %65 ]
%72 = call i64 @recv(i32 %60, i8* %68, i32 %70, i32 0)
%73 = trunc i64 %72 to i32
%74 = add i32 %71, %73
%75 = sub nsw i32 %2, %74
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %69
77: ; preds = %69, %65
%78 = add nuw nsw i32 %66, 1
store i32 %78, i32* %9
%79 = call i32 @free(i8* %68)
%80 = add nuw nsw i32 %67, 1
%81 = icmp eq i32 %80, %1
br i1 %81, label %82, label %65
82: ; preds = %77, %55
br label %83
83: ; preds = %82, %83
%84 = phi i64 [ %88, %83 ], [ 0, %82 ]
%85 = trunc i64 %84 to i32
%86 = sub i32 4, %85
%87 = call i64 @send(i32 %60, i32* %9, i32 %86, i32 0)
%88 = add i64 %87, %84
%89 = icmp eq i64 %88, 4
br i1 %89, label %90, label %83
90: ; preds = %83
%91 = load %struct.addrinfo*, %struct.addrinfo** %5
%92 = call i32 @freeaddrinfo(%struct.addrinfo* %91)
br label %93
93: ; preds = %90, %53, %43
%94 = phi i32 [ -1, %43 ], [ -1, %53 ], [ 0, %90 ]
br label %95
95: ; preds = %93, %35, %22
%96 = phi i32 [ -1, %22 ], [ -1, %35 ], [ %94, %93 ]
ret i32 %96
}