#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct TYPE_4__ {
  int fd;
};
struct epoll_event {
  TYPE_2__ data;
  int /*<<< orphan*/ events;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serverAddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int epoll_create(int);
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
struct epoll_event *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int main() {
  int ret = -1;
  int clientSock;
  char input[10] = "input";
  struct sockaddr_in serverAddr;
  char buffer[100];
  socklen_t adr_sz = sizeof(serverAddr);
  int optval = 1;
  struct epoll_event *ep_events;
  struct epoll_event event;
  int epfd, event_cnt, i, str_len;
  if ((clientSock = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket");
    goto leave;
  }
  serverAddr.sin_family = AF_INET;
  serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
  serverAddr.sin_port = htons(3001);
  if ((ret = connect(clientSock, (struct sockaddr *)&serverAddr,
                     sizeof(serverAddr)))) {
    perror("connect");
    goto error;
  }
  epfd = epoll_create(50);
  ep_events = malloc(sizeof(struct epoll_event) * 50);
  event.events = EPOLLIN;
  event.data.fd = clientSock;
  epoll_ctl(epfd, EPOLL_CTL_ADD, clientSock, &event);
  event.data.fd = 0;
  epoll_ctl(epfd, EPOLL_CTL_ADD, 0, &event);
  while (1) {
    event_cnt = epoll_wait(epfd, ep_events, 50, -1);
    if (event_cnt == -1) {
      perror("epoll_wait");
      goto error;
    }
    for (i = 0; i < event_cnt; i++) {
      if (ep_events[i].data.fd == 0) {
        fgets(buffer, 100, stdin);
        if ((ret = send(clientSock, buffer, strlen(buffer), 0)) <= 0) {
          perror("send");
          ret = -1;
        } else
          printf("I :  %s \n", buffer);
      } else {
        if ((ret = recv(clientSock, buffer, 100, 0)) <= 0) {
          perror("recv");
          ret = -1;
          goto leave;
        } else
          printf("%d: %s \n", ep_events[i].data.fd, buffer);
      }
    }
  }
error:
  close(clientSock);
leave:
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
mov    0xdf0(%rip),%rax
mov    %rax,-0x16(%rbp)
mov    0xded(%rip),%ax
mov    %ax,-0xe(%rbp)
movl   $0xc,-0x94(%rbp)
movl   $0x1,-0x98(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    1269 <main+0x79>
lea    0xdab(%rip),%rdi
call   10e0 <perror@plt>
jmp    14cd <main+0x2dd>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xd95(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    $0xbb9,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     12bf <main+0xcf>
lea    0xd66(%rip),%rdi
call   10e0 <perror@plt>
jmp    14c5 <main+0x2d5>
mov    $0x32,%edi
call   10f0 <epoll_create@plt>
mov    %eax,-0xac(%rbp)
mov    $0x190,%edi
call   10c0 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xac(%rbp),%edi
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
lea    -0xa8(%rbp),%rcx
call   1090 <epoll_ctl@plt>
movl   $0x0,-0xa8(%rbp)
mov    -0xac(%rbp),%edi
mov    0x2ca3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
lea    -0xa8(%rbp),%rcx
call   1090 <epoll_ctl@plt>
mov    -0xac(%rbp),%edi
mov    -0xa0(%rbp),%rsi
mov    $0x32,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
mov    %eax,-0xb0(%rbp)
cmpl   $0xffffffff,-0xb0(%rbp)
jne    137d <main+0x18d>
lea    0xcb0(%rip),%rdi
call   10e0 <perror@plt>
jmp    14c5 <main+0x2d5>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xb0(%rbp),%eax
jge    14c0 <main+0x2d0>
mov    -0xa0(%rbp),%rax
movslq -0xb4(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,8)
jne    1442 <main+0x252>
lea    -0x90(%rbp),%rdi
mov    0x2c19(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   10a0 <fgets@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0xc4(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc4(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jg     1428 <main+0x238>
lea    0xc17(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    143d <main+0x24d>
lea    -0x90(%rbp),%rsi
lea    0xbfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14a7 <main+0x2b7>
mov    -0xc(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jg     147c <main+0x28c>
lea    0xbd2(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    14cd <main+0x2dd>
mov    -0xa0(%rbp),%rax
movslq -0xb4(%rbp),%rcx
mov    (%rax,%rcx,8),%esi
lea    -0x90(%rbp),%rdx
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14a7 <main+0x2b7>
jmp    14ac <main+0x2bc>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1387 <main+0x197>
jmp    133d <main+0x14d>
mov    -0xc(%rbp),%edi
call   1080 <close@plt>
mov    -0x8(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
jne    1235 <main+0x45>
lea    0xdda(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    13ee <main+0x1fe>
mov    %eax,%r12d
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
lea    0xdbb(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0xbb9,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0xc,%edx
call   1100 <connect@plt>
test   %eax,%eax
jne    13d8 <main+0x1e8>
mov    $0x32,%edi
call   10f0 <epoll_create@plt>
mov    %eax,%r14d
mov    $0x190,%edi
call   10c0 <malloc@plt>
mov    %rax,%r13
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %r12d,(%rsp)
mov    0x2d21(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rbp
mov    %r14d,%edi
mov    %r12d,%edx
mov    %rbp,%rcx
call   1090 <epoll_ctl@plt>
movl   $0x0,(%rsp)
mov    (%rbx),%esi
xor    %ebx,%ebx
mov    %r14d,%edi
xor    %edx,%edx
mov    %rbp,%rcx
call   1090 <epoll_ctl@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x32,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
lea    0xd23(%rip),%rdi
cmp    $0xffffffff,%eax
je     13e1 <main+0x1f1>
lea    0x20(%rsp),%rbp
xor    %ebx,%ebx
mov    %r14d,0xc(%rsp)
jmp    132f <main+0x13f>
nopl   (%rax)
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0x32,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
cmp    $0xffffffff,%eax
je     140e <main+0x21e>
test   %eax,%eax
jle    1310 <main+0x120>
mov    %eax,%r15d
xor    %r14d,%r14d
jmp    138d <main+0x19d>
nopl   0x0(%rax,%rax,1)
mov    0x2c91(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x64,%esi
call   10a0 <fgets@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %eax,%eax
jle    13c5 <main+0x1d5>
mov    %eax,%ebx
lea    0xcaf(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
je     1310 <main+0x120>
cmpl   $0x0,0x0(%r13,%r14,8)
je     1340 <main+0x150>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1402 <main+0x212>
mov    %eax,%ebx
mov    0x0(%r13,%r14,8),%esi
lea    0xc7f(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1384 <main+0x194>
lea    0xc58(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    1384 <main+0x194>
mov    %eax,%ebx
lea    0xc30(%rip),%rdi
call   10e0 <perror@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc2a(%rip),%rdi
jmp    1226 <main+0x36>
lea    0xc04(%rip),%rdi
jmp    13e1 <main+0x1f1>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.input = [10 x i8] c"input\00\00\00\00\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@AF_INET = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [8 x i8] c"connect\00"
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [11 x i8] c"epoll_wait\00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"send\00"
@.str.5 = [10 x i8] c"I : %s \0A\00"
@.str.6 = [5 x i8] c"recv\00"
@.str.7 = [9 x i8] c"%d: %s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.epoll_event*
%10 = alloca %struct.epoll_event
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%15 = bitcast [10 x i8]* %4 to i8*
store i32 12, i32* %7
store i32 1, i32* %8
%16 = load i32, i32* @PF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
store i32 %18, i32* %3
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %117
22: ; preds = %0
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %23, i32* %24
%25 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = call i32 @htons(i32 3001)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %28, i32* %29
%30 = load i32, i32* %3
%31 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%32 = call i32 @connect(i32 %30, %struct.sockaddr* %31, i32 12)
store i32 %32, i32* %2
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %22
%35 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %114
36: ; preds = %22
%37 = call i32 @epoll_create(i32 50)
store i32 %37, i32* %11
%38 = call %struct.epoll_event* @malloc(i32 400)
store %struct.epoll_event* %38, %struct.epoll_event** %9
%39 = load i32, i32* @EPOLLIN
%40 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %10, i32 0, i32 1
store i32 %39, i32* %40
%41 = load i32, i32* %3
%42 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %10, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i32 0, i32 0
store i32 %41, i32* %43
%44 = load i32, i32* %11
%45 = load i32, i32* @EPOLL_CTL_ADD
%46 = load i32, i32* %3
%47 = call i32 @epoll_ctl(i32 %44, i32 %45, i32 %46, %struct.epoll_event* %10)
%48 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %10, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %48, i32 0, i32 0
store i32 0, i32* %49
%50 = load i32, i32* %11
%51 = load i32, i32* @EPOLL_CTL_ADD
%52 = call i32 @epoll_ctl(i32 %50, i32 %51, i32 0, %struct.epoll_event* %10)
br label %53
53: ; preds = %36, %113
%54 = load i32, i32* %11
%55 = load %struct.epoll_event*, %struct.epoll_event** %9
%56 = call i32 @epoll_wait(i32 %54, %struct.epoll_event* %55, i32 50, i32 -1)
store i32 %56, i32* %12
%57 = load i32, i32* %12
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %114
61: ; preds = %53
store i32 0, i32* %13
br label %62
62: ; preds = %110, %61
%63 = load i32, i32* %13
%64 = load i32, i32* %12
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %113
66: ; preds = %62
%67 = load %struct.epoll_event*, %struct.epoll_event** %9
%68 = load i32, i32* %13
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %67, i64 %69
%71 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %70, i32 0, i32 0
%72 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %71, i32 0, i32 0
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %91
75: ; preds = %66
%76 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%77 = load i32, i32* @stdin
%78 = call i32 @fgets(i8* %76, i32 100, i32 %77)
%79 = load i32, i32* %3
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%82 = call i32 @strlen(i8* %81)
%83 = call i32 @send(i32 %79, i8* %80, i32 %82, i32 0)
store i32 %83, i32* %2
%84 = icmp sle i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %75
%86 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %2
br label %90
87: ; preds = %75
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %87, %85
br label %109
91: ; preds = %66
%92 = load i32, i32* %3
%93 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%94 = call i32 @recv(i32 %92, i8* %93, i32 100, i32 0)
store i32 %94, i32* %2
%95 = icmp sle i32 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %2
br label %117
98: ; preds = %91
%99 = load %struct.epoll_event*, %struct.epoll_event** %9
%100 = load i32, i32* %13
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %99, i64 %101
%103 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %102, i32 0, i32 0
%104 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %103, i32 0, i32 0
%105 = load i32, i32* %104
%106 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %105, i8* %106)
br label %108
108: ; preds = %98
br label %109
109: ; preds = %108, %90
br label %110
110: ; preds = %109
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
store i32 %112, i32* %13
br label %62
113: ; preds = %62
br label %53
114: ; preds = %59, %34
%115 = load i32, i32* %3
%116 = call i32 @close(i32 %115)
br label %117
117: ; preds = %114, %96, %20
%118 = load i32, i32* %2
ret i32 %118
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@AF_INET = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [8 x i8] c"connect\00"
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [11 x i8] c"epoll_wait\00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"send\00"
@.str.5 = [10 x i8] c"I : %s \0A\00"
@.str.6 = [5 x i8] c"recv\00"
@.str.7 = [9 x i8] c"%d: %s \0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [100 x i8]
%3 = alloca %struct.epoll_event
%4 = bitcast %struct.sockaddr_in* %1 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast %struct.epoll_event* %3 to i8*
%7 = load i32, i32* @PF_INET
%8 = load i32, i32* @SOCK_STREAM
%9 = tail call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %77
13: ; preds = %0
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %14, i32* %15
%16 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %16, i32* %17
%18 = tail call i32 @htons(i32 3001)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %18, i32* %19
%20 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%21 = call i32 @connect(i32 %9, %struct.sockaddr* %20, i32 12)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %72
23: ; preds = %13
%24 = call i32 @epoll_create(i32 50)
%25 = call %struct.epoll_event* @malloc(i32 400)
%26 = load i32, i32* @EPOLLIN
%27 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0, i32 0
store i32 %9, i32* %28
%29 = load i32, i32* @EPOLL_CTL_ADD
%30 = call i32 @epoll_ctl(i32 %24, i32 %29, i32 %9, %struct.epoll_event* %3)
store i32 0, i32* %28
%31 = load i32, i32* @EPOLL_CTL_ADD
%32 = call i32 @epoll_ctl(i32 %24, i32 %31, i32 0, %struct.epoll_event* %3)
%33 = call i32 @epoll_wait(i32 %24, %struct.epoll_event* %25, i32 50, i32 -1)
%34 = icmp eq i32 %33, -1
br i1 %34, label %72, label %39
35: ; preds = %68, %39
%36 = phi i32 [ %41, %39 ], [ %69, %68 ]
%37 = call i32 @epoll_wait(i32 %24, %struct.epoll_event* %25, i32 50, i32 -1)
%38 = icmp eq i32 %37, -1
br i1 %38, label %72, label %39
39: ; preds = %23, %35
%40 = phi i32 [ %37, %35 ], [ %33, %23 ]
%41 = phi i32 [ %36, %35 ], [ 0, %23 ]
%42 = icmp sgt i32 %40, 0
br i1 %42, label %43, label %35
43: ; preds = %39
%44 = zext i32 %40 to i64
br label %45
45: ; preds = %43, %68
%46 = phi i64 [ 0, %43 ], [ %70, %68 ]
%47 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %25, i64 %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %45
%51 = load i32, i32* @stdin
%52 = call i32 @fgets(i8* %5, i32 100, i32 %51)
%53 = call i32 @strlen(i8* %5)
%54 = call i32 @send(i32 %9, i8* %5, i32 %53, i32 0)
%55 = icmp slt i32 %54, 1
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %68
58: ; preds = %50
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %5)
br label %68
60: ; preds = %45
%61 = call i32 @recv(i32 %9, i8* %5, i32 100, i32 0)
%62 = icmp slt i32 %61, 1
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %77
65: ; preds = %60
%66 = load i32, i32* %47
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %66, i8* %5)
br label %68
68: ; preds = %65, %58, %56
%69 = phi i32 [ -1, %56 ], [ %54, %58 ], [ %61, %65 ]
%70 = add nuw nsw i64 %46, 1
%71 = icmp eq i64 %70, %44
br i1 %71, label %35, label %45
72: ; preds = %35, %23, %13
%73 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %13 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %35 ]
%74 = phi i32 [ %21, %13 ], [ 0, %23 ], [ %36, %35 ]
%75 = call i32 @perror(i8* %73)
%76 = call i32 @close(i32 %9)
br label %77
77: ; preds = %72, %63, %11
%78 = phi i32 [ -1, %11 ], [ %74, %72 ], [ -1, %63 ]
ret i32 %78
}