#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 */
typedef int /*<<< orphan*/ timeout;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  char sin_zero;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  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 /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
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);
scalar_t__ fsetxattr(int, char *, char *, int /*<<< orphan*/,
                     int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int, char *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                      struct timeval *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int sock;
  int clientsock;
  char message[255];
  socklen_t client_length;
  struct sockaddr_in server_addr, client_addr;
  char *label_in;
  char *attr_in = "security.SMACK64IPIN";
  int port;
  struct timeval timeout;
  timeout.tv_sec = 15;
  timeout.tv_usec = 0;
  if (argc != 3) {
    perror("Server: Argument missing please provide port and label for "
           "SMACK64IPIN");
    return 2;
  }
  port = atoi(argv[1]);
  label_in = argv[2];
  bzero(message, 255);
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("Server: Socket failure");
    return 2;
  }
  if (fsetxattr(sock, attr_in, label_in, strlen(label_in), 0) < 0) {
    perror("Server: Unable to set attribute ipin 2");
    return 2;
  }
  server_addr.sin_family = AF_INET;
  server_addr.sin_port = htons(port);
  server_addr.sin_addr.s_addr = INADDR_ANY;
  bzero(&(server_addr.sin_zero), 8);
  if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) <
      0) {
    perror("Server: Set timeout failed\n");
    return 2;
  }
  if (bind(sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
    perror("Server: Bind failure ");
    return 2;
  }
  listen(sock, 1);
  client_length = sizeof(client_addr);
  clientsock = accept(sock, (struct sockaddr *)&client_addr, &client_length);
  if (clientsock < 0) {
    perror("Server: Connection failed");
    close(sock);
    return 1;
  }
  if (fsetxattr(clientsock, "security.SMACK64IPIN", label_in, strlen(label_in),
                0) < 0) {
    perror(" Server: Unable to set attribute ipin 2");
    close(sock);
    return 2;
  }
  if (read(clientsock, message, 254) < 0) {
    perror("Server: Error when reading from socket");
    close(clientsock);
    close(sock);
    return 1;
  }
  close(clientsock);
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe10(%rip),%rax
mov    %rax,-0x158(%rbp)
movl   $0xf,-0x170(%rbp)
movq   $0x0,-0x168(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     122e <main+0x5e>
lea    0xdf8(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x15c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x150(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0xff,%esi
call   10c0 <bzero@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    0x2d4f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    129e <main+0xce>
lea    0xdcf(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x14(%rbp),%eax
mov    %eax,-0x184(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x150(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x184(%rbp),%edi
mov    -0x180(%rbp),%rsi
mov    -0x178(%rbp),%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
cmp    $0x0,%rax
jge    130f <main+0x13f>
lea    0xdc2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x12c(%rbp)
mov    -0x15c(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x130(%rbp)
mov    0x2ca2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
lea    -0x138(%rbp),%rdi
mov    $0x8,%esi
call   10c0 <bzero@plt>
mov    -0x14(%rbp),%edi
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
mov    0x2c66(%rip),%rax
mov    (%rax),%edx
lea    -0x170(%rbp),%rcx
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1398 <main+0x1c8>
lea    0xcec(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x14(%rbp),%edi
lea    -0x138(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <bind@plt>
cmp    $0x0,%rax
jge    13ce <main+0x1fe>
lea    0xcd2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1090 <listen@plt>
movl   $0x10,-0x124(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x148(%rbp),%rsi
lea    -0x124(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1428 <main+0x258>
lea    0xc96(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x18(%rbp),%eax
mov    %eax,-0x194(%rbp)
mov    -0x150(%rbp),%rax
mov    %rax,-0x190(%rbp)
mov    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x194(%rbp),%edi
mov    -0x190(%rbp),%rdx
mov    %eax,%ecx
lea    0xb9f(%rip),%rsi
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
cmp    $0x0,%rax
jge    1493 <main+0x2c3>
lea    0xc45(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f0 <main+0x320>
mov    -0x18(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0xfe,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jge    14d9 <main+0x309>
lea    0xc2f(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x320>
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    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x148,%rsp
movl   $0xf,0x20(%rsp)
movq   $0x0,0x28(%rsp)
cmp    $0x3,%edi
jne    1361 <main+0x191>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%r14
lea    0x40(%rsp),%rdi
mov    $0xff,%esi
call   10c0 <bzero@plt>
mov    0x2dc1(%rip),%r15
mov    (%r15),%edi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
test   %eax,%eax
js     136a <main+0x19a>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xdb5(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
test   %rax,%rax
js     1373 <main+0x1a3>
mov    (%r15),%eax
mov    %eax,0x1c(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %eax,0x18(%rsp)
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
call   10c0 <bzero@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
mov    0x2d27(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rcx
mov    %ebx,%edi
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     137c <main+0x1ac>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10a0 <bind@plt>
test   %rax,%rax
js     1385 <main+0x1b5>
mov    $0x1,%r15d
mov    %ebx,%edi
mov    $0x1,%esi
call   1090 <listen@plt>
movl   $0x10,0xc(%rsp)
lea    0x30(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   10d0 <accept@plt>
test   %eax,%eax
js     13a8 <main+0x1d8>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xce4(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
test   %rax,%rax
js     13bd <main+0x1ed>
lea    0x40(%rsp),%rsi
mov    %ebp,%edi
mov    $0xfe,%edx
call   1080 <read@plt>
test   %rax,%rax
js     13d2 <main+0x202>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %r15d,%r15d
jmp    1397 <main+0x1c7>
lea    0xcad(%rip),%rdi
jmp    138c <main+0x1bc>
lea    0xceb(%rip),%rdi
jmp    138c <main+0x1bc>
lea    0xd46(%rip),%rdi
jmp    138c <main+0x1bc>
lea    0xcf0(%rip),%rdi
jmp    138c <main+0x1bc>
lea    0xd03(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%r15d
mov    %r15d,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf6(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    1397 <main+0x1c7>
lea    0xcfb(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    1391 <main+0x1c1>
lea    0xd0e(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0x1,%r15d
jmp    1397 <main+0x1c7>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [21 x i8] c"security.SMACK64IPIN\00"
@.str.1 = [71 x i8] c"Server: Argument missing please provide port and label for SMACK64IPIN\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [23 x i8] c"Server: Socket failure\00"
@.str.3 = [39 x i8] c"Server: Unable to set attribute ipin 2\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@.str.4 = [28 x i8] c"Server: Set timeout failed\0A\00"
@.str.5 = [22 x i8] c"Server: Bind failure \00"
@.str.6 = [26 x i8] c"Server: Connection failed\00"
@.str.7 = [40 x i8] c" Server: Unable to set attribute ipin 2\00"
@.str.8 = [39 x i8] c"Server: Error when reading from 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 [255 x i8]
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %13
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
store i32 15, i32* %16
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
store i64 0, i64* %17
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %112
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %14
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %12
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%31 = call i32 @bzero(i8* %30, i32 255)
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %6
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %22
%37 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %112
38: ; preds = %22
%39 = load i32, i32* %6
%40 = load i8*, i8** %13
%41 = load i8*, i8** %12
%42 = load i8*, i8** %12
%43 = call i32 @strlen(i8* %42)
%44 = call i64 @fsetxattr(i32 %39, i8* %40, i8* %41, i32 %43, i32 0)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %38
%47 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %112
48: ; preds = %38
%49 = load i32, i32* @AF_INET
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 3
store i32 %49, i32* %50
%51 = load i32, i32* %14
%52 = call i32 @htons(i32 %51)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %52, i32* %53
%54 = load i32, i32* @INADDR_ANY
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i32 %54, i32* %56
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%58 = call i32 @bzero(i8* %57, i32 8)
%59 = load i32, i32* %6
%60 = load i32, i32* @SOL_SOCKET
%61 = load i32, i32* @SO_RCVTIMEO
%62 = call i64 @setsockopt(i32 %59, i32 %60, i32 %61, %struct.timeval* %15, i32 16)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %48
%65 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %112
66: ; preds = %48
%67 = load i32, i32* %6
%68 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%69 = call i64 @bind(i32 %67, %struct.sockaddr* %68, i32 16)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %112
73: ; preds = %66
%74 = load i32, i32* %6
%75 = call i32 @listen(i32 %74, i32 1)
store i32 16, i32* %9
%76 = load i32, i32* %6
%77 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%78 = call i32 @accept(i32 %76, %struct.sockaddr* %77, i32* %9)
store i32 %78, i32* %7
%79 = load i32, i32* %7
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %73
%82 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%83 = load i32, i32* %6
%84 = call i32 @close(i32 %83)
store i32 1, i32* %3
br label %112
85: ; preds = %73
%86 = load i32, i32* %7
%87 = load i8*, i8** %12
%88 = load i8*, i8** %12
%89 = call i32 @strlen(i8* %88)
%90 = call i64 @fsetxattr(i32 %86, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %87, i32 %89, i32 0)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %85
%93 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%94 = load i32, i32* %6
%95 = call i32 @close(i32 %94)
store i32 2, i32* %3
br label %112
96: ; preds = %85
%97 = load i32, i32* %7
%98 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%99 = call i64 @read(i32 %97, i8* %98, i32 254)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %96
%102 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%103 = load i32, i32* %7
%104 = call i32 @close(i32 %103)
%105 = load i32, i32* %6
%106 = call i32 @close(i32 %105)
store i32 1, i32* %3
br label %112
107: ; preds = %96
%108 = load i32, i32* %7
%109 = call i32 @close(i32 %108)
%110 = load i32, i32* %6
%111 = call i32 @close(i32 %110)
store i32 0, i32* %3
br label %112
112: ; preds = %107, %101, %92, %81, %71, %64, %46, %36, %20
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [21 x i8] c"security.SMACK64IPIN\00"
@.str.1 = [71 x i8] c"Server: Argument missing please provide port and label for SMACK64IPIN\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [23 x i8] c"Server: Socket failure\00"
@.str.3 = [39 x i8] c"Server: Unable to set attribute ipin 2\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@.str.4 = [28 x i8] c"Server: Set timeout failed\0A\00"
@.str.5 = [22 x i8] c"Server: Bind failure \00"
@.str.6 = [26 x i8] c"Server: Connection failed\00"
@.str.7 = [40 x i8] c" Server: Unable to set attribute ipin 2\00"
@.str.8 = [39 x i8] c"Server: Error when reading from socket\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.timeval
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%12 = bitcast %struct.timeval* %7 to i8*
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
store i32 15, i32* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
store i64 0, i64* %14
%15 = icmp eq i32 %0, 3
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = tail call i32 @perror(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
br label %82
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @bzero(i8* %8, i32 255)
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = tail call i32 @socket(i32 %25, i32 %26, i32 0)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %18
%30 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %82
31: ; preds = %18
%32 = tail call i32 @strlen(i8* %23)
%33 = tail call i64 @fsetxattr(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %32, i32 0)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %82
37: ; preds = %31
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 3
store i32 %38, i32* %39
%40 = tail call i32 @htons(i32 %21)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %40, i32* %41
%42 = load i32, i32* @INADDR_ANY
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %42, i32* %43
%44 = call i32 @bzero(i8* %10, i32 8)
%45 = load i32, i32* @SOL_SOCKET
%46 = load i32, i32* @SO_RCVTIMEO
%47 = call i64 @setsockopt(i32 %27, i32 %45, i32 %46, %struct.timeval* %7, i32 16)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %37
%50 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %82
51: ; preds = %37
%52 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%53 = call i64 @bind(i32 %27, %struct.sockaddr* %52, i32 16)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %82
57: ; preds = %51
%58 = call i32 @listen(i32 %27, i32 1)
store i32 16, i32* %4
%59 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%60 = call i32 @accept(i32 %27, %struct.sockaddr* %59, i32* %4)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%64 = call i32 @close(i32 %27)
br label %82
65: ; preds = %57
%66 = call i32 @strlen(i8* %23)
%67 = call i64 @fsetxattr(i32 %60, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %66, i32 0)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @close(i32 %27)
br label %82
72: ; preds = %65
%73 = call i64 @read(i32 %60, i8* %8, i32 254)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %72
%76 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%77 = call i32 @close(i32 %60)
%78 = call i32 @close(i32 %27)
br label %82
79: ; preds = %72
%80 = call i32 @close(i32 %60)
%81 = call i32 @close(i32 %27)
br label %82
82: ; preds = %79, %75, %69, %62, %55, %49, %35, %29, %16
%83 = phi i32 [ 2, %16 ], [ 2, %29 ], [ 2, %35 ], [ 2, %49 ], [ 2, %55 ], [ 1, %62 ], [ 2, %69 ], [ 1, %75 ], [ 0, %79 ]
ret i32 %83
}