#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_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct pollfd {
  int fd;
  int events;
  int revents;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int BUFSIZ;
scalar_t__ ECONNRESET;
int POLLERR;
int POLLIN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, struct sockaddr *,
                         int /*<<< orphan*/);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_aton(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int main(int argc, char *argv[]) {
  int i, maxi, listenfd, connfd, sockfd;
  int nready;
  ssize_t n;
  socklen_t clilen;
  struct sockaddr_in servaddr, cliaddr;
  struct hostent *hp;
  char buf[BUFSIZ];
  struct pollfd client[50000];
  if (argc != 2) {
    printf("Please input %s <hostname>\n", argv[0]);
    exit(1);
  }
  if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    printf("Create socket error!\n");
    exit(1);
  }
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  if ((hp = gethostbyname(argv[1])) != NULL) {
    bcopy(hp->h_addr, (struct sockaddr *)&servaddr.sin_addr, hp->h_length);
  } else if (inet_aton(argv[1], &servaddr.sin_addr) < 0) {
    printf("Input Server IP error!\n");
    exit(1);
  }
  servaddr.sin_port = htons(3333);
  if (bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) {
    printf("IPaddress bound failure!\n");
    exit(1);
  }
  listen(listenfd, 1024);
  client[0].fd = listenfd;
  client[0].events = POLLIN;
  for (i = 1; i < 50000; ++i)
    client[i].fd = -1;
  maxi = 0;
  while (1) {
    nready = poll(client, maxi + 1, -1);
    if (client[0].revents & POLLIN) {
      connfd = accept(listenfd, (struct sockaddr *)&servaddr, &clilen);
      for (i = 1; i < 50000; ++i)
        if (client[i].fd < 0) {
          client[i].fd = connfd;
          client[i].events = POLLIN;
          break;
        }
      if (i == 50000) {
        printf("too many clients");
        exit(1);
      }
      if (i > maxi)
        maxi = i;
      if (--nready <= 0)
        continue;
    }
    for (i = 1; i <= maxi; i++) {
      if ((sockfd = client[i].fd) < 0)
        continue;
      if (client[i].revents & (POLLIN | POLLERR)) {
        if ((n = read(sockfd, buf, 1024)) < 0) {
          if (errno == ECONNRESET) {
            close(sockfd);
            client[i].fd = -1;
          } else
            perror("read error");
        } else if (n == 0) {
          close(sockfd);
          client[i].fd = -1;
        } else
          write(sockfd, buf, n);
        if (--nready <= 0)
          break;
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x92840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x92838(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1271 <main+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    12ae <main+0xae>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x40(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <gethostbyname@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1302 <main+0x102>
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x40(%rbp),%rsi
add    $0x4,%rsi
mov    -0x58(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bcopy@plt>
jmp    133e <main+0x13e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x40(%rbp),%rsi
add    $0x4,%rsi
call   1090 <inet_aton@plt>
cmp    $0x0,%rax
jge    1339 <main+0x139>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    133e <main+0x13e>
mov    $0xd05,%edi
call   1040 <htons@plt>
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    137e <main+0x17e>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    $0x400,%esi
call   10a0 <listen@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x92830(%rbp)
mov    0x2c3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9282c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xc350,-0x14(%rbp)
jge    13dd <main+0x1dd>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13aa <main+0x1aa>
movl   $0x0,-0x18(%rbp)
jmp    13e9 <main+0x1e9>
lea    -0x92830(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    $0xffffffff,%edx
call   10c0 <poll@plt>
mov    %eax,-0x28(%rbp)
mov    -0x92828(%rbp),%eax
mov    0x2bc8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14fd <main+0x2fd>
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xc350,-0x14(%rbp)
jge    14aa <main+0x2aa>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,(%rax)
jge    1497 <main+0x297>
mov    -0x20(%rbp),%ecx
movslq -0x14(%rbp),%rdx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
mov    0x2b5d(%rip),%rax
mov    (%rax),%ecx
movslq -0x14(%rbp),%rdx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x4(%rax)
jmp    14aa <main+0x2aa>
jmp    149c <main+0x29c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1435 <main+0x235>
cmpl   $0xc350,-0x14(%rbp)
jne    14cf <main+0x2cf>
lea    0xba6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    14e1 <main+0x2e1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jg     14f8 <main+0x2f8>
jmp    13e4 <main+0x1e4>
jmp    14fd <main+0x2fd>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1650 <main+0x450>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1535 <main+0x335>
jmp    1642 <main+0x442>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    0x2a87(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2a86(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     163d <main+0x43d>
mov    -0x92838(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jge    15d9 <main+0x3d9>
mov    0x2a20(%rip),%rax
mov    (%rax),%rax
mov    0x2a2e(%rip),%rcx
cmp    (%rcx),%rax
jne    15c8 <main+0x3c8>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
jmp    15d4 <main+0x3d4>
lea    0xaa6(%rip),%rdi
call   10e0 <perror@plt>
jmp    1621 <main+0x421>
cmpq   $0x0,-0x30(%rbp)
jne    1609 <main+0x409>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movslq -0x14(%rbp),%rcx
lea    -0x92830(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
jmp    161c <main+0x41c>
mov    -0x92838(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rdx
call   1030 <write@plt>
jmp    1621 <main+0x421>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jg     1638 <main+0x438>
jmp    1650 <main+0x450>
jmp    163d <main+0x43d>
jmp    1642 <main+0x442>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1504 <main+0x304>
jmp    13e4 <main+0x1e4>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x927e8,%rsp
mov    %rsi,%r15
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x2,%edi
jne    1270 <main+0x60>
mov    0x2d9b(%rip),%r14
mov    (%r14),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
jns    128b <main+0x7b>
lea    0xdfd(%rip),%rdi
jmp    1307 <main+0xf7>
mov    (%r15),%rsi
lea    0xd86(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    (%r14),%eax
mov    %eax,-0x30(%rbp)
mov    0x8(%r15),%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    12cb <main+0xbb>
mov    0x8(%r15),%rdi
lea    -0x34(%rbp),%rsi
call   10a0 <inet_aton@plt>
test   %rax,%rax
jns    12d9 <main+0xc9>
lea    0xd88(%rip),%rdi
jmp    1307 <main+0xf7>
mov    (%rax),%edx
mov    0x4(%rax),%edi
lea    -0x34(%rbp),%rsi
call   10c0 <bcopy@plt>
mov    $0xd05,%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
lea    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%r14d
mov    %r14d,%edi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jns    1316 <main+0x106>
lea    0xd31(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %r14d,%edi
mov    $0x400,%esi
call   10b0 <listen@plt>
mov    %r14d,-0x92810(%rbp)
mov    0x2ca7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9280c(%rbp)
mov    $0x30,%eax
xchg   %ax,%ax
movl   $0xffffffff,-0x92834(%rbp,%rax,1)
ff ff ff ff
movl   $0xffffffff,-0x92828(%rbp,%rax,1)
ff ff ff ff
movl   $0xffffffff,-0x9281c(%rbp,%rax,1)
ff ff ff ff
cmp    $0x927c0,%rax
je     137a <main+0x16a>
movl   $0xffffffff,-0x92810(%rbp,%rax,1)
ff ff ff ff
add    $0x30,%rax
jmp    1340 <main+0x130>
mov    %r12,%r15
xor    %ebx,%ebx
jmp    1398 <main+0x188>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%r14d
mov    -0x40(%rbp),%rbx
lea    0x1(%rbx),%esi
lea    -0x92810(%rbp),%rdi
mov    $0xffffffff,%edx
call   10d0 <poll@plt>
mov    %eax,%r13d
mov    0x2c22(%rip),%rax
mov    (%rax),%eax
test   %eax,-0x92808(%rbp)
je     1495 <main+0x285>
mov    %r14d,%edi
lea    -0x38(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   1110 <accept@plt>
mov    $0x1,%ecx
mov    $0x4,%esi
xor    %edx,%edx
cmpl   $0x0,-0x92804(%rbp,%rdx,1)
js     1431 <main+0x221>
nopw   0x0(%rax,%rax,1)
cmpl   $0x0,-0x927f8(%rbp,%rdx,1)
js     143d <main+0x22d>
cmpl   $0x0,-0x927ec(%rbp,%rdx,1)
js     144d <main+0x23d>
cmp    $0x92790,%rdx
je     1562 <main+0x352>
cmpl   $0x0,-0x927e0(%rbp,%rdx,1)
js     145d <main+0x24d>
add    $0x4,%rcx
add    $0x30,%rdx
add    $0x4,%rsi
cmpl   $0x0,-0x92804(%rbp,%rdx,1)
jns    13f0 <main+0x1e0>
add    %rbp,%rdx
add    $0xfffffffffff6d7fc,%rdx
jmp    146a <main+0x25a>
add    $0x1,%rcx
add    %rbp,%rdx
add    $0xfffffffffff6d808,%rdx
jmp    146a <main+0x25a>
add    $0x2,%rcx
add    %rbp,%rdx
add    $0xfffffffffff6d814,%rdx
jmp    146a <main+0x25a>
add    %rbp,%rdx
add    $0xfffffffffff6d820,%rdx
mov    %rsi,%rcx
mov    %ecx,%esi
mov    %eax,(%rdx)
mov    0x2b63(%rip),%rax
mov    (%rax),%eax
lea    (%rsi,%rsi,2),%rdx
mov    %eax,-0x9280c(%rbp,%rdx,4)
cmp    %ecx,%ebx
cmovl  %ecx,%ebx
cmp    $0x2,%r13d
jl     1398 <main+0x188>
add    $0xffffffff,%r13d
test   %ebx,%ebx
jle    1398 <main+0x188>
mov    %rbx,-0x40(%rbp)
mov    %ebx,%eax
shl    $0x2,%rax
lea    (%rax,%rax,2),%r14
add    $0xc,%r14
mov    $0xc,%ebx
jmp    1501 <main+0x2f1>
mov    0x2af3(%rip),%rax
mov    (%rax),%rax
mov    0x2b01(%rip),%rcx
cmp    (%rcx),%rax
jne    1554 <main+0x344>
mov    %r12d,%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x92810(%rbp,%rbx,1)
ff ff ff ff
lea    -0x1(%r13),%eax
cmp    $0x2,%r13d
mov    %eax,%r13d
jl     1390 <main+0x180>
add    $0xc,%rbx
cmp    %rbx,%r14
je     1390 <main+0x180>
mov    -0x92810(%rbp,%rbx,1),%r12d
ff
test   %r12d,%r12d
js     14f4 <main+0x2e4>
mov    0x2acb(%rip),%rax
mov    (%rax),%eax
mov    0x2aba(%rip),%rcx
or     (%rcx),%eax
test   %eax,-0x92808(%rbp,%rbx,1)
je     14f4 <main+0x2e4>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1080 <read@plt>
test   %rax,%rax
js     14b6 <main+0x2a6>
je     14d0 <main+0x2c0>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
jmp    14e3 <main+0x2d3>
lea    0xad2(%rip),%rdi
call   10f0 <perror@plt>
jmp    14e3 <main+0x2d3>
lea    0xab3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i32 }
%struct.pollfd = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@.str = [28 x i8] c"Please input %s <hostname>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [22 x i8] c"Create socket error!\0A\00"
@.str.2 = [24 x i8] c"Input Server IP error!\0A\00"
@.str.3 = [26 x i8] c"IPaddress bound failure!\0A\00"
@POLLIN = global i32 0
@.str.4 = [17 x i8] c"too many clients\00"
@POLLERR = global i32 0
@errno = global i64 0
@ECONNRESET = global i64 0
@.str.5 = [11 x i8] c"read error\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 i32
%12 = alloca i64
%13 = alloca i32
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.sockaddr_in
%16 = alloca %struct.hostent*
%17 = alloca i8*
%18 = alloca i64
%19 = alloca [50000 x %struct.pollfd]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %17
%23 = alloca i8, i64 %21
store i64 %21, i64* %18
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 2
br i1 %25, label %26, label %32
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %2
%33 = load i32, i32* @AF_INET
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
store i32 %35, i32* %8
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = call i32 @bzero(%struct.sockaddr_in* %14, i32 12)
%42 = load i32, i32* @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %42, i32* %43
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call %struct.hostent* @gethostbyname(i8* %46)
store %struct.hostent* %47, %struct.hostent** %16
%48 = icmp ne %struct.hostent* %47, null
br i1 %48, label %49, label %59
49: ; preds = %40
%50 = load %struct.hostent*, %struct.hostent** %16
%51 = getelementptr inbounds %struct.hostent, %struct.hostent* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
%54 = bitcast i32* %53 to %struct.sockaddr*
%55 = load %struct.hostent*, %struct.hostent** %16
%56 = getelementptr inbounds %struct.hostent, %struct.hostent* %55, i32 0, i32 0
%57 = load i32, i32* %56
%58 = call i32 @bcopy(i32 %52, %struct.sockaddr* %54, i32 %57)
br label %70
59: ; preds = %40
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
%64 = call i64 @inet_aton(i8* %62, i32* %63)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %59
br label %70
70: ; preds = %69, %49
%71 = call i32 @htons(i32 3333)
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
store i32 %71, i32* %72
%73 = load i32, i32* %8
%74 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%75 = call i64 @bind(i32 %73, %struct.sockaddr* %74, i32 12)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %70
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %70
%81 = load i32, i32* %8
%82 = call i32 @listen(i32 %81, i32 1024)
%83 = load i32, i32* %8
%84 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 0
%85 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %84, i32 0, i32 0
store i32 %83, i32* %85
%86 = load i32, i32* @POLLIN
%87 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 0
%88 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %87, i32 0, i32 1
store i32 %86, i32* %88
store i32 1, i32* %6
br label %89
89: ; preds = %97, %80
%90 = load i32, i32* %6
%91 = icmp slt i32 %90, 50000
br i1 %91, label %92, label %100
92: ; preds = %89
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %94
%96 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %95, i32 0, i32 0
store i32 -1, i32* %96
br label %97
97: ; preds = %92
%98 = load i32, i32* %6
%99 = add nsw i32 %98, 1
store i32 %99, i32* %6
br label %89
100: ; preds = %89
store i32 0, i32* %7
br label %101
101: ; preds = %227, %158, %100
br label %102
102: ; preds = %101
%103 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 0
%104 = load i32, i32* %7
%105 = add nsw i32 %104, 1
%106 = call i32 @poll(%struct.pollfd* %103, i32 %105, i32 -1)
store i32 %106, i32* %11
%107 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 0
%108 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %107, i32 0, i32 2
%109 = load i32, i32* %108
%110 = load i32, i32* @POLLIN
%111 = and i32 %109, %110
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %160
113: ; preds = %102
%114 = load i32, i32* %8
%115 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%116 = call i32 @accept(i32 %114, %struct.sockaddr* %115, i32* %13)
store i32 %116, i32* %9
store i32 1, i32* %6
br label %117
117: ; preds = %139, %113
%118 = load i32, i32* %6
%119 = icmp slt i32 %118, 50000
br i1 %119, label %120, label %142
120: ; preds = %117
%121 = load i32, i32* %6
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %122
%124 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %123, i32 0, i32 0
%125 = load i32, i32* %124
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %138
127: ; preds = %120
%128 = load i32, i32* %9
%129 = load i32, i32* %6
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %130
%132 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %131, i32 0, i32 0
store i32 %128, i32* %132
%133 = load i32, i32* @POLLIN
%134 = load i32, i32* %6
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %135
%137 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %136, i32 0, i32 1
store i32 %133, i32* %137
br label %142
138: ; preds = %120
br label %139
139: ; preds = %138
%140 = load i32, i32* %6
%141 = add nsw i32 %140, 1
store i32 %141, i32* %6
br label %117
142: ; preds = %127, %117
%143 = load i32, i32* %6
%144 = icmp eq i32 %143, 50000
br i1 %144, label %145, label %148
145: ; preds = %142
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%147 = call i32 @exit(i32 1)
unreachable
148: ; preds = %142
%149 = load i32, i32* %6
%150 = load i32, i32* %7
%151 = icmp sgt i32 %149, %150
br i1 %151, label %152, label %154
152: ; preds = %148
%153 = load i32, i32* %6
store i32 %153, i32* %7
br label %154
154: ; preds = %152, %148
%155 = load i32, i32* %11
%156 = add nsw i32 %155, -1
store i32 %156, i32* %11
%157 = icmp sle i32 %156, 0
br i1 %157, label %158, label %159
158: ; preds = %154
br label %101
159: ; preds = %154
br label %160
160: ; preds = %159, %102
store i32 1, i32* %6
br label %161
161: ; preds = %224, %160
%162 = load i32, i32* %6
%163 = load i32, i32* %7
%164 = icmp sle i32 %162, %163
br i1 %164, label %165, label %227
165: ; preds = %161
%166 = load i32, i32* %6
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %167
%169 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %168, i32 0, i32 0
%170 = load i32, i32* %169
store i32 %170, i32* %10
%171 = icmp slt i32 %170, 0
br i1 %171, label %172, label %173
172: ; preds = %165
br label %224
173: ; preds = %165
%174 = load i32, i32* %6
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %175
%177 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %176, i32 0, i32 2
%178 = load i32, i32* %177
%179 = load i32, i32* @POLLIN
%180 = load i32, i32* @POLLERR
%181 = or i32 %179, %180
%182 = and i32 %178, %181
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %223
184: ; preds = %173
%185 = load i32, i32* %10
%186 = call i64 @read(i32 %185, i8* %23, i32 1024)
store i64 %186, i64* %12
%187 = icmp slt i64 %186, 0
br i1 %187, label %188, label %202
188: ; preds = %184
%189 = load i64, i64* @errno
%190 = load i64, i64* @ECONNRESET
%191 = icmp eq i64 %189, %190
br i1 %191, label %192, label %199
192: ; preds = %188
%193 = load i32, i32* %10
%194 = call i32 @close(i32 %193)
%195 = load i32, i32* %6
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %196
%198 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %197, i32 0, i32 0
store i32 -1, i32* %198
br label %201
199: ; preds = %188
%200 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %201
201: ; preds = %199, %192
br label %217
202: ; preds = %184
%203 = load i64, i64* %12
%204 = icmp eq i64 %203, 0
br i1 %204, label %205, label %212
205: ; preds = %202
%206 = load i32, i32* %10
%207 = call i32 @close(i32 %206)
%208 = load i32, i32* %6
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %19, i64 0, i64 %209
%211 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %210, i32 0, i32 0
store i32 -1, i32* %211
br label %216
212: ; preds = %202
%213 = load i32, i32* %10
%214 = load i64, i64* %12
%215 = call i32 @write(i32 %213, i8* %23, i64 %214)
br label %216
216: ; preds = %212, %205
br label %217
217: ; preds = %216, %201
%218 = load i32, i32* %11
%219 = add nsw i32 %218, -1
store i32 %219, i32* %11
%220 = icmp sle i32 %219, 0
br i1 %220, label %221, label %222
221: ; preds = %217
br label %227
222: ; preds = %217
br label %223
223: ; preds = %222, %173
br label %224
224: ; preds = %223, %172
%225 = load i32, i32* %6
%226 = add nsw i32 %225, 1
store i32 %226, i32* %6
br label %161
227: ; preds = %221, %161
br label %101
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.pollfd = type { i32, i32, i32 }
%struct.hostent = type { i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@.str = [28 x i8] c"Please input %s <hostname>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@POLLIN = global i32 0
@.str.4 = [17 x i8] c"too many clients\00"
@POLLERR = global i32 0
@errno = global i64 0
@ECONNRESET = global i64 0
@.str.5 = [11 x i8] c"read error\00"
@str = [25 x i8] c"IPaddress bound failure!\00"
@str.6 = [23 x i8] c"Input Server IP error!\00"
@str.7 = [21 x i8] c"Create socket error!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [50000 x %struct.pollfd]
%6 = bitcast i32* %3 to i8*
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = bitcast [50000 x %struct.pollfd]* %5 to i8*
%12 = icmp eq i32 %0, 2
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%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 slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call %struct.hostent* @gethostbyname(i8* %30)
%32 = icmp eq %struct.hostent* %31, null
br i1 %32, label %41, label %33
33: ; preds = %25
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i64 0, i32 1
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%37 = bitcast i32* %36 to %struct.sockaddr*
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i64 0, i32 0
%39 = load i32, i32* %38
%40 = call i32 @bcopy(i32 %35, %struct.sockaddr* %37, i32 %39)
br label %49
41: ; preds = %25
%42 = load i8*, i8** %29
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%44 = call i64 @inet_aton(i8* %42, i32* %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %41, %33
%50 = call i32 @htons(i32 3333)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %50, i32* %51
%52 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%53 = call i64 @bind(i32 %20, %struct.sockaddr* %52, i32 12)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49
%59 = call i32 @listen(i32 %20, i32 1024)
%60 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 0, i32 0
store i32 %20, i32* %60
%61 = load i32, i32* @POLLIN
%62 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 0, i32 1
store i32 %61, i32* %62
br label %66
63: ; preds = %66
%64 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 0
%65 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 0, i32 2
br label %78
66: ; preds = %75, %58
%67 = phi i64 [ 1, %58 ], [ %77, %75 ]
%68 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %67, i32 0
store i32 -1, i32* %68
%69 = add nuw nsw i64 %67, 1
%70 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %69, i32 0
store i32 -1, i32* %70
%71 = add nuw nsw i64 %67, 2
%72 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %71, i32 0
store i32 -1, i32* %72
%73 = add nuw nsw i64 %67, 3
%74 = icmp eq i64 %73, 50000
br i1 %74, label %63, label %75
75: ; preds = %66
%76 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %73, i32 0
store i32 -1, i32* %76
%77 = add nuw nsw i64 %67, 4
br label %66
78: ; preds = %130, %63
%79 = phi i32 [ 0, %63 ], [ %131, %130 ]
%80 = add nsw i32 %79, 1
%81 = call i32 @poll(%struct.pollfd* %64, i32 %80, i32 -1)
%82 = load i32, i32* %65
%83 = load i32, i32* @POLLIN
%84 = and i32 %83, %82
%85 = icmp eq i32 %84, 0
br i1 %85, label %126, label %86
86: ; preds = %78
%87 = call i32 @accept(i32 %20, %struct.sockaddr* %52, i32* %3)
br label %88
88: ; preds = %110, %86
%89 = phi i64 [ 1, %86 ], [ %111, %110 ]
%90 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %89, i32 0
%91 = load i32, i32* %90
%92 = icmp slt i32 %91, 0
br i1 %92, label %115, label %93
93: ; preds = %88
%94 = add nuw nsw i64 %89, 1
%95 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %94, i32 0
%96 = load i32, i32* %95
%97 = icmp slt i32 %96, 0
br i1 %97, label %115, label %98
98: ; preds = %93
%99 = add nuw nsw i64 %89, 2
%100 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %99, i32 0
%101 = load i32, i32* %100
%102 = icmp slt i32 %101, 0
br i1 %102, label %115, label %103
103: ; preds = %98
%104 = add nuw nsw i64 %89, 3
%105 = icmp eq i64 %104, 50000
br i1 %105, label %112, label %106
106: ; preds = %103
%107 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %104, i32 0
%108 = load i32, i32* %107
%109 = icmp slt i32 %108, 0
br i1 %109, label %115, label %110
110: ; preds = %106
%111 = add nuw nsw i64 %89, 4
br label %88
112: ; preds = %103
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %106, %98, %93, %88
%116 = phi i64 [ %89, %88 ], [ %94, %93 ], [ %99, %98 ], [ %104, %106 ]
%117 = phi i32* [ %90, %88 ], [ %95, %93 ], [ %100, %98 ], [ %107, %106 ]
%118 = trunc i64 %116 to i32
%119 = and i64 %116, 4294967295
store i32 %87, i32* %117
%120 = load i32, i32* @POLLIN
%121 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %119, i32 1
store i32 %120, i32* %121
%122 = icmp slt i32 %79, %118
%123 = select i1 %122, i32 %118, i32 %79
%124 = add nsw i32 %81, -1
%125 = icmp slt i32 %81, 2
br i1 %125, label %130, label %126
126: ; preds = %115, %78
%127 = phi i32 [ %124, %115 ], [ %81, %78 ]
%128 = phi i32 [ %123, %115 ], [ %79, %78 ]
%129 = icmp slt i32 %128, 1
br i1 %129, label %130, label %132
130: ; preds = %169, %166, %126, %115
%131 = phi i32 [ %123, %115 ], [ %128, %126 ], [ %128, %166 ], [ %128, %169 ]
br label %78
132: ; preds = %126
%133 = add nuw i32 %128, 1
%134 = zext i32 %133 to i64
br label %135
135: ; preds = %132, %169
%136 = phi i64 [ 1, %132 ], [ %171, %169 ]
%137 = phi i32 [ %127, %132 ], [ %170, %169 ]
%138 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %136, i32 0
%139 = load i32, i32* %138
%140 = icmp slt i32 %139, 0
br i1 %140, label %169, label %141
141: ; preds = %135
%142 = getelementptr inbounds [50000 x %struct.pollfd], [50000 x %struct.pollfd]* %5, i64 0, i64 %136, i32 2
%143 = load i32, i32* %142
%144 = load i32, i32* @POLLIN
%145 = load i32, i32* @POLLERR
%146 = or i32 %145, %144
%147 = and i32 %146, %143
%148 = icmp eq i32 %147, 0
br i1 %148, label %169, label %149
149: ; preds = %141
%150 = call i64 @read(i32 %139, i8* %10, i32 1024)
%151 = icmp slt i64 %150, 0
br i1 %151, label %152, label %160
152: ; preds = %149
%153 = load i64, i64* @errno
%154 = load i64, i64* @ECONNRESET
%155 = icmp eq i64 %153, %154
br i1 %155, label %156, label %158
156: ; preds = %152
%157 = call i32 @close(i32 %139)
store i32 -1, i32* %138
br label %166
158: ; preds = %152
%159 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %166
160: ; preds = %149
%161 = icmp eq i64 %150, 0
br i1 %161, label %162, label %164
162: ; preds = %160
%163 = call i32 @close(i32 %139)
store i32 -1, i32* %138
br label %166
164: ; preds = %160
%165 = call i32 @write(i32 %139, i8* %10, i64 %150)
br label %166
166: ; preds = %162, %164, %156, %158
%167 = add nsw i32 %137, -1
%168 = icmp slt i32 %137, 2
br i1 %168, label %130, label %169
169: ; preds = %141, %166, %135
%170 = phi i32 [ %137, %135 ], [ %167, %166 ], [ %137, %141 ]
%171 = add nuw nsw i64 %136, 1
%172 = icmp eq i64 %171, %134
br i1 %172, label %130, label %135
}