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

/* Variables and functions */
int AF_INET;
int INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int close(int);
int /*<<< orphan*/ getsockname(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int main(int argc, char *argv[]) {
  int hSocket, hServerSocket;
  struct hostent *pHostInfo;
  struct sockaddr_in Address;
  int nAddressSize = sizeof(struct sockaddr_in);
  char pBuffer[100];
  int nHostPort;
  if (argc < 2) {
    printf("\nUsage: server host-port\n");
    return 0;
  } else {
    nHostPort = atoi(argv[1]);
  }
  printf("\nStarting server");
  printf("\nMaking socket");
  hServerSocket = socket(AF_INET, SOCK_STREAM, 0);
  if (hServerSocket == -1) {
    printf("\nCould not make a socket\n");
    return 0;
  }
  Address.sin_addr.s_addr = INADDR_ANY;
  Address.sin_port = htons(nHostPort);
  Address.sin_family = AF_INET;
  printf("\nBinding to port %d", nHostPort);
  if (bind(hServerSocket, (struct sockaddr *)&Address, sizeof(Address)) == -1) {
    printf("\nCould not connect to host\n");
    return 0;
  }
  getsockname(hServerSocket, (struct sockaddr *)&Address,
              (socklen_t *)&nAddressSize);
  printf("opened socket as fd (%d) on port (%d) for stream i/o\n",
         hServerSocket, ntohs(Address.sin_port));
  printf("Server\n              sin_family        = %d\n              "
         "sin_addr.s_addr   = %d\n              sin_port          = %d\n",
         Address.sin_family, Address.sin_addr.s_addr, ntohs(Address.sin_port));
  printf("\nMaking a listen queue of %d elements", 5);
  if (listen(hServerSocket, 5) == -1) {
    printf("\nCould not listen\n");
    return 0;
  }
  printf("\nWaiting for a connection\n");
  hSocket = accept(hServerSocket, (struct sockaddr *)&Address,
                   (socklen_t *)&nAddressSize);
  for (;;) {
    write(hSocket, pBuffer, strlen(pBuffer) + 1);
    read(hSocket, pBuffer, 100);
    printf("\nClient : %s", pBuffer);
    if (strcmp(pBuffer, "exit") == 0) {
      printf("\nClosing the socket");
      if (close(hSocket) == -1) {
        printf("\nCould not close socket\n");
        return 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x34(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1224 <main+0x44>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1497 <main+0x2b7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0xa4(%rbp)
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1293 <main+0xb3>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1497 <main+0x2b7>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0xa4(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0xa4(%rbp),%esi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1301 <main+0x121>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1497 <main+0x2b7>
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10e0 <getsockname@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x2c(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0xb0(%rbp),%esi
mov    %eax,%edx
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x2c(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0xac(%rbp),%esi
mov    -0xa8(%rbp),%edx
mov    %eax,%ecx
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x5,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    13b1 <main+0x1d1>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1497 <main+0x2b7>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xbc(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xbc(%rbp),%edi
mov    -0xb8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x64,%edx
call   1080 <read@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd4d(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1492 <main+0x2b2>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    148d <main+0x2ad>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1497 <main+0x2b7>
jmp    1492 <main+0x2b2>
jmp    13d2 <main+0x1f2>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
movl   $0xc,0xc(%rsp)
cmp    $0x1,%edi
jg     1218 <main+0x28>
lea    0xf92(%rip),%rdi
jmp    13da <main+0x1ea>
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebp
lea    0xdd6(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2da2(%rip),%r14
mov    (%r14),%edi
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     13c1 <main+0x1d1>
mov    %eax,%ebx
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r14),%eax
mov    %eax,(%rsp)
lea    0xd97(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
je     13ca <main+0x1da>
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   10f0 <getsockname@plt>
mov    0x4(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xd6b(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%r14d
mov    (%rsp),%ebp
mov    0x4(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xd7e(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xde0(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
cmp    $0xffffffff,%eax
je     13d3 <main+0x1e3>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   10e0 <accept@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rbx
lea    0xdbc(%rip),%r14
lea    0xdc2(%rip),%r15
lea    0xdc0(%rip),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1090 <read@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    1360 <main+0x170>
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
jne    1360 <main+0x170>
lea    0xd88(%rip),%rdi
jmp    13da <main+0x1ea>
lea    0xdc4(%rip),%rdi
jmp    13da <main+0x1ea>
lea    0xda0(%rip),%rdi
jmp    13da <main+0x1ea>
lea    0xd85(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [26 x i8] c"\0AUsage: server host-port\0A\00"
@.str.1 = [17 x i8] c"\0AStarting server\00"
@.str.2 = [15 x i8] c"\0AMaking socket\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [26 x i8] c"\0ACould not make a socket\0A\00"
@INADDR_ANY = global i32 0
@.str.4 = [20 x i8] c"\0ABinding to port %d\00"
@.str.5 = [28 x i8] c"\0ACould not connect to host\0A\00"
@.str.6 = [54 x i8] c"opened socket as fd (%d) on port (%d) for stream i/o\0A\00"
@.str.7 = [119 x i8] c"Server\0A sin_family = %d\0A sin_addr.s_addr = %d\0A sin_port = %d\0A\00"
@.str.8 = [38 x i8] c"\0AMaking a listen queue of %d elements\00"
@.str.9 = [19 x i8] c"\0ACould not listen\0A\00"
@.str.10 = [27 x i8] c"\0AWaiting for a connection\0A\00"
@.str.11 = [13 x i8] c"\0AClient : %s\00"
@.str.12 = [5 x i8] c"exit\00"
@.str.13 = [20 x i8] c"\0AClosing the socket\00"
@.str.14 = [25 x i8] c"\0ACould not close socket\0A\00"
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.hostent*
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca [100 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %10
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %102
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %12
br label %22
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %102
32: ; preds = %22
%33 = load i32, i32* @INADDR_ANY
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
%35 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %34, i32 0, i32 0
store i32 %33, i32* %35
%36 = load i32, i32* %12
%37 = call i32 @htons(i32 %36)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %37, i32* %38
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %39, i32* %40
%41 = load i32, i32* %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %7
%44 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%45 = call i32 @bind(i32 %43, %struct.sockaddr* %44, i32 12)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %102
49: ; preds = %32
%50 = load i32, i32* %7
%51 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%52 = call i32 @getsockname(i32 %50, %struct.sockaddr* %51, i32* %10)
%53 = load i32, i32* %7
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%55 = load i32, i32* %54
%56 = call i32 @ntohs(i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %53, i32 %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%64 = load i32, i32* %63
%65 = call i32 @ntohs(i32 %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.7, i64 0, i64 0), i32 %59, i32 %62, i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 5)
%68 = load i32, i32* %7
%69 = call i32 @listen(i32 %68, i32 5)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %49
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %102
73: ; preds = %49
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%75 = load i32, i32* %7
%76 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%77 = call i32 @accept(i32 %75, %struct.sockaddr* %76, i32* %10)
store i32 %77, i32* %6
br label %78
78: ; preds = %101, %73
%79 = load i32, i32* %6
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%82 = call i64 @strlen(i8* %81)
%83 = add nsw i64 %82, 1
%84 = call i32 @write(i32 %79, i8* %80, i64 %83)
%85 = load i32, i32* %6
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%87 = call i32 @read(i32 %85, i8* %86, i32 100)
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %88)
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%91 = call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %101
93: ; preds = %78
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%95 = load i32, i32* %6
%96 = call i32 @close(i32 %95)
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %102
100: ; preds = %93
br label %101
101: ; preds = %100, %78
br label %78
102: ; preds = %98, %71, %47, %30, %15
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str.1 = [17 x i8] c"\0AStarting server\00"
@.str.2 = [15 x i8] c"\0AMaking socket\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
@.str.4 = [20 x i8] c"\0ABinding to port %d\00"
@.str.6 = [54 x i8] c"opened socket as fd (%d) on port (%d) for stream i/o\0A\00"
@.str.7 = [119 x i8] c"Server\0A sin_family = %d\0A sin_addr.s_addr = %d\0A sin_port = %d\0A\00"
@.str.8 = [38 x i8] c"\0AMaking a listen queue of %d elements\00"
@.str.11 = [13 x i8] c"\0AClient : %s\00"
@.str.12 = [5 x i8] c"exit\00"
@.str.13 = [20 x i8] c"\0AClosing the socket\00"
@str = [26 x i8] c"\0AWaiting for a connection\00"
@str.15 = [24 x i8] c"\0ACould not close socket\00"
@str.16 = [18 x i8] c"\0ACould not listen\00"
@str.17 = [27 x i8] c"\0ACould not connect to host\00"
@str.18 = [25 x i8] c"\0ACould not make a socket\00"
@str.19 = [25 x i8] c"\0AUsage: server host-port\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = bitcast i32* %4 to i8*
store i32 12, i32* %4
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.19, i64 0, i64 0))
br label %70
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = tail call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.18, i64 0, i64 0))
br label %70
24: ; preds = %12
%25 = load i32, i32* @INADDR_ANY
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2, i32 0
store i32 %25, i32* %26
%27 = tail call i32 @htons(i32 %15)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %29, i32* %30
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%32 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%33 = call i32 @bind(i32 %20, %struct.sockaddr* %32, i32 12)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %24
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.17, i64 0, i64 0))
br label %70
37: ; preds = %24
%38 = call i32 @getsockname(i32 %20, %struct.sockaddr* %32, i32* %4)
%39 = load i32, i32* %28
%40 = call i32 @ntohs(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %20, i32 %40)
%42 = load i32, i32* %30
%43 = load i32, i32* %26
%44 = load i32, i32* %28
%45 = call i32 @ntohs(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @.str.7, i64 0, i64 0), i32 %42, i32 %43, i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 5)
%48 = call i32 @listen(i32 %20, i32 5)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %37
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
br label %70
52: ; preds = %37
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%54 = call i32 @accept(i32 %20, %struct.sockaddr* %32, i32* %4)
br label %55
55: ; preds = %67, %52
%56 = call i64 @strlen(i8* %8)
%57 = add nsw i64 %56, 1
%58 = call i32 @write(i32 %54, i8* %8, i64 %57)
%59 = call i32 @read(i32 %54, i8* %8, i32 100)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %8)
%61 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %55
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%65 = call i32 @close(i32 %54)
%66 = icmp eq i32 %65, -1
br i1 %66, label %68, label %67
67: ; preds = %63, %55
br label %55
68: ; preds = %63
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.15, i64 0, i64 0))
br label %70
70: ; preds = %68, %50, %35, %22, %10
ret i32 0
}