#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ opcion;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ Servidor;
typedef int /*<<< orphan*/ Datos;
typedef int /*<<< orphan*/ Cliente;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
void *htons(int);
void *inet_addr(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ scanf(char *, char *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int sendto(int, int *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
main() {
  struct timeval timeout;
  int c, opcion = -1;
  fd_set readfds;
  int Socket_Cliente;
  struct sockaddr_in Cliente;
  char Datos[100], peticion[10];
  struct sockaddr_in Servidor;
  socklen_t Longitud_Servidor;
  Socket_Cliente = socket(AF_INET, SOCK_DGRAM, 0);
  FD_ZERO(&readfds);
  FD_SET(Socket_Cliente, &readfds);
  if (Socket_Cliente == -1) {
    printf("No se puede abrir el socket cliente\n");
    exit(-1);
  }
  Cliente.sin_family = AF_INET;
  Cliente.sin_port = htons(1999);
  Cliente.sin_addr.s_addr = inet_addr("127.0.0.1");
  if (bind(Socket_Cliente, (struct sockaddr *)&Cliente, sizeof(Cliente)) ==
      -1) {
    close(Socket_Cliente);
  }
  Servidor.sin_family = AF_INET;
  Servidor.sin_port = htons(2000);
  Servidor.sin_addr.s_addr = inet_addr("127.0.0.1");
  Longitud_Servidor = sizeof(Servidor);
  printf("\nEscriba la opcion que desee:\n");
  printf("  - DAY: ver el dia.\n");
  printf("  - TIME: ver la hora.\n");
  printf("  - DAYTIME: ver el dia y la hora.\n");
  printf("\nOpcion: ");
  scanf("%s", peticion);
  if (!strcmp("DAY", peticion)) {
    opcion = 0;
  } else if (!strcmp("TIME", peticion)) {
    opcion = 1;
  } else if (!strcmp("DAYTIME", peticion)) {
    opcion = 2;
  }
  int i = 0, encontrado = 0;
  int recibido;
  int enviado = sendto(Socket_Cliente, &opcion, sizeof(opcion), 0,
                       (struct sockaddr *)&Servidor, Longitud_Servidor);
  if (enviado < 0) {
    printf("Error al solicitar el servicio\n");
  }
  timeout.tv_sec = 5;
  timeout.tv_usec = 0;
  while (!encontrado && i < 3) {
    c = select(Socket_Cliente + 1, &readfds, NULL, NULL, &timeout);
    if (c == 0) {
      printf("Error al leer del servidor\n");
    } else if (c == -1) {
      printf("Error en select");
      encontrado = 1;
    } else {
      recibido = recvfrom(Socket_Cliente, Datos, sizeof(Datos), 0,
                          (struct sockaddr *)&Servidor, &Longitud_Servidor);
      printf("\nLeido %s\n\n", Datos);
      encontrado = 1;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x20(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%rdi
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x28(%rbp)
lea    -0x24(%rbp),%rdi
call   1090 <FD_ZERO@plt>
mov    -0x28(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   10f0 <FD_SET@plt>
cmpl   $0xffffffff,-0x28(%rbp)
jne    124d <main+0x6d>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    $0x7cf,%edi
call   1030 <htons@plt>
mov    %rax,-0x38(%rbp)
lea    0xdb5(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    129b <main+0xbb>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xc8(%rbp)
mov    $0x7d0,%edi
call   1030 <htons@plt>
mov    %rax,-0xd0(%rbp)
lea    0xd61(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %rax,-0xd8(%rbp)
movl   $0x18,-0xdc(%rbp)
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xba(%rbp),%rsi
lea    0xd7c(%rip),%rdi
call   10c0 <scanf@plt>
lea    -0xba(%rbp),%rsi
lea    0xd6c(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    135b <main+0x17b>
movl   $0x0,-0x20(%rbp)
jmp    13b0 <main+0x1d0>
lea    -0xba(%rbp),%rsi
lea    0xd4b(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1383 <main+0x1a3>
movl   $0x1,-0x20(%rbp)
jmp    13ab <main+0x1cb>
lea    -0xba(%rbp),%rsi
lea    0xd20(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    13a6 <main+0x1c6>
movl   $0x2,-0x20(%rbp)
jmp    13ab <main+0x1cb>
jmp    13b0 <main+0x1d0>
movl   $0x0,-0xe0(%rbp)
movl   $0x0,-0xe4(%rbp)
mov    -0x28(%rbp),%edi
lea    -0xd8(%rbp),%r8
mov    -0xdc(%rbp),%r9d
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <sendto@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
jge    1406 <main+0x226>
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x5,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xe4(%rbp)
mov    %al,-0xed(%rbp)
jne    143a <main+0x25a>
cmpl   $0x3,-0xe0(%rbp)
setl   %al
mov    %al,-0xed(%rbp)
mov    -0xed(%rbp),%al
test   $0x1,%al
jne    144d <main+0x26d>
jmp    1510 <main+0x330>
mov    -0x28(%rbp),%edi
add    $0x1,%edi
lea    -0x24(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rdx
call   10a0 <select@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1487 <main+0x2a7>
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14fc <main+0x31c>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    14ae <main+0x2ce>
lea    0xc5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xe4(%rbp)
jmp    14f7 <main+0x317>
mov    -0x28(%rbp),%edi
lea    -0xb0(%rbp),%rsi
lea    -0xd8(%rbp),%r8
mov    $0x64,%edx
xor    %ecx,%ecx
lea    -0xdc(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0xe8(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xe4(%rbp)
jmp    14fc <main+0x31c>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    1415 <main+0x235>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
movl   $0xffffffff,0x8(%rsp)
ff
mov    0x2dee(%rip),%r14
mov    (%r14),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   10f0 <FD_SET@plt>
cmp    $0xffffffff,%ebp
je     1451 <main+0x271>
mov    %ebp,%ebx
mov    (%r14),%rax
mov    %rax,0x58(%rsp)
mov    $0x7cf,%edi
call   1040 <htons@plt>
mov    %rax,0x50(%rsp)
lea    0xdb1(%rip),%rdi
call   1080 <inet_addr@plt>
mov    %rax,0x48(%rsp)
lea    0x48(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1276 <main+0x96>
mov    %ebx,%edi
call   1070 <close@plt>
mov    (%r14),%rax
mov    %rax,0x40(%rsp)
mov    $0x7d0,%edi
call   1040 <htons@plt>
mov    %rax,0x38(%rsp)
lea    0xd6c(%rip),%rdi
call   1080 <inet_addr@plt>
mov    %rax,0x30(%rsp)
movl   $0x18,0x10(%rsp)
lea    0xd92(%rip),%rdi
call   1030 <puts@plt>
lea    0xda4(%rip),%rdi
call   1030 <puts@plt>
lea    0xdad(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xd2d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd29(%rip),%rdi
lea    0x16(%rsp),%rsi
call   10c0 <scanf@plt>
cmpl   $0x594144,0x16(%rsp)
je     132c <main+0x14c>
mov    $0x454d4954,%eax
xor    0x16(%rsp),%eax
movzbl 0x1a(%rsp),%ecx
or     %eax,%ecx
je     1336 <main+0x156>
movabs $0x454d4954594144,%rax
cmp    %rax,0x16(%rsp)
jne    133e <main+0x15e>
movl   $0x2,0x8(%rsp)
jmp    133e <main+0x15e>
movl   $0x0,0x8(%rsp)
jmp    133e <main+0x15e>
movl   $0x1,0x8(%rsp)
lea    0x8(%rsp),%rsi
lea    0x30(%rsp),%r8
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
jns    136c <main+0x18c>
lea    0xd60(%rip),%rdi
call   1030 <puts@plt>
movl   $0x5,0x20(%rsp)
movq   $0x0,0x28(%rsp)
add    $0x1,%ebp
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r8
mov    %ebp,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   10a0 <select@plt>
test   %eax,%eax
je     13a0 <main+0x1c0>
cmp    $0xffffffff,%eax
je     1402 <main+0x222>
jmp    1412 <main+0x232>
lea    0xd05(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r8
mov    %ebp,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   10a0 <select@plt>
cmp    $0xffffffff,%eax
je     1402 <main+0x222>
test   %eax,%eax
jne    1412 <main+0x232>
lea    0xcdb(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r8
mov    %ebp,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   10a0 <select@plt>
cmp    $0xffffffff,%eax
je     1402 <main+0x222>
test   %eax,%eax
jne    1412 <main+0x232>
lea    0xcb1(%rip),%rdi
call   1030 <puts@plt>
jmp    1443 <main+0x263>
lea    0xc1a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1443 <main+0x263>
lea    0x60(%rsp),%rbp
lea    0x30(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   10b0 <recvfrom@plt>
lea    0xbfa(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xc8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [37 x i8] c"No se puede abrir el socket cliente\0A\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [31 x i8] c"\0AEscriba la opcion que desee:\0A\00"
@.str.3 = [22 x i8] c" - DAY: ver el dia.\0A\00"
@.str.4 = [24 x i8] c" - TIME: ver la hora.\0A\00"
@.str.5 = [36 x i8] c" - DAYTIME: ver el dia y la hora.\0A\00"
@.str.6 = [10 x i8] c"\0AOpcion: \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"DAY\00"
@.str.9 = [5 x i8] c"TIME\00"
@.str.10 = [8 x i8] c"DAYTIME\00"
@.str.11 = [32 x i8] c"Error al solicitar el servicio\0A\00"
@.str.12 = [28 x i8] c"Error al leer del servidor\0A\00"
@.str.13 = [16 x i8] c"Error en select\00"
@.str.14 = [12 x i8] c"\0ALeido %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [100 x i8]
%9 = alloca [10 x i8]
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %4
%16 = load i8*, i8** @AF_INET
%17 = load i32, i32* @SOCK_DGRAM
%18 = call i32 @socket(i8* %16, i32 %17, i32 0)
store i32 %18, i32* %6
%19 = call i32 @FD_ZERO(i32* %5)
%20 = load i32, i32* %6
%21 = call i32 @FD_SET(i32 %20, i32* %5)
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 -1)
unreachable
27: ; preds = %0
%28 = load i8*, i8** @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %28, i8** %29
%30 = call i8* @htons(i32 1999)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i8* %30, i8** %31
%32 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
store i8* %32, i8** %34
%35 = load i32, i32* %6
%36 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%37 = call i32 @bind(i32 %35, %struct.sockaddr* %36, i32 24)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %27
%40 = load i32, i32* %6
%41 = call i32 @close(i32 %40)
br label %42
42: ; preds = %39, %27
%43 = load i8*, i8** @AF_INET
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i8* %43, i8** %44
%45 = call i8* @htons(i32 2000)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i8* %45, i8** %46
%47 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %48, i32 0, i32 0
store i8* %47, i8** %49
store i32 24, i32* %11
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%58 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %57)
%59 = icmp ne i32 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %42
store i32 0, i32* %4
br label %73
61: ; preds = %42
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%63 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %66, label %65
65: ; preds = %61
store i32 1, i32* %4
br label %72
66: ; preds = %61
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%68 = call i32 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %67)
%69 = icmp ne i32 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %66
store i32 2, i32* %4
br label %71
71: ; preds = %70, %66
br label %72
72: ; preds = %71, %65
br label %73
73: ; preds = %72, %60
store i32 0, i32* %12
store i32 0, i32* %13
%74 = load i32, i32* %6
%75 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%76 = load i32, i32* %11
%77 = call i32 @sendto(i32 %74, i32* %4, i32 4, i32 0, %struct.sockaddr* %75, i32 %76)
store i32 %77, i32* %15
%78 = load i32, i32* %15
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %73
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %82
82: ; preds = %80, %73
%83 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %83
%84 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i64 0, i64* %84
br label %85
85: ; preds = %114, %82
%86 = load i32, i32* %13
%87 = icmp ne i32 %86, 0
br i1 %87, label %91, label %88
88: ; preds = %85
%89 = load i32, i32* %12
%90 = icmp slt i32 %89, 3
br label %91
91: ; preds = %88, %85
%92 = phi i1 [ false, %85 ], [ %90, %88 ]
br i1 %92, label %93, label %117
93: ; preds = %91
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
%96 = call i32 @select(i32 %95, i32* %5, i32* null, i32* null, %struct.timeval* %2)
store i32 %96, i32* %3
%97 = load i32, i32* %3
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %93
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
br label %114
101: ; preds = %93
%102 = load i32, i32* %3
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %101
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %13
br label %113
106: ; preds = %101
%107 = load i32, i32* %6
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%109 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%110 = call i32 @recvfrom(i32 %107, i8* %108, i32 100, i32 0, %struct.sockaddr* %109, i32* %11)
store i32 %110, i32* %14
%111 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %111)
store i32 1, i32* %13
br label %113
113: ; preds = %106, %104
br label %114
114: ; preds = %113, %99
%115 = load i32, i32* %12
%116 = add nsw i32 %115, 1
store i32 %116, i32* %12
br label %85
117: ; preds = %91
%118 = load i32, i32* %1
ret i32 %118
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.6 = [10 x i8] c"\0AOpcion: \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"DAY\00"
@.str.9 = [5 x i8] c"TIME\00"
@.str.10 = [8 x i8] c"DAYTIME\00"
@.str.13 = [16 x i8] c"Error en select\00"
@.str.14 = [12 x i8] c"\0ALeido %s\0A\0A\00"
@str = [30 x i8] c"\0AEscriba la opcion que desee:\00"
@str.15 = [21 x i8] c" - DAY: ver el dia.\00"
@str.16 = [23 x i8] c" - TIME: ver la hora.\00"
@str.17 = [35 x i8] c" - DAYTIME: ver el dia y la hora.\00"
@str.18 = [27 x i8] c"Error al leer del servidor\00"
@str.19 = [31 x i8] c"Error al solicitar el servicio\00"
@str.20 = [36 x i8] c"No se puede abrir el socket cliente\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [100 x i8]
%6 = alloca [10 x i8]
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = bitcast %struct.timeval* %1 to i8*
%10 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%11 = bitcast i32* %3 to i8*
%12 = bitcast %struct.sockaddr_in* %4 to i8*
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%15 = bitcast %struct.sockaddr_in* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = load i8*, i8** @AF_INET
%18 = load i32, i32* @SOCK_DGRAM
%19 = tail call i32 @socket(i8* %17, i32 %18, i32 0)
%20 = call i32 @FD_ZERO(i32* %3)
%21 = call i32 @FD_SET(i32 %19, i32* %3)
%22 = icmp eq i32 %19, -1
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.20, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %0
%27 = load i8*, i8** @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %27, i8** %28
%29 = call i8* @htons(i32 1999)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %29, i8** %30
%31 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i8* %31, i8** %32
%33 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%34 = call i32 @bind(i32 %19, %struct.sockaddr* %33, i32 24)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %26
%37 = call i32 @close(i32 %19)
br label %38
38: ; preds = %36, %26
%39 = load i8*, i8** @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i8* %39, i8** %40
%41 = call i8* @htons(i32 2000)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1
store i8* %41, i8** %42
%43 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0, i32 0
store i8* %43, i8** %44
store i32 24, i32* %8
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.17, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %14)
%51 = call i32 @bcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(4) %14, i64 4)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %38
store i32 0, i32* %2
br label %62
54: ; preds = %38
%55 = call i32 @bcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* dereferenceable(5) %14, i64 5)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 1, i32* %2
br label %62
58: ; preds = %54
%59 = call i32 @bcmp(i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(8) %14, i64 8)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %58
store i32 2, i32* %2
br label %62
62: ; preds = %57, %61, %58, %53
%63 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%64 = call i32 @sendto(i32 %19, i32* %2, i32 4, i32 0, %struct.sockaddr* %63, i32 24)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.19, i64 0, i64 0))
br label %68
68: ; preds = %66, %62
%69 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i32 5, i32* %69
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i64 0, i64* %70
%71 = add nuw nsw i32 %19, 1
%72 = call i32 @select(i32 %71, i32* %3, i32* null, i32* null, %struct.timeval* %1)
switch i32 %72, label %75 [
i32 0, label %78
i32 -1, label %73
]
73: ; preds = %81, %78, %68
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
br label %86
75: ; preds = %81, %78, %68
%76 = call i32 @recvfrom(i32 %19, i8* %13, i32 100, i32 0, %struct.sockaddr* %63, i32* %8)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %13)
br label %86
78: ; preds = %68
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%80 = call i32 @select(i32 %71, i32* %3, i32* null, i32* null, %struct.timeval* %1)
switch i32 %80, label %75 [
i32 0, label %81
i32 -1, label %73
]
81: ; preds = %78
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%83 = call i32 @select(i32 %71, i32* %3, i32* null, i32* null, %struct.timeval* %1)
switch i32 %83, label %75 [
i32 0, label %84
i32 -1, label %73
]
84: ; preds = %81
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
br label %86
86: ; preds = %84, %75, %73
ret i32 0
}