#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;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sockaddr;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ limpia(int *, int *);
scalar_t__ listen(int, int);
int maximoDescriptor(int *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ procesar(int, int *);
scalar_t__ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct sockaddr_in sockaddr, clientaddr;
  int s;
  int ns;
  int len;
  int portno = 5001;
  int i;
  int socketCliente[10];
  int numeroClientes = 0;
  int maximo;
  fd_set descriptoresLectura;
  if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    perror("Error al crear socket");
  memset(&sockaddr, '0', sizeof(sockaddr));
  sockaddr.sin_family = AF_INET;
  sockaddr.sin_port = htons(portno);
  sockaddr.sin_addr.s_addr = INADDR_ANY;
  len = sizeof(sockaddr);
  if (bind(s, (struct sockaddr *)&sockaddr, len) < 0)
    perror("Error en el bind");
  signal(SIGCHLD, SIG_IGN);
  if (listen(s, 10) < 0)
    perror("Eror en el listen");
  while (1) {
    limpia(socketCliente, &numeroClientes);
    FD_ZERO(&descriptoresLectura);
    FD_SET(s, &descriptoresLectura);
    for (i = 0; i < numeroClientes; i++)
      FD_SET(socketCliente[i], &descriptoresLectura);
    maximo = maximoDescriptor(socketCliente, numeroClientes);
    if (maximo < s)
      maximo = s;
    if (select(maximo + 1, &descriptoresLectura, NULL, NULL, NULL) < 0) {
      perror("Error en select");
      exit(1);
    }
    for (i = 0; i < numeroClientes; i++) {
      if (FD_ISSET(socketCliente[i], &descriptoresLectura)) {
        procesar(socketCliente[i], &numeroClientes);
      }
    }
    if (FD_ISSET(s, &descriptoresLectura)) {
      if ((socketCliente[numeroClientes] =
               accept(s, (struct sockaddr *)&clientaddr, &len)) < 0)
        perror("Error en el accept");
      numeroClientes++;
      if ((numeroClientes) >= 10) {
        close(socketCliente[numeroClientes - 1]);
        numeroClientes--;
      }
      printf("Cliente nuevo aceptado");
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1389,-0x40(%rbp)
movl   $0x0,-0x74(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1278 <main+0x58>
lea    0xd8d(%rip),%rdi
call   10f0 <perror@plt>
lea    -0x20(%rbp),%rdi
mov    $0x30,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x40(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0xc,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    12da <main+0xba>
lea    0xd41(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
call   1090 <signal@plt>
mov    -0x34(%rbp),%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
cmp    $0x0,%rax
jge    1314 <main+0xf4>
lea    0xd18(%rip),%rdi
call   10f0 <perror@plt>
jmp    1319 <main+0xf9>
lea    -0x70(%rbp),%rdi
lea    -0x74(%rbp),%rsi
call   10a0 <limpia@plt>
lea    -0x7c(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x34(%rbp),%edi
lea    -0x7c(%rbp),%rsi
call   1130 <FD_SET@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    136d <main+0x14d>
movslq -0x44(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
lea    -0x7c(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1342 <main+0x122>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1120 <maximoDescriptor@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    138e <main+0x16e>
mov    -0x34(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%edi
add    $0x1,%edi
lea    -0x7c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10c0 <select@plt>
cmp    $0x0,%rax
jge    13c8 <main+0x1a8>
lea    0xc80(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    141a <main+0x1fa>
movslq -0x44(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
lea    -0x7c(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1407 <main+0x1e7>
movslq -0x44(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
lea    -0x74(%rbp),%rsi
call   1070 <procesar@plt>
jmp    140c <main+0x1ec>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13cf <main+0x1af>
mov    -0x34(%rbp),%edi
lea    -0x7c(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1496 <main+0x276>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1100 <accept@plt>
movslq -0x74(%rbp),%rcx
mov    %eax,-0x70(%rbp,%rcx,4)
cmp    $0x0,%eax
jge    145d <main+0x23d>
lea    0xbf1(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0xa,-0x74(%rbp)
jl     148a <main+0x26a>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x70(%rbp,%rax,4),%edi
call   1080 <close@plt>
mov    -0x74(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x74(%rbp)
lea    0xbcb(%rip),%rdi
call   1050 <printf@plt>
jmp    1319 <main+0xf9>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movl   $0x0,0x8(%rsp)
mov    0x2dab(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1263 <main+0x43>
lea    0xda2(%rip),%rdi
call   10f0 <perror@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x30,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    $0x1389,%edi
call   1040 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movl   $0xc,0xc(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jns    12c5 <main+0xa5>
lea    0xd56(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
call   1090 <signal@plt>
mov    %r15d,%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
test   %rax,%rax
jns    12fa <main+0xda>
lea    0xd32(%rip),%rdi
call   10f0 <perror@plt>
lea    0x20(%rsp),%r14
lea    0x8(%rsp),%r12
lea    0x1c(%rsp),%rbp
jmp    131c <main+0xfc>
nopl   0x0(%rax,%rax,1)
lea    0xd45(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   10a0 <limpia@plt>
mov    %rbp,%rdi
call   10b0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    136a <main+0x14a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x20(%rsp,%rbx,4),%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rsi
cmp    %rsi,%rbx
jl     1350 <main+0x130>
mov    %r14,%rdi
call   1120 <maximoDescriptor@plt>
cmp    %r15d,%eax
cmovl  %r15d,%eax
lea    0x1(%rax),%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10c0 <select@plt>
test   %rax,%rax
js     143a <main+0x21a>
cmpl   $0x0,0x8(%rsp)
jle    13d0 <main+0x1b0>
xor    %r13d,%r13d
jmp    13ae <main+0x18e>
add    $0x1,%r13
movslq 0x8(%rsp),%rax
cmp    %rax,%r13
jge    13d0 <main+0x1b0>
mov    0x20(%rsp,%r13,4),%edi
mov    %rbp,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     13a0 <main+0x180>
mov    0x20(%rsp,%r13,4),%edi
mov    %r12,%rsi
call   1070 <procesar@plt>
jmp    13a0 <main+0x180>
nop
mov    %r15d,%edi
mov    %rbp,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     131c <main+0xfc>
mov    %r15d,%edi
lea    0x48(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1100 <accept@plt>
movslq 0x8(%rsp),%rcx
mov    %eax,0x20(%rsp,%rcx,4)
test   %eax,%eax
js     1428 <main+0x208>
lea    0x1(%rcx),%eax
mov    %eax,0x8(%rsp)
cmp    $0x9,%ecx
jl     1310 <main+0xf0>
mov    %ecx,%eax
mov    0x20(%rsp,%rax,4),%edi
call   1080 <close@plt>
addl   $0xffffffff,0x8(%rsp)
jmp    1310 <main+0xf0>
lea    0xc1a(%rip),%rdi
call   10f0 <perror@plt>
mov    0x8(%rsp),%ecx
jmp    1403 <main+0x1e3>
lea    0xbf8(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"Error al crear socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [17 x i8] c"Error en el bind\00"
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@.str.2 = [18 x i8] c"Eror en el listen\00"
@.str.3 = [16 x i8] c"Error en select\00"
@.str.4 = [19 x i8] c"Error en el accept\00"
@.str.5 = [23 x i8] c"Cliente nuevo aceptado\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [10 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast [10 x i32]* %6 to i8*
%13 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%14 = bitcast i32* %8 to i8*
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = call i32 @memset(%struct.sockaddr_in* %3, i32 48, i32 12)
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %23, i32* %24
%25 = call i32 @htons(i32 5001)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %25, i32* %26
%27 = load i32, i32* @INADDR_ANY
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %27, i32* %28
store i32 12, i32* %5
%29 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%30 = call i64 @bind(i32 %17, %struct.sockaddr* %29, i32 12)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %21
%35 = load i32, i32* @SIGCHLD
%36 = load i32, i32* @SIG_IGN
%37 = call i32 @signal(i32 %35, i32 %36)
%38 = call i64 @listen(i32 %17, i32 10)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %34
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%44 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %45
45: ; preds = %113, %42
%46 = call i32 @limpia(i32* %43, i32* %7)
%47 = call i32 @FD_ZERO(i32* %8)
%48 = call i32 @FD_SET(i32 %17, i32* %8)
%49 = load i32, i32* %7
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %45, %51
%52 = phi i64 [ %56, %51 ], [ 0, %45 ]
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = call i32 @FD_SET(i32 %54, i32* %8)
%56 = add nuw nsw i64 %52, 1
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = icmp slt i64 %56, %58
br i1 %59, label %51, label %60
60: ; preds = %51, %45
%61 = phi i32 [ %49, %45 ], [ %57, %51 ]
%62 = call i32 @maximoDescriptor(i32* %43, i32 %61)
%63 = icmp slt i32 %62, %17
%64 = select i1 %63, i32 %17, i32 %62
%65 = add nsw i32 %64, 1
%66 = call i64 @select(i32 %65, i32* %8, i32* null, i32* null, i32* null)
%67 = icmp slt i64 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %60
%69 = load i32, i32* %7
%70 = icmp sgt i32 %69, 0
br i1 %70, label %74, label %88
71: ; preds = %60
%72 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %68, %83
%75 = phi i64 [ %84, %83 ], [ 0, %68 ]
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i64 @FD_ISSET(i32 %77, i32* %8)
%79 = icmp eq i64 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %74
%81 = load i32, i32* %76
%82 = call i32 @procesar(i32 %81, i32* %7)
br label %83
83: ; preds = %74, %80
%84 = add nuw nsw i64 %75, 1
%85 = load i32, i32* %7
%86 = sext i32 %85 to i64
%87 = icmp slt i64 %84, %86
br i1 %87, label %74, label %88
88: ; preds = %83, %68
%89 = call i64 @FD_ISSET(i32 %17, i32* %8)
%90 = icmp eq i64 %89, 0
br i1 %90, label %113, label %91
91: ; preds = %88
%92 = call i32 @accept(i32 %17, %struct.sockaddr* %44, i32* %5)
%93 = load i32, i32* %7
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %94
store i32 %92, i32* %95
%96 = icmp slt i32 %92, 0
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%99 = load i32, i32* %7
br label %100
100: ; preds = %97, %91
%101 = phi i32 [ %99, %97 ], [ %93, %91 ]
%102 = add nsw i32 %101, 1
store i32 %102, i32* %7
%103 = icmp sgt i32 %101, 8
br i1 %103, label %104, label %111
104: ; preds = %100
%105 = zext i32 %101 to i64
%106 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
%109 = load i32, i32* %7
%110 = add nsw i32 %109, -1
store i32 %110, i32* %7
br label %111
111: ; preds = %104, %100
%112 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %113
113: ; preds = %111, %88
br label %45
}