#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*/ serv_addr;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_COPY(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOMAXCONN;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ str_echo(int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int sockfd, n, newsockfd, childpid, servlen, fin, i, tab[FD_SETSIZE], nbfd,
      maxfd, sockcli;
  struct sockaddr_in serv_addr, cli_addr;
  socklen_t clilen;
  fd_set rset, pset;
  if (argc != 2) {
    usage();
    exit(1);
  }
  if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
    perror("servmulti : Probleme socket\n");
    exit(2);
  }
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = PF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(atoi(argv[1]));
  maxfd = sockfd + 1;
  if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
    perror("servmulti : erreur bind\n");
    exit(1);
  }
  if (listen(sockfd, SOMAXCONN) < 0) {
    perror("servmulti : erreur listen\n");
    exit(1);
  }
  for (i = 0; i < FD_SETSIZE; i++) {
    tab[i] = -1;
  }
  FD_ZERO(&rset);
  FD_ZERO(&pset);
  FD_SET(sockfd, &rset);
  for (;;) {
    FD_COPY(&rset, &pset);
    nbfd = select(maxfd, &pset, NULL, NULL, NULL);
    if (nbfd < 0) {
      perror("servmulti : erreur select");
    }
    if (FD_ISSET(sockfd, &pset)) {
      clilen = sizeof(cli_addr);
      newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
      if (newsockfd < 0) {
        perror("servmulti : erreur accept\n");
        exit(1);
      }
    }
    i = 0;
    while ((i < FD_SETSIZE) && (tab[i] >= 0))
      i++;
    if (i == FD_SETSIZE)
      exit(1);
    tab[i] = newsockfd;
    FD_SET(newsockfd, &rset);
    if (newsockfd >= maxfd) {
      maxfd = newsockfd + 1;
    }
    i = 0;
    while ((nbfd > 0) && (i < FD_SETSIZE)) {
      if (((sockcli = tab[i])) >= 0 && (FD_ISSET(sockcli, &pset))) {
        if (str_echo(sockcli) == 0) {
          close(sockcli);
          tab[i] = -1;
          FD_CLR(sockcli, &rset);
        }
        nbfd--;
      }
      i++;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1291 <main+0x61>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12cc <main+0x9c>
lea    0xd43(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    134a <main+0x11a>
lea    0xce2(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    137b <main+0x14b>
lea    0xcca(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2c3c(%rip),%rcx
cmp    (%rcx),%eax
jge    13b1 <main+0x181>
mov    -0x80(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1382 <main+0x152>
lea    -0x70(%rbp),%rdi
call   1090 <FD_ZERO@plt>
lea    -0x74(%rbp),%rdi
call   1090 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1140 <FD_SET@plt>
lea    -0x70(%rbp),%rdi
lea    -0x74(%rbp),%rsi
call   10c0 <FD_COPY@plt>
mov    -0x48(%rbp),%edi
lea    -0x74(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10a0 <select@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    140c <main+0x1dc>
lea    0xc4a(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1461 <main+0x231>
movl   $0xc,-0x6c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x68(%rbp),%rsi
lea    -0x6c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    145c <main+0x22c>
lea    0xc1e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    1461 <main+0x231>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
xor    %eax,%eax
mov    0x2b54(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x81(%rbp)
jge    1497 <main+0x267>
mov    -0x80(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setge  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    14aa <main+0x27a>
jmp    14b8 <main+0x288>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1468 <main+0x238>
mov    -0x2c(%rbp),%eax
mov    0x2b06(%rip),%rcx
cmp    (%rcx),%eax
jne    14d4 <main+0x2a4>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x80(%rbp),%rax
mov    -0x1c(%rbp),%edx
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1140 <FD_SET@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jl     1503 <main+0x2d3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x44(%rbp)
mov    %al,-0x82(%rbp)
jle    1531 <main+0x301>
mov    -0x2c(%rbp),%eax
mov    0x2aa2(%rip),%rcx
cmp    (%rcx),%eax
setl   %al
mov    %al,-0x82(%rbp)
mov    -0x82(%rbp),%al
test   $0x1,%al
jne    1544 <main+0x314>
jmp    15bd <main+0x38d>
mov    -0x80(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jl     15af <main+0x37f>
mov    -0x4c(%rbp),%edi
lea    -0x74(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15af <main+0x37f>
mov    -0x4c(%rbp),%edi
call   1040 <str_echo@plt>
cmp    $0x0,%rax
jne    15a6 <main+0x376>
mov    -0x4c(%rbp),%edi
call   1080 <close@plt>
mov    -0x80(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x4c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1120 <FD_CLR@plt>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    150a <main+0x2da>
jmp    13cf <main+0x19f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x2,%edi
jne    129a <main+0x6a>
mov    %rsi,%r14
mov    0x2d52(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
jns    12ab <main+0x7b>
lea    0xd75(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
xor    %eax,%eax
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %eax,%r13d
lea    -0x50(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    (%rbx),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x4c(%rbp)
mov    0x8(%r14),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x50(%rbp)
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jns    1308 <main+0xd8>
lea    0xd17(%rip),%rdi
jmp    1325 <main+0xf5>
mov    0x2cc9(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
call   10b0 <listen@plt>
test   %rax,%rax
jns    1334 <main+0x104>
lea    0xd11(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %r13d,%ebx
mov    0x2c8a(%rip),%rax
mov    (%rax),%edx
test   %edx,%edx
jle    1355 <main+0x125>
shl    $0x2,%rdx
mov    %r12,%rdi
mov    $0xff,%esi
call   1070 <memset@plt>
mov    %ebx,%r13d
add    $0x1,%r13d
lea    -0x2c(%rbp),%r14
mov    %r14,%rdi
call   1090 <FD_ZERO@plt>
lea    -0x30(%rbp),%rdi
call   1090 <FD_ZERO@plt>
mov    %ebx,-0x34(%rbp)
mov    %ebx,%edi
mov    %r14,%rsi
call   1140 <FD_SET@plt>
mov    %rax,-0x40(%rbp)
jmp    1393 <main+0x163>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%r13d
lea    -0x2c(%rbp),%rdi
lea    -0x30(%rbp),%r15
mov    %r15,%rsi
call   10c0 <FD_COPY@plt>
mov    %r13d,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <select@plt>
mov    %eax,%r14d
test   %eax,%eax
js     14eb <main+0x2bb>
mov    -0x34(%rbp),%ebx
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     13f4 <main+0x1c4>
movl   $0xc,-0x38(%rbp)
mov    %ebx,%edi
lea    -0x60(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1100 <accept@plt>
mov    %rax,-0x40(%rbp)
test   %eax,%eax
js     1506 <main+0x2d6>
mov    0x2bcd(%rip),%rax
mov    (%rax),%eax
xor    %ecx,%ecx
test   %eax,%eax
jle    1430 <main+0x200>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpl   $0x0,(%r12,%rcx,4)
js     1430 <main+0x200>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1410 <main+0x1e0>
jmp    14fc <main+0x2cc>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %eax,%ecx
je     14fc <main+0x2cc>
mov    %ecx,%eax
mov    -0x40(%rbp),%rbx
mov    %ebx,(%r12,%rax,4)
mov    %ebx,%edi
lea    -0x2c(%rbp),%rsi
call   1140 <FD_SET@plt>
lea    0x1(%rbx),%r15d
cmp    %r13d,%ebx
cmovl  %r13d,%r15d
mov    %r15d,%r13d
test   %r14d,%r14d
jle    1393 <main+0x163>
mov    0x2b5d(%rip),%rax
cmpl   $0x0,(%rax)
mov    %r15d,%r13d
jle    1393 <main+0x163>
mov    $0x1,%r13d
nopl   (%rax)
mov    -0x4(%r12,%r13,4),%ebx
test   %ebx,%ebx
js     14c4 <main+0x294>
mov    %ebx,%edi
lea    -0x30(%rbp),%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     14c4 <main+0x294>
mov    %ebx,%edi
call   1040 <str_echo@plt>
test   %rax,%rax
jne    14c0 <main+0x290>
mov    %ebx,%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%r12,%r13,4)
ff ff
mov    %ebx,%edi
lea    -0x2c(%rbp),%rsi
call   1120 <FD_CLR@plt>
add    $0xffffffff,%r14d
lea    0x1(%r13),%rax
mov    0x2af9(%rip),%rcx
movslq (%rcx),%rcx
test   %r14d,%r14d
jle    1390 <main+0x160>
cmp    %rcx,%r13
mov    %rax,%r13
jl     1480 <main+0x250>
mov    %r15d,%r13d
jmp    1393 <main+0x163>
lea    0xb5f(%rip),%rdi
call   10f0 <perror@plt>
jmp    13c0 <main+0x190>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xb5e(%rip),%rdi
jmp    1325 <main+0xf5>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [29 x i8] c"servmulti : Probleme socket\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [25 x i8] c"servmulti : erreur bind\0A\00"
@SOMAXCONN = global i32 0
@.str.2 = [27 x i8] c"servmulti : erreur listen\0A\00"
@.str.3 = [26 x i8] c"servmulti : erreur select\00"
@.str.4 = [27 x i8] c"servmulti : erreur accept\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.sockaddr_in
%19 = alloca %struct.sockaddr_in
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = load i32, i32* @FD_SETSIZE
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %13
%26 = alloca i32, i64 %24
store i64 %24, i64* %14
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %2
%30 = call i32 (...) @usage()
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %2
%33 = load i32, i32* @PF_INET
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
store i32 %35, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @exit(i32 2)
unreachable
40: ; preds = %32
%41 = bitcast %struct.sockaddr_in* %18 to i8*
%42 = call i32 @memset(i8* %41, i32 0, i32 12)
%43 = load i32, i32* @PF_INET
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 2
store i32 %43, i32* %44
%45 = load i32, i32* @INADDR_ANY
%46 = call i32 @htonl(i32 %45)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 1
%48 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %47, i32 0, i32 0
store i32 %46, i32* %48
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
%53 = call i32 @htons(i32 %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
store i32 %53, i32* %54
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %16
%57 = load i32, i32* %6
%58 = bitcast %struct.sockaddr_in* %18 to %struct.sockaddr*
%59 = call i64 @bind(i32 %57, %struct.sockaddr* %58, i32 12)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %40
%62 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %40
%65 = load i32, i32* %6
%66 = load i32, i32* @SOMAXCONN
%67 = call i64 @listen(i32 %65, i32 %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %64
store i32 0, i32* %12
br label %73
73: ; preds = %81, %72
%74 = load i32, i32* %12
%75 = load i32, i32* @FD_SETSIZE
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %84
77: ; preds = %73
%78 = load i32, i32* %12
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %26, i64 %79
store i32 -1, i32* %80
br label %81
81: ; preds = %77
%82 = load i32, i32* %12
%83 = add nsw i32 %82, 1
store i32 %83, i32* %12
br label %73
84: ; preds = %73
%85 = call i32 @FD_ZERO(i32* %21)
%86 = call i32 @FD_ZERO(i32* %22)
%87 = load i32, i32* %6
%88 = call i32 @FD_SET(i32 %87, i32* %21)
br label %89
89: ; preds = %184, %84
%90 = call i32 @FD_COPY(i32* %21, i32* %22)
%91 = load i32, i32* %16
%92 = call i32 @select(i32 %91, i32* %22, i32* null, i32* null, i32* null)
store i32 %92, i32* %15
%93 = load i32, i32* %15
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %89
%96 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %97
97: ; preds = %95, %89
%98 = load i32, i32* %6
%99 = call i64 @FD_ISSET(i32 %98, i32* %22)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %111
101: ; preds = %97
store i32 12, i32* %20
%102 = load i32, i32* %6
%103 = bitcast %struct.sockaddr_in* %19 to %struct.sockaddr*
%104 = call i32 @accept(i32 %102, %struct.sockaddr* %103, i32* %20)
store i32 %104, i32* %8
%105 = load i32, i32* %8
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %101
%108 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %101
br label %111
111: ; preds = %110, %97
store i32 0, i32* %12
br label %112
112: ; preds = %124, %111
%113 = load i32, i32* %12
%114 = load i32, i32* @FD_SETSIZE
%115 = icmp slt i32 %113, %114
br i1 %115, label %116, label %122
116: ; preds = %112
%117 = load i32, i32* %12
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i32, i32* %26, i64 %118
%120 = load i32, i32* %119
%121 = icmp sge i32 %120, 0
br label %122
122: ; preds = %116, %112
%123 = phi i1 [ false, %112 ], [ %121, %116 ]
br i1 %123, label %124, label %127
124: ; preds = %122
%125 = load i32, i32* %12
%126 = add nsw i32 %125, 1
store i32 %126, i32* %12
br label %112
127: ; preds = %122
%128 = load i32, i32* %12
%129 = load i32, i32* @FD_SETSIZE
%130 = icmp eq i32 %128, %129
br i1 %130, label %131, label %133
131: ; preds = %127
%132 = call i32 @exit(i32 1)
unreachable
133: ; preds = %127
%134 = load i32, i32* %8
%135 = load i32, i32* %12
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %26, i64 %136
store i32 %134, i32* %137
%138 = load i32, i32* %8
%139 = call i32 @FD_SET(i32 %138, i32* %21)
%140 = load i32, i32* %8
%141 = load i32, i32* %16
%142 = icmp sge i32 %140, %141
br i1 %142, label %143, label %146
143: ; preds = %133
%144 = load i32, i32* %8
%145 = add nsw i32 %144, 1
store i32 %145, i32* %16
br label %146
146: ; preds = %143, %133
store i32 0, i32* %12
br label %147
147: ; preds = %181, %146
%148 = load i32, i32* %15
%149 = icmp sgt i32 %148, 0
br i1 %149, label %150, label %154
150: ; preds = %147
%151 = load i32, i32* %12
%152 = load i32, i32* @FD_SETSIZE
%153 = icmp slt i32 %151, %152
br label %154
154: ; preds = %150, %147
%155 = phi i1 [ false, %147 ], [ %153, %150 ]
br i1 %155, label %156, label %184
156: ; preds = %154
%157 = load i32, i32* %12
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i32, i32* %26, i64 %158
%160 = load i32, i32* %159
store i32 %160, i32* %17
%161 = icmp sge i32 %160, 0
br i1 %161, label %162, label %181
162: ; preds = %156
%163 = load i32, i32* %17
%164 = call i64 @FD_ISSET(i32 %163, i32* %22)
%165 = icmp ne i64 %164, 0
br i1 %165, label %166, label %181
166: ; preds = %162
%167 = load i32, i32* %17
%168 = call i64 @str_echo(i32 %167)
%169 = icmp eq i64 %168, 0
br i1 %169, label %170, label %178
170: ; preds = %166
%171 = load i32, i32* %17
%172 = call i32 @close(i32 %171)
%173 = load i32, i32* %12
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i32, i32* %26, i64 %174
store i32 -1, i32* %175
%176 = load i32, i32* %17
%177 = call i32 @FD_CLR(i32 %176, i32* %21)
br label %178
178: ; preds = %170, %166
%179 = load i32, i32* %15
%180 = add nsw i32 %179, -1
store i32 %180, i32* %15
br label %181
181: ; preds = %178, %162, %156
%182 = load i32, i32* %12
%183 = add nsw i32 %182, 1
store i32 %183, i32* %12
br label %147
184: ; preds = %154
br label %89
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [29 x i8] c"servmulti : Probleme socket\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [25 x i8] c"servmulti : erreur bind\0A\00"
@SOMAXCONN = global i32 0
@.str.2 = [27 x i8] c"servmulti : erreur listen\0A\00"
@.str.3 = [26 x i8] c"servmulti : erreur select\00"
@.str.4 = [27 x i8] c"servmulti : erreur accept\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = load i32, i32* @FD_SETSIZE
%9 = zext i32 %8 to i64
%10 = alloca i32, i64 %9
%11 = bitcast i32* %10 to i8*
%12 = bitcast %struct.sockaddr_in* %3 to i8*
%13 = bitcast %struct.sockaddr_in* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = icmp eq i32 %0, 2
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = tail call i32 (...) @usage()
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* @PF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = tail call i32 @socket(i32 %22, i32 %23, i32 0)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 2)
unreachable
29: ; preds = %21
%30 = call i32 @memset(i8* %12, i32 0, i32 12)
%31 = load i32, i32* @PF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %31, i32* %32
%33 = load i32, i32* @INADDR_ANY
%34 = call i32 @htonl(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %34, i32* %35
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
%39 = call i32 @htons(i32 %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %39, i32* %40
%41 = add nuw nsw i32 %24, 1
%42 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%43 = call i64 @bind(i32 %24, %struct.sockaddr* %42, i32 12)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %29
%46 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %29
%49 = load i32, i32* @SOMAXCONN
%50 = call i64 @listen(i32 %24, i32 %49)
%51 = icmp slt i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %48
%53 = load i32, i32* @FD_SETSIZE
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = zext i32 %53 to i64
%57 = shl nuw nsw i64 %56, 2
br label %61
58: ; preds = %48
%59 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55, %52
%62 = call i32 @FD_ZERO(i32* %6)
%63 = call i32 @FD_ZERO(i32* %7)
%64 = call i32 @FD_SET(i32 %24, i32* %6)
%65 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %66
66: ; preds = %115, %61
%67 = phi i32 [ %41, %61 ], [ %110, %115 ]
%68 = phi i32 [ undef, %61 ], [ %84, %115 ]
%69 = call i32 @FD_COPY(i32* %6, i32* %7)
%70 = call i32 @select(i32 %67, i32* %7, i32* null, i32* null, i32* null)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = call i64 @FD_ISSET(i32 %24, i32* %7)
%76 = icmp eq i64 %75, 0
br i1 %76, label %83, label %77
77: ; preds = %74
store i32 12, i32* %5
%78 = call i32 @accept(i32 %24, %struct.sockaddr* %65, i32* %5)
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %77, %74
%84 = phi i32 [ %78, %77 ], [ %68, %74 ]
%85 = load i32, i32* @FD_SETSIZE
%86 = icmp sgt i32 %85, 0
br i1 %86, label %87, label %99
87: ; preds = %83
%88 = zext i32 %85 to i64
br label %89
89: ; preds = %87, %94
%90 = phi i64 [ 0, %87 ], [ %95, %94 ]
%91 = getelementptr inbounds i32, i32* %10, i64 %90
%92 = load i32, i32* %91
%93 = icmp sgt i32 %92, -1
br i1 %93, label %94, label %97
94: ; preds = %89
%95 = add nuw nsw i64 %90, 1
%96 = icmp eq i64 %95, %88
br i1 %96, label %102, label %89
97: ; preds = %89
%98 = trunc i64 %90 to i32
br label %99
99: ; preds = %97, %83
%100 = phi i32 [ 0, %83 ], [ %98, %97 ]
%101 = icmp eq i32 %100, %85
br i1 %101, label %102, label %104
102: ; preds = %99, %94
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %99
%105 = zext i32 %100 to i64
%106 = getelementptr inbounds i32, i32* %10, i64 %105
store i32 %84, i32* %106
%107 = call i32 @FD_SET(i32 %84, i32* %6)
%108 = icmp slt i32 %84, %67
%109 = add nsw i32 %84, 1
%110 = select i1 %108, i32 %67, i32 %109
%111 = icmp sgt i32 %70, 0
%112 = load i32, i32* @FD_SETSIZE
%113 = icmp sgt i32 %112, 0
%114 = select i1 %111, i1 %113, i1 false
br i1 %114, label %116, label %115
115: ; preds = %133, %104
br label %66
116: ; preds = %104, %133
%117 = phi i64 [ %135, %133 ], [ 0, %104 ]
%118 = phi i32 [ %134, %133 ], [ %70, %104 ]
%119 = getelementptr inbounds i32, i32* %10, i64 %117
%120 = load i32, i32* %119
%121 = icmp sgt i32 %120, -1
br i1 %121, label %122, label %133
122: ; preds = %116
%123 = call i64 @FD_ISSET(i32 %120, i32* %7)
%124 = icmp eq i64 %123, 0
br i1 %124, label %133, label %125
125: ; preds = %122
%126 = call i64 @str_echo(i32 %120)
%127 = icmp eq i64 %126, 0
br i1 %127, label %128, label %131
128: ; preds = %125
%129 = call i32 @close(i32 %120)
store i32 -1, i32* %119
%130 = call i32 @FD_CLR(i32 %120, i32* %6)
br label %131
131: ; preds = %128, %125
%132 = add nsw i32 %118, -1
br label %133
133: ; preds = %131, %122, %116
%134 = phi i32 [ %132, %131 ], [ %118, %122 ], [ %118, %116 ]
%135 = add nuw nsw i64 %117, 1
%136 = icmp sgt i32 %134, 0
%137 = load i32, i32* @FD_SETSIZE
%138 = sext i32 %137 to i64
%139 = icmp slt i64 %135, %138
%140 = select i1 %136, i1 %139, i1 false
br i1 %140, label %116, label %115
}