#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
typedef int /*<<< orphan*/ sockname;
typedef int socklen_t;
typedef int /*<<< orphan*/ from;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ cadena;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FD_CLR(int, 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*/ SOCK_STREAM;
int accept(int, struct sockaddr_in *, int *);
int bind(int, struct sockaddr_in *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
main() {
  int i, sd, new_sd, fd[50], cont = 0;
  int rec_sd;
  struct sockaddr_in sockname, from;
  char cadena[250];
  socklen_t from_len;
  char nick[50][250];
  for (i = 0; i < 50; i++) {
    fd[i] = 0;
  }
  fd_set auxBuffer, buffer;
  FD_ZERO(&buffer);
  FD_ZERO(&auxBuffer);
  if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("No se puede abrir el socket cliente\n");
    exit(1);
  }
  sockname.sin_family = AF_INET;
  sockname.sin_port = htons(2000);
  sockname.sin_addr.s_addr = INADDR_ANY;
  if (bind(sd, &sockname, sizeof(sockname)) == -1) {
    perror("Error en la operación bind");
    exit(1);
  }
  from_len = sizeof(from);
  if (listen(sd, 50) == -1) {
    perror("Error en la operación de listen");
    exit(1);
  }
  FD_SET(sd, &buffer);
  while (1) {
    auxBuffer = buffer;
    if (select(FD_SETSIZE, &auxBuffer, NULL, NULL, NULL) == -1) {
      perror("Error en la funcion <select>");
      exit(1);
    }
    if (FD_ISSET(sd, &auxBuffer)) {
      if ((new_sd = accept(sd, &from, &from_len)) == -1) {
        perror("Error aceptando peticiones");
        exit(1);
      }
      FD_SET(new_sd, &buffer);
      fd[new_sd] = 1;
      if (send(new_sd, "+Ok. Usuario Conectado.", 25, 0) == -1) {
        perror("Error enviando datos en el servidor");
      }
    } else {
      for (i = 0; i < FD_SETSIZE; i++) {
        if (FD_ISSET(i, &auxBuffer)) {
          rec_sd = i;
        }
      }
      bzero(cadena, sizeof(cadena));
      if (recv(rec_sd, cadena, sizeof(cadena), 0) == -1) {
        perror("Error en la operación de recv del servidor");
      }
      printf("<<<<<<%s>>>>>\n", cadena);
      if (strncmp(cadena, "quit", 4) == 0) {
        fd[rec_sd] = 0;
        printf("Usuario <%d> ha abandonado el chat", rec_sd);
        FD_CLR(rec_sd, &buffer);
        close(rec_sd);
      } else {
        printf("\n<%d> escribio:\n", rec_sd);
        printf("%s\n", cadena);
        for (i = 0; i < FD_SETSIZE; i++) {
          if (FD_ISSET(i, &buffer) && (i != rec_sd) && (i != sd)) {
            if (send(i, cadena, sizeof(cadena), 0) == -1) {
              perror("Error enviando datos desde el servidor");
            }
          }
        }
      }
    }
  }
  close(sd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3300,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    126a <main+0x4a>
movslq -0x8(%rbp),%rax
movl   $0x0,-0xe0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1243 <main+0x23>
lea    -0x32f8(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
lea    -0x32f4(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    12bd <main+0x9d>
lea    0xd52(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf0(%rbp)
mov    $0x7d0,%edi
call   1060 <htons@plt>
mov    %eax,-0xf4(%rbp)
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf8(%rbp)
mov    -0xc(%rbp),%edi
lea    -0xf8(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    131e <main+0xfe>
lea    0xd16(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
movl   $0xc,-0x214(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x32,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1354 <main+0x134>
lea    0xcfc(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x32f8(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x32f8(%rbp),%eax
mov    %eax,-0x32f4(%rbp)
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    -0x32f4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10b0 <select@plt>
cmp    $0xffffffff,%eax
jne    13ae <main+0x18e>
lea    0xcc3(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x32f4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     144d <main+0x22d>
mov    -0xc(%rbp),%edi
lea    -0x108(%rbp),%rsi
lea    -0x214(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xffffffff,%eax
jne    13ff <main+0x1df>
lea    0xc8f(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%edi
lea    -0x32f8(%rbp),%rsi
call   1130 <FD_SET@plt>
movslq -0x10(%rbp),%rax
movl   $0x1,-0xe0(%rbp,%rax,4)
mov    -0x10(%rbp),%edi
lea    0xc73(%rip),%rsi
mov    $0x19,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    1448 <main+0x228>
lea    0xc6f(%rip),%rdi
call   10e0 <perror@plt>
jmp    161c <main+0x3fc>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2b6a(%rip),%rcx
cmp    (%rcx),%eax
jge    149b <main+0x27b>
mov    -0x8(%rbp),%edi
lea    -0x32f4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1488 <main+0x268>
mov    -0x8(%rbp),%eax
mov    %eax,-0xe8(%rbp)
jmp    148d <main+0x26d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1454 <main+0x234>
lea    -0x210(%rbp),%rdi
mov    $0xfa,%esi
call   10f0 <bzero@plt>
mov    -0xe8(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0xfa,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    14da <main+0x2ba>
lea    0xc01(%rip),%rdi
call   10e0 <perror@plt>
lea    -0x210(%rbp),%rsi
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xc14(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1559 <main+0x339>
movslq -0xe8(%rbp),%rax
movl   $0x0,-0xe0(%rbp,%rax,4)
mov    -0xe8(%rbp),%esi
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xe8(%rbp),%edi
lea    -0x32f8(%rbp),%rsi
call   1110 <FD_CLR@plt>
mov    -0xe8(%rbp),%edi
call   1090 <close@plt>
jmp    1617 <main+0x3f7>
mov    -0xe8(%rbp),%esi
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xbcf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2a35(%rip),%rcx
cmp    (%rcx),%eax
jge    1612 <main+0x3f2>
mov    -0x8(%rbp),%edi
lea    -0x32f8(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15ff <main+0x3df>
mov    -0x8(%rbp),%eax
cmp    -0xe8(%rbp),%eax
je     15ff <main+0x3df>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     15ff <main+0x3df>
mov    -0x8(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0xfa,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    15fa <main+0x3da>
lea    0xb59(%rip),%rdi
call   10e0 <perror@plt>
jmp    15ff <main+0x3df>
jmp    1604 <main+0x3e4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1589 <main+0x369>
jmp    1617 <main+0x3f7>
jmp    161c <main+0x3fc>
jmp    1363 <main+0x143>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
lea    0x4(%rsp),%rdi
call   10b0 <FD_ZERO@plt>
lea    0x8(%rsp),%rdi
call   10b0 <FD_ZERO@plt>
mov    0x2d8c(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
cmp    $0xffffffff,%eax
jne    127f <main+0x4f>
lea    0xd86(%rip),%rdi
jmp    1511 <main+0x2e1>
mov    %eax,%r14d
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    $0x7d0,%edi
call   1070 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12c6 <main+0x96>
lea    0xd64(%rip),%rdi
jmp    1511 <main+0x2e1>
movl   $0xc,0xc(%rsp)
mov    %r14d,%edi
mov    $0x32,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12ec <main+0xbc>
lea    0xd5a(%rip),%rdi
jmp    1511 <main+0x2e1>
lea    0x4(%rsp),%rsi
mov    %r14d,%edi
call   1140 <FD_SET@plt>
mov    0x4(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x2cc0(%rip),%r15
mov    (%r15),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10c0 <select@plt>
cmp    $0xffffffff,%eax
jne    132d <main+0xfd>
lea    0xd3a(%rip),%rdi
jmp    1511 <main+0x2e1>
lea    0x8(%rsp),%rbx
lea    0xdc9(%rip),%r12
jmp    136f <main+0x13f>
lea    0xdc0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    (%r15),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10c0 <select@plt>
cmp    $0xffffffff,%eax
je     1321 <main+0xf1>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     13d0 <main+0x1a0>
mov    %r14d,%edi
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
je     150a <main+0x2da>
mov    %eax,%ebp
mov    %eax,%edi
lea    0x4(%rsp),%rsi
call   1140 <FD_SET@plt>
mov    %ebp,%edi
lea    0xce9(%rip),%rsi
mov    $0x19,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    1350 <main+0x120>
lea    0xce9(%rip),%rdi
call   10f0 <perror@plt>
jmp    1350 <main+0x120>
cmpl   $0x0,(%r15)
jle    13f9 <main+0x1c9>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
cmovne %ebp,%r13d
add    $0x1,%ebp
cmp    (%r15),%ebp
jl     13e0 <main+0x1b0>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xfa,%esi
call   1100 <bzero@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0xfa,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     14f9 <main+0x2c9>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbp,%rdi
lea    0xcd4(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14ce <main+0x29e>
lea    0xce2(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
cmpl   $0x0,(%r15)
jle    1350 <main+0x120>
xor    %r12d,%r12d
jmp    148d <main+0x25d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    (%r15),%r12d
jge    133b <main+0x10b>
mov    %r12d,%edi
lea    0x4(%rsp),%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1480 <main+0x250>
cmp    %r12d,%r13d
je     1480 <main+0x250>
cmp    %r12d,%r14d
je     1480 <main+0x250>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0xfa,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    1480 <main+0x250>
lea    0xc83(%rip),%rdi
call   10f0 <perror@plt>
jmp    1480 <main+0x250>
lea    0xc41(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13d,%edi
lea    0x4(%rsp),%rsi
call   1120 <FD_CLR@plt>
mov    %r13d,%edi
call   10a0 <close@plt>
jmp    1350 <main+0x120>
lea    0xbd6(%rip),%rdi
call   10f0 <perror@plt>
jmp    1426 <main+0x1f6>
lea    0xb6e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [37 x i8] c"No se puede abrir el socket cliente\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [28 x i8] c"Error en la operaci\C3\B3n bind\00"
@.str.2 = [33 x i8] c"Error en la operaci\C3\B3n de listen\00"
@FD_SETSIZE = global i32 0
@.str.3 = [29 x i8] c"Error en la funcion <select>\00"
@.str.4 = [27 x i8] c"Error aceptando peticiones\00"
@.str.5 = [24 x i8] c"+Ok. Usuario Conectado.\00"
@.str.6 = [36 x i8] c"Error enviando datos en el servidor\00"
@.str.7 = [44 x i8] c"Error en la operaci\C3\B3n de recv del servidor\00"
@.str.8 = [15 x i8] c"<<<<<<%s>>>>>\0A\00"
@.str.9 = [5 x i8] c"quit\00"
@.str.10 = [35 x i8] c"Usuario <%d> ha abandonado el chat\00"
@.str.11 = [17 x i8] c"\0A<%d> escribio:\0A\00"
@.str.12 = [4 x i8] c"%s\0A\00"
@.str.13 = [39 x i8] c"Error enviando datos desde el servidor\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [50 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca [250 x i8]
%11 = alloca i32
%12 = alloca [50 x [250 x i8]]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %2
br label %15
15: ; preds = %22, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 50
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 %20
store i32 0, i32* %21
br label %22
22: ; preds = %18
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %15
25: ; preds = %15
%26 = call i32 @FD_ZERO(i32* %14)
%27 = call i32 @FD_ZERO(i32* %13)
%28 = load i32, i32* @AF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
store i32 %30, i32* %3
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %25
%36 = load i32, i32* @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %36, i32* %37
%38 = call i32 @htons(i32 2000)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %38, i32* %39
%40 = load i32, i32* @INADDR_ANY
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
store i32 %40, i32* %42
%43 = load i32, i32* %3
%44 = call i32 @bind(i32 %43, %struct.sockaddr_in* %8, i32 12)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %35
store i32 12, i32* %11
%50 = load i32, i32* %3
%51 = call i32 @listen(i32 %50, i32 50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %49
%57 = load i32, i32* %3
%58 = call i32 @FD_SET(i32 %57, i32* %14)
br label %59
59: ; preds = %56, %165
%60 = load i32, i32* %14
store i32 %60, i32* %13
%61 = load i32, i32* @FD_SETSIZE
%62 = call i32 @select(i32 %61, i32* %13, i32* null, i32* null, i32* null)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %59
%68 = load i32, i32* %3
%69 = call i64 @FD_ISSET(i32 %68, i32* %13)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %90
71: ; preds = %67
%72 = load i32, i32* %3
%73 = call i32 @accept(i32 %72, %struct.sockaddr_in* %9, i32* %11)
store i32 %73, i32* %4
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %71
%79 = load i32, i32* %4
%80 = call i32 @FD_SET(i32 %79, i32* %14)
%81 = load i32, i32* %4
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 %82
store i32 1, i32* %83
%84 = load i32, i32* %4
%85 = call i32 @send(i32 %84, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 25, i32 0)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %89
87: ; preds = %78
%88 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %89
89: ; preds = %87, %78
br label %165
90: ; preds = %67
store i32 0, i32* %2
br label %91
91: ; preds = %102, %90
%92 = load i32, i32* %2
%93 = load i32, i32* @FD_SETSIZE
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load i32, i32* %2
%97 = call i64 @FD_ISSET(i32 %96, i32* %13)
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = load i32, i32* %2
store i32 %100, i32* %7
br label %101
101: ; preds = %99, %95
br label %102
102: ; preds = %101
%103 = load i32, i32* %2
%104 = add nsw i32 %103, 1
store i32 %104, i32* %2
br label %91
105: ; preds = %91
%106 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%107 = call i32 @bzero(i8* %106, i32 250)
%108 = load i32, i32* %7
%109 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%110 = call i32 @recv(i32 %108, i8* %109, i32 250, i32 0)
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %114
112: ; preds = %105
%113 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %114
114: ; preds = %112, %105
%115 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %115)
%117 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%118 = call i64 @strncmp(i8* %117, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %130
120: ; preds = %114
%121 = load i32, i32* %7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 %122
store i32 0, i32* %123
%124 = load i32, i32* %7
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %7
%127 = call i32 @FD_CLR(i32 %126, i32* %14)
%128 = load i32, i32* %7
%129 = call i32 @close(i32 %128)
br label %164
130: ; preds = %114
%131 = load i32, i32* %7
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %131)
%133 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %133)
store i32 0, i32* %2
br label %135
135: ; preds = %160, %130
%136 = load i32, i32* %2
%137 = load i32, i32* @FD_SETSIZE
%138 = icmp slt i32 %136, %137
br i1 %138, label %139, label %163
139: ; preds = %135
%140 = load i32, i32* %2
%141 = call i64 @FD_ISSET(i32 %140, i32* %14)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %159
143: ; preds = %139
%144 = load i32, i32* %2
%145 = load i32, i32* %7
%146 = icmp ne i32 %144, %145
br i1 %146, label %147, label %159
147: ; preds = %143
%148 = load i32, i32* %2
%149 = load i32, i32* %3
%150 = icmp ne i32 %148, %149
br i1 %150, label %151, label %159
151: ; preds = %147
%152 = load i32, i32* %2
%153 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%154 = call i32 @send(i32 %152, i8* %153, i32 250, i32 0)
%155 = icmp eq i32 %154, -1
br i1 %155, label %156, label %158
156: ; preds = %151
%157 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
br label %158
158: ; preds = %156, %151
br label %159
159: ; preds = %158, %147, %143, %139
br label %160
160: ; preds = %159
%161 = load i32, i32* %2
%162 = add nsw i32 %161, 1
store i32 %162, i32* %2
br label %135
163: ; preds = %135
br label %164
164: ; preds = %163, %120
br label %165
165: ; preds = %164, %89
br label %59
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [37 x i8] c"No se puede abrir el socket cliente\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [28 x i8] c"Error en la operaci\C3\B3n bind\00"
@.str.2 = [33 x i8] c"Error en la operaci\C3\B3n de listen\00"
@FD_SETSIZE = global i32 0
@.str.3 = [29 x i8] c"Error en la funcion <select>\00"
@.str.4 = [27 x i8] c"Error aceptando peticiones\00"
@.str.5 = [24 x i8] c"+Ok. Usuario Conectado.\00"
@.str.6 = [36 x i8] c"Error enviando datos en el servidor\00"
@.str.7 = [44 x i8] c"Error en la operaci\C3\B3n de recv del servidor\00"
@.str.8 = [15 x i8] c"<<<<<<%s>>>>>\0A\00"
@.str.9 = [5 x i8] c"quit\00"
@.str.10 = [35 x i8] c"Usuario <%d> ha abandonado el chat\00"
@.str.11 = [17 x i8] c"\0A<%d> escribio:\0A\00"
@.str.13 = [39 x i8] c"Error enviando datos desde el servidor\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca [250 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.sockaddr_in* %1 to i8*
%8 = bitcast %struct.sockaddr_in* %2 to i8*
%9 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = call i32 @FD_ZERO(i32* %6)
%14 = call i32 @FD_ZERO(i32* %5)
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %0
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %23, i32* %24
%25 = call i32 @htons(i32 2000)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %25, i32* %26
%27 = load i32, i32* @INADDR_ANY
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %27, i32* %28
%29 = call i32 @bind(i32 %17, %struct.sockaddr_in* %1, i32 12)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
store i32 12, i32* %4
%35 = call i32 @listen(i32 %17, i32 50)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %34
%41 = call i32 @FD_SET(i32 %17, i32* %6)
%42 = load i32, i32* %6
store i32 %42, i32* %5
%43 = load i32, i32* @FD_SETSIZE
%44 = call i32 @select(i32 %43, i32* %5, i32* null, i32* null, i32* null)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %114, %40
%47 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %40, %114
%50 = phi i32 [ %115, %114 ], [ undef, %40 ]
%51 = call i64 @FD_ISSET(i32 %17, i32* %5)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i32, i32* @FD_SETSIZE
%55 = icmp sgt i32 %54, 0
br i1 %55, label %68, label %77
56: ; preds = %49
%57 = call i32 @accept(i32 %17, %struct.sockaddr_in* %2, i32* %4)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %56
%63 = call i32 @FD_SET(i32 %57, i32* %6)
%64 = call i32 @send(i32 %57, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 25, i32 0)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %114
66: ; preds = %62
%67 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %114
68: ; preds = %53, %68
%69 = phi i32 [ %74, %68 ], [ 0, %53 ]
%70 = phi i32 [ %73, %68 ], [ %50, %53 ]
%71 = call i64 @FD_ISSET(i32 %69, i32* %5)
%72 = icmp eq i64 %71, 0
%73 = select i1 %72, i32 %70, i32 %69
%74 = add nuw nsw i32 %69, 1
%75 = load i32, i32* @FD_SETSIZE
%76 = icmp slt i32 %74, %75
br i1 %76, label %68, label %77
77: ; preds = %68, %53
%78 = phi i32 [ %50, %53 ], [ %73, %68 ]
%79 = call i32 @bzero(i8* %9, i32 250)
%80 = call i32 @recv(i32 %78, i8* %9, i32 250, i32 0)
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %84
84: ; preds = %82, %77
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %9)
%86 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 %78)
%90 = call i32 @FD_CLR(i32 %78, i32* %6)
%91 = call i32 @close(i32 %78)
br label %114
92: ; preds = %84
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %78)
%94 = call i32 @puts(i8* %9)
%95 = load i32, i32* @FD_SETSIZE
%96 = icmp sgt i32 %95, 0
br i1 %96, label %97, label %114
97: ; preds = %92, %110
%98 = phi i32 [ %111, %110 ], [ 0, %92 ]
%99 = call i64 @FD_ISSET(i32 %98, i32* %6)
%100 = icmp eq i64 %99, 0
%101 = icmp eq i32 %98, %78
%102 = or i1 %100, %101
%103 = icmp eq i32 %98, %17
%104 = select i1 %102, i1 true, i1 %103
br i1 %104, label %110, label %105
105: ; preds = %97
%106 = call i32 @send(i32 %98, i8* %9, i32 250, i32 0)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
br label %110
110: ; preds = %97, %108, %105
%111 = add nuw nsw i32 %98, 1
%112 = load i32, i32* @FD_SETSIZE
%113 = icmp slt i32 %111, %112
br i1 %113, label %97, label %114
114: ; preds = %110, %92, %88, %62, %66
%115 = phi i32 [ %50, %66 ], [ %50, %62 ], [ %78, %88 ], [ %78, %92 ], [ %78, %110 ]
%116 = load i32, i32* %6
store i32 %116, i32* %5
%117 = load i32, i32* @FD_SETSIZE
%118 = call i32 @select(i32 %117, i32* %5, i32* null, i32* null, i32* null)
%119 = icmp eq i32 %118, -1
br i1 %119, label %46, label %49
}