#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*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
scalar_t__ isprime(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sockfd, newsockfd, portn, val;
  socklen_t clientlen;
  char buffer[256];
  struct sockaddr_in server_addr, client_addr;
  int n;
  if (argc != 2) {
    perror("Arguments specified wrongly. Type --help for usage");
    exit(1);
  } else if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
    printf("Usage: ./app_server <port>\n");
    return 0;
  } else {
    portn = atoi(argv[1]);
  }
  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("Error creating socket");
    exit(1);
  }
  bzero((char *)&server_addr, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = INADDR_ANY;
  server_addr.sin_port = htons(portn);
  if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
    perror("Error on binding");
    exit(1);
  }
  listen(sockfd, 5);
  clientlen = sizeof(client_addr);
  newsockfd = accept(sockfd, (struct sockaddr *)&client_addr, &clientlen);
  if (newsockfd < 0) {
    perror("Error on accept");
    exit(1);
  }
  while (1) {
    bzero(buffer, 256);
    n = read(newsockfd, buffer, 255);
    if (n < 0) {
      perror("Error reading from socket");
    }
    printf("Received %s from client...\n", buffer);
    if (buffer[0] == '0') {
      break;
    }
    val = atoi(buffer);
    bzero(buffer, 256);
    if (isprime(val)) {
      sprintf(buffer, "%i is a prime number!\n", val);
    } else {
      sprintf(buffer, "%i is not a prime number!\n", val);
    }
    n = write(newsockfd, buffer, strlen(buffer));
    if (n < 0) {
      error("Error writing to socket");
    }
  }
  close(newsockfd);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1259 <main+0x39>
lea    0xdb6(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcb(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     1293 <main+0x73>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb5(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12ad <main+0x8d>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1500 <main+0x2e0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    12c2 <main+0xa2>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12fd <main+0xdd>
lea    0xd6b(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    -0x140(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x138(%rbp)
mov    0x2cbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x140(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    136e <main+0x14e>
lea    0xd10(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
movl   $0xc,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x150(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13b8 <main+0x198>
lea    0xcd7(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    13bd <main+0x19d>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    -0x18(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xff,%edx
call   1080 <read@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
jge    1401 <main+0x1e1>
lea    0xc94(%rip),%rdi
call   10e0 <perror@plt>
lea    -0x130(%rbp),%rsi
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x130(%rbp),%eax
cmp    $0x30,%eax
jne    142b <main+0x20b>
jmp    14e9 <main+0x2c9>
lea    -0x130(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    -0x20(%rbp),%edi
call   10a0 <isprime@plt>
cmp    $0x0,%rax
je     1478 <main+0x258>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xc58(%rip),%rsi
call   1120 <sprintf@plt>
jmp    148e <main+0x26e>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xc54(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x164(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x164(%rbp),%edi
mov    -0x160(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
jge    14e4 <main+0x2c4>
lea    0xc19(%rip),%rdi
call   10d0 <error@plt>
jmp    13bd <main+0x19d>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
cmp    $0x2,%edi
jne    141d <main+0x1ed>
mov    0x8(%rsi),%rbx
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     13eb <main+0x1bb>
lea    0xdce(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     13eb <main+0x1bb>
mov    %rbx,%rdi
call   1120 <atoi@plt>
mov    %eax,%ebx
mov    0x2d5b(%rip),%r14
mov    (%r14),%edi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
js     1426 <main+0x1f6>
mov    %eax,%ebp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    (%r14),%eax
mov    %eax,0x18(%rsp)
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
js     142f <main+0x1ff>
mov    %ebp,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
movl   $0xc,0xc(%rsp)
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,0x8(%rsp)
mov    %ebp,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     1438 <main+0x208>
mov    %eax,%ebp
lea    0x30(%rsp),%rbx
lea    0xd5c(%rip),%r12
lea    0xd88(%rip),%r14
lea    0xd6a(%rip),%r13
mov    %rbx,%rdi
mov    $0x100,%esi
call   1100 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1090 <read@plt>
test   %eax,%eax
js     13da <main+0x1aa>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmpb   $0x30,0x30(%rsp)
je     13f9 <main+0x1c9>
mov    %rbx,%rdi
call   1120 <atoi@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0x100,%esi
call   1100 <bzero@plt>
mov    %r15d,%edi
call   10b0 <isprime@plt>
test   %rax,%rax
mov    %r13,%rsi
cmove  %r14,%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1130 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    1340 <main+0x110>
lea    0xd0c(%rip),%rdi
call   10e0 <error@plt>
jmp    1340 <main+0x110>
lea    0xc93(%rip),%rdi
call   10f0 <perror@plt>
jmp    1360 <main+0x130>
lea    0xd02(%rip),%rdi
call   1030 <puts@plt>
jmp    1409 <main+0x1d9>
mov    %ebp,%edi
call   1080 <close@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbdc(%rip),%rdi
jmp    143f <main+0x20f>
lea    0xc10(%rip),%rdi
jmp    143f <main+0x20f>
lea    0xc1d(%rip),%rdi
jmp    143f <main+0x20f>
lea    0xc25(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [51 x i8] c"Arguments specified wrongly. Type --help for usage\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [28 x i8] c"Usage: ./app_server <port>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [22 x i8] c"Error creating socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"Error on binding\00"
@.str.6 = [16 x i8] c"Error on accept\00"
@.str.7 = [26 x i8] c"Error reading from socket\00"
@.str.8 = [28 x i8] c"Received %s from client...\0A\00"
@.str.9 = [23 x i8] c"%i is a prime number!\0A\00"
@.str.10 = [27 x i8] c"%i is not a prime number!\0A\00"
@.str.11 = [24 x i8] c"Error writing to socket\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca %struct.sockaddr_in
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %26, %20
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %128
34: ; preds = %26
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %8
br label %39
39: ; preds = %34
br label %40
40: ; preds = %39
%41 = load i32, i32* @AF_INET
%42 = load i32, i32* @SOCK_STREAM
%43 = call i32 @socket(i32 %41, i32 %42, i32 0)
store i32 %43, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %40
%49 = bitcast %struct.sockaddr_in* %12 to i8*
%50 = call i32 @bzero(i8* %49, i32 12)
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %51, i32* %52
%53 = load i32, i32* @INADDR_ANY
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%55 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %54, i32 0, i32 0
store i32 %53, i32* %55
%56 = load i32, i32* %8
%57 = call i32 @htons(i32 %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i32 %57, i32* %58
%59 = load i32, i32* %6
%60 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%61 = call i64 @bind(i32 %59, %struct.sockaddr* %60, i32 12)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %48
%64 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %48
%67 = load i32, i32* %6
%68 = call i32 @listen(i32 %67, i32 5)
store i32 12, i32* %10
%69 = load i32, i32* %6
%70 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%71 = call i32 @accept(i32 %69, %struct.sockaddr* %70, i32* %10)
store i32 %71, i32* %7
%72 = load i32, i32* %7
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %66
%75 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %66
br label %78
78: ; preds = %77, %122
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%80 = call i32 @bzero(i8* %79, i32 256)
%81 = load i32, i32* %7
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%83 = call i32 @read(i32 %81, i8* %82, i32 255)
store i32 %83, i32* %14
%84 = load i32, i32* %14
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %78
%87 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %88
88: ; preds = %86, %78
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %89)
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 48
br i1 %94, label %95, label %96
95: ; preds = %88
br label %123
96: ; preds = %88
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%98 = call i32 @atoi(i8* %97)
store i32 %98, i32* %9
%99 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%100 = call i32 @bzero(i8* %99, i32 256)
%101 = load i32, i32* %9
%102 = call i64 @isprime(i32 %101)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %96
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%106 = load i32, i32* %9
%107 = call i32 @sprintf(i8* %105, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %106)
br label %112
108: ; preds = %96
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%110 = load i32, i32* %9
%111 = call i32 @sprintf(i8* %109, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %110)
br label %112
112: ; preds = %108, %104
%113 = load i32, i32* %7
%114 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%116 = call i32 @strlen(i8* %115)
%117 = call i32 @write(i32 %113, i8* %114, i32 %116)
store i32 %117, i32* %14
%118 = load i32, i32* %14
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %122
120: ; preds = %112
%121 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %122
122: ; preds = %120, %112
br label %78
123: ; preds = %95
%124 = load i32, i32* %7
%125 = call i32 @close(i32 %124)
%126 = load i32, i32* %6
%127 = call i32 @close(i32 %126)
store i32 0, i32* %3
br label %128
128: ; preds = %123, %32
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [51 x i8] c"Arguments specified wrongly. Type --help for usage\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-h\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [22 x i8] c"Error creating socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"Error on binding\00"
@.str.6 = [16 x i8] c"Error on accept\00"
@.str.7 = [26 x i8] c"Error reading from socket\00"
@.str.8 = [28 x i8] c"Received %s from client...\0A\00"
@.str.9 = [23 x i8] c"%i is a prime number!\0A\00"
@.str.10 = [27 x i8] c"%i is not a prime number!\0A\00"
@.str.11 = [24 x i8] c"Error writing to socket\00"
@str = [27 x i8] c"Usage: ./app_server <port>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = bitcast %struct.sockaddr_in* %5 to i8*
%10 = bitcast %struct.sockaddr_in* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %15
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %82
25: ; preds = %20
%26 = tail call i32 @atoi(i8* %17)
%27 = load i32, i32* @AF_INET
%28 = load i32, i32* @SOCK_STREAM
%29 = tail call i32 @socket(i32 %27, i32 %28, i32 0)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %25
%35 = call i32 @bzero(i8* %9, i32 12)
%36 = load i32, i32* @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %36, i32* %37
%38 = load i32, i32* @INADDR_ANY
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %38, i32* %39
%40 = tail call i32 @htons(i32 %26)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %40, i32* %41
%42 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%43 = call i64 @bind(i32 %29, %struct.sockaddr* %42, i32 12)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %34
%46 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %34
%49 = call i32 @listen(i32 %29, i32 5)
store i32 12, i32* %3
%50 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%51 = call i32 @accept(i32 %29, %struct.sockaddr* %50, i32* %3)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %48, %78
%57 = call i32 @bzero(i8* %8, i32 256)
%58 = call i32 @read(i32 %51, i8* %8, i32 255)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %62
62: ; preds = %60, %56
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%64 = load i8, i8* %8
%65 = icmp eq i8 %64, 48
br i1 %65, label %79, label %66
66: ; preds = %62
%67 = call i32 @atoi(i8* %8)
%68 = call i32 @bzero(i8* %8, i32 256)
%69 = call i64 @isprime(i32 %67)
%70 = icmp eq i64 %69, 0
%71 = select i1 %70, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0)
%72 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) %71, i32 %67)
%73 = call i32 @strlen(i8* %8)
%74 = call i32 @write(i32 %51, i8* %8, i32 %73)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %66
%77 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %78
78: ; preds = %76, %66
br label %56
79: ; preds = %62
%80 = call i32 @close(i32 %51)
%81 = call i32 @close(i32 %29)
br label %82
82: ; preds = %79, %23
ret i32 0
}