#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  int st_uid;
  int st_gid;
  int st_ino;
};
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  scalar_t__ ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;
typedef int pid_t;
typedef int /*<<< orphan*/ cliente;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int EINVAL;
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ SOCK_DGRAM;
int WEXITSTATUS(int);
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ bind(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int fork();
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ getnameinfo(struct sockaddr *, int, char *, int, char *, int,
                               int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int stat(char *, struct stat *);
int strlen(char *);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int udp_socket, info;
  struct addrinfo hints;
  struct addrinfo *res;
  char buffer[80];
  int uid = 0, gid = 0, ino = 0;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_protocol = 0;
  if (argc < 2) {
    perror("Error de argumentos.\n");
  }
  info = getaddrinfo("::", argv[1], &hints, &res);
  if (info < 0)
    return -EINVAL;
  udp_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  bind(udp_socket, (struct sockaddr *)res->ai_addr, res->ai_addrlen);
  pid_t pid;
  int i;
  int num_pid[2];
  for (i = 0; i < 2; i++) {
    pid = fork();
    num_pid[i] = pid;
    if (pid == -1) {
      perror("Error fork.\n");
    } else if (pid == 0) {
      while (1) {
        struct sockaddr_storage cliente;
        socklen_t cliente_len = sizeof(cliente);
        char host[NI_MAXHOST];
        char serv[NI_MAXSERV];
        int recv = recvfrom(udp_socket, buffer, 80, 0,
                            (struct sockaddr *)&cliente, &cliente_len);
        buffer[recv] = '\0';
        getnameinfo((struct sockaddr *)&cliente, cliente_len, host, NI_MAXHOST,
                    serv, NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
        printf("Host: %s, Puerto: %s\n", host, serv);
        if (buffer[0] == 'i') {
          char ruta[80];
          char msg[80];
          sscanf(&buffer[2], "%s", ruta);
          struct stat sb;
          if (stat(ruta, &sb) == -1) {
            perror("Error de stat.\n");
          } else {
            uid = sb.st_uid;
            gid = sb.st_gid;
            ino = sb.st_ino;
            sprintf(msg, "UID: %i, GID: %i, INO: %i\n", uid, gid, ino);
            sendto(udp_socket, msg, strlen(msg), 0, (struct sockaddr *)&cliente,
                   cliente_len);
          }
        } else if (buffer[0] == 'q') {
          sendto(udp_socket, "CERRANDO CONEXION..\n", 20, 0,
                 (struct sockaddr *)&cliente, cliente_len);
          freeaddrinfo(res);
          close(udp_socket);
          return 0;
        }
      }
      close(udp_socket);
      _exit(0);
    }
  }
  i = 0;
  int status;
  while (i < 2) {
    wait(&status);
    printf("Fin proceso %i, código de salida %i\n", num_pid[i],
           WEXITSTATUS(status));
    i++;
  }
  freeaddrinfo(res);
  close(udp_socket);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1289 <main+0x79>
lea    0xd7c(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd7e(%rip),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12c5 <main+0xb5>
xor    %eax,%eax
mov    0x2cf5(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1695 <main+0x485>
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rdx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bind@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2,-0xb4(%rbp)
jge    1611 <main+0x401>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xb0(%rbp),%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0xbc(%rbp,%rax,4)
cmpl   $0xffffffff,-0xb0(%rbp)
jne    134f <main+0x13f>
lea    0xcd4(%rip),%rdi
call   10d0 <perror@plt>
jmp    15f8 <main+0x3e8>
cmpl   $0x0,-0xb0(%rbp)
jne    15f3 <main+0x3e3>
jmp    1361 <main+0x151>
movl   $0x4,-0xc4(%rbp)
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0xd0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1b8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
mov    0x2c29(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1b0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xe0(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0xc0(%rbp),%r8
mov    $0x50,%edx
xor    %ecx,%ecx
lea    -0xc4(%rbp),%r9
call   1090 <recvfrom@plt>
mov    -0x1b8(%rbp),%rdx
mov    -0x1b0(%rbp),%r8
mov    %eax,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xc0(%rbp),%rdi
mov    -0xc4(%rbp),%esi
mov    0x2b82(%rip),%rax
mov    (%rax),%ecx
mov    0x2ba1(%rip),%rax
mov    (%rax),%r9d
mov    0x2b7f(%rip),%rax
mov    (%rax),%eax
mov    0x2ba6(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <getnameinfo@plt>
mov    -0x1b8(%rbp),%rsi
mov    -0x1b0(%rbp),%rdx
add    $0x10,%rsp
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x69,%eax
jne    1562 <main+0x352>
lea    -0xa0(%rbp),%rdi
add    $0x2,%rdi
lea    -0x140(%rbp),%rdx
lea    0xba2(%rip),%rsi
call   10a0 <sscanf@plt>
lea    -0x140(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    14cc <main+0x2bc>
lea    0xb7d(%rip),%rdi
call   10d0 <perror@plt>
jmp    155d <main+0x34d>
mov    -0x1a0(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x19c(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x198(%rbp),%eax
mov    %eax,-0xac(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0xa8(%rbp),%ecx
mov    -0xac(%rbp),%r8d
lea    0xb3e(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
lea    -0x190(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1c4(%rbp),%edi
mov    -0x1c0(%rbp),%rsi
mov    %eax,%edx
lea    -0xc0(%rbp),%r8
mov    -0xc4(%rbp),%r9d
xor    %ecx,%ecx
call   1050 <sendto@plt>
jmp    15c2 <main+0x3b2>
movsbl -0xa0(%rbp),%eax
cmp    $0x71,%eax
jne    15bd <main+0x3ad>
mov    -0x14(%rbp),%edi
lea    -0xc0(%rbp),%r8
mov    -0xc4(%rbp),%r9d
lea    0xae0(%rip),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <sendto@plt>
mov    -0x48(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1a4(%rbp)
jmp    15cc <main+0x3bc>
jmp    15c2 <main+0x3b2>
movl   $0x0,-0x1a4(%rbp)
mov    -0xd0(%rbp),%rax
mov    %rax,%rsp
mov    -0x1a4(%rbp),%eax
test   %eax,%eax
je     15ee <main+0x3de>
jmp    15e9 <main+0x3d9>
jmp    1695 <main+0x485>
jmp    1361 <main+0x151>
jmp    15f8 <main+0x3e8>
jmp    15fd <main+0x3ed>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1303 <main+0xf3>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2,-0xb4(%rbp)
jge    167d <main+0x46d>
lea    -0x1a8(%rbp),%rdi
call   1100 <wait@plt>
movslq -0xb4(%rbp),%rax
mov    -0xbc(%rbp,%rax,4),%eax
mov    %eax,-0x1c8(%rbp)
mov    -0x1a8(%rbp),%edi
call   10c0 <WEXITSTATUS@plt>
mov    -0x1c8(%rbp),%esi
mov    %eax,%edx
lea    0xa1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    161b <main+0x40b>
mov    -0x48(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rsi,%rbx
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
cmp    $0x1,%edi
jle    14fd <main+0x2ed>
mov    0x8(%rbx),%rsi
lea    0xdaf(%rip),%rdi
lea    -0x80(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
js     14de <main+0x2ce>
mov    -0x40(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1130 <socket@plt>
mov    %eax,%edi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %edi,-0x2c(%rbp)
call   10b0 <bind@plt>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     135c <main+0x14c>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     150e <main+0x2fe>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     135c <main+0x14c>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
je     151f <main+0x30f>
lea    -0xd0(%rbp),%rbx
mov    %rbx,%rdi
call   1100 <wait@plt>
mov    -0xd0(%rbp),%edi
call   10c0 <WEXITSTATUS@plt>
lea    0xd85(%rip),%r13
xor    %r12d,%r12d
mov    %r13,%rdi
mov    %r14d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1100 <wait@plt>
mov    -0xd0(%rbp),%edi
call   10c0 <WEXITSTATUS@plt>
mov    %r13,%rdi
mov    %r15d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
jmp    14eb <main+0x2db>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x71,%al
je     14a5 <main+0x295>
mov    -0x48(%rbp),%rsp
mov    %rsp,-0x48(%rbp)
movl   $0x4,-0x30(%rbp)
mov    0x2c3a(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2c46(%rip),%rbx
mov    (%rbx),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r13
mov    %r13,%r8
lea    -0x30(%rbp),%r9
call   1090 <recvfrom@plt>
cltq
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    -0x30(%rbp),%esi
mov    (%r12),%ecx
mov    (%rbx),%r9d
mov    0x2c0f(%rip),%rax
mov    (%rax),%eax
mov    0x2bd6(%rip),%rdx
or     (%rdx),%eax
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %r15,%rdx
mov    %r14,%r8
push   %rax
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
lea    0xc24(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xd0(%rbp),%eax
cmp    $0x69,%al
jne    1350 <main+0x140>
lea    -0xce(%rbp),%rdi
lea    0xc10(%rip),%rsi
lea    -0x170(%rbp),%rbx
mov    %rbx,%rdx
call   10a0 <sscanf@plt>
mov    %rbx,%rdi
lea    -0x58(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
je     1490 <main+0x280>
mov    -0x58(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x50(%rbp),%r8d
lea    -0x120(%rbp),%rbx
mov    %rbx,%rdi
lea    0xbe8(%rip),%rsi
call   10e0 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r8
call   1050 <sendto@plt>
jmp    1358 <main+0x148>
lea    0xba8(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x48(%rbp),%rsp
jmp    135c <main+0x14c>
mov    -0x30(%rbp),%r9d
lea    0xbba(%rip),%rsi
xor    %r12d,%r12d
lea    -0x38(%rbp),%r8
mov    -0x2c(%rbp),%ebx
mov    %ebx,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <sendto@plt>
mov    -0x40(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    -0x48(%rbp),%rsp
jmp    14eb <main+0x2db>
mov    0x2acb(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xafc(%rip),%rdi
call   10d0 <perror@plt>
jmp    125c <main+0x4c>
lea    0xb04(%rip),%rdi
call   10d0 <perror@plt>
jmp    12be <main+0xae>
lea    0xaf3(%rip),%rdi
call   10d0 <perror@plt>
jmp    12d9 <main+0xc9>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i64, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.stat = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [22 x i8] c"Error de argumentos.\0A\00"
@.str.1 = [3 x i8] c"::\00"
@EINVAL = global i32 0
@.str.2 = [13 x i8] c"Error fork.\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.3 = [22 x i8] c"Host: %s, Puerto: %s\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [16 x i8] c"Error de stat.\0A\00"
@.str.6 = [27 x i8] c"UID: %i, GID: %i, INO: %i\0A\00"
@.str.7 = [21 x i8] c"CERRANDO CONEXION..\0A\00"
@.str.8 = [38 x i8] c"Fin proceso %i, c\C3\B3digo de salida %i\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 %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca [80 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2 x i32]
%17 = alloca %struct.sockaddr_storage
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
%22 = alloca i32
%23 = alloca [80 x i8]
%24 = alloca [80 x i8]
%25 = alloca %struct.stat
%26 = alloca i32
%27 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%28 = load i32, i32* @AI_PASSIVE
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %28, i32* %29
%30 = load i32, i32* @AF_UNSPEC
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i32, i32* @SOCK_DGRAM
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 2
store i64 0, i64* %34
%35 = load i32, i32* %4
%36 = icmp slt i32 %35, 2
br i1 %36, label %37, label %39
37: ; preds = %2
%38 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %37, %2
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @getaddrinfo(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %42, %struct.addrinfo* %8, %struct.addrinfo** %9)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i32, i32* @EINVAL
%48 = sub nsw i32 0, %47
store i32 %48, i32* %3
br label %188
49: ; preds = %39
%50 = load %struct.addrinfo*, %struct.addrinfo** %9
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 4
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %9
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 3
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 2
%58 = load i64, i64* %57
%59 = call i32 @socket(i32 %52, i32 %55, i64 %58)
store i32 %59, i32* %6
%60 = load i32, i32* %6
%61 = load %struct.addrinfo*, %struct.addrinfo** %9
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 1
%63 = load i64, i64* %62
%64 = inttoptr i64 %63 to %struct.sockaddr*
%65 = load %struct.addrinfo*, %struct.addrinfo** %9
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i32 @bind(i32 %60, %struct.sockaddr* %64, i32 %67)
store i32 0, i32* %15
br label %69
69: ; preds = %165, %49
%70 = load i32, i32* %15
%71 = icmp slt i32 %70, 2
br i1 %71, label %72, label %168
72: ; preds = %69
%73 = call i32 (...) @fork()
store i32 %73, i32* %14
%74 = load i32, i32* %14
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 %76
store i32 %74, i32* %77
%78 = load i32, i32* %14
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %72
%81 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %164
82: ; preds = %72
%83 = load i32, i32* %14
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %163
85: ; preds = %82
br label %86
86: ; preds = %85, %162
store i32 4, i32* %18
%87 = load i32, i32* @NI_MAXHOST
%88 = zext i32 %87 to i64
%89 = call i8* @llvm.stacksave()
store i8* %89, i8** %19
%90 = alloca i8, i64 %88
store i64 %88, i64* %20
%91 = load i32, i32* @NI_MAXSERV
%92 = zext i32 %91 to i64
%93 = alloca i8, i64 %92
store i64 %92, i64* %21
%94 = load i32, i32* %6
%95 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%96 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr*
%97 = call i32 @recvfrom(i32 %94, i8* %95, i32 80, i32 0, %struct.sockaddr* %96, i32* %18)
store i32 %97, i32* %22
%98 = load i32, i32* %22
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %99
store i8 0, i8* %100
%101 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr*
%102 = load i32, i32* %18
%103 = load i32, i32* @NI_MAXHOST
%104 = load i32, i32* @NI_MAXSERV
%105 = load i32, i32* @NI_NUMERICHOST
%106 = load i32, i32* @NI_NUMERICSERV
%107 = or i32 %105, %106
%108 = call i32 @getnameinfo(%struct.sockaddr* %101, i32 %102, i8* %90, i32 %103, i8* %93, i32 %104, i32 %107)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %90, i8* %93)
%110 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 105
br i1 %113, label %114, label %143
114: ; preds = %86
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 2
%116 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%117 = call i32 @sscanf(i8* %115, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %116)
%118 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%119 = call i32 @stat(i8* %118, %struct.stat* %25)
%120 = icmp eq i32 %119, -1
br i1 %120, label %121, label %123
121: ; preds = %114
%122 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %142
123: ; preds = %114
%124 = getelementptr inbounds %struct.stat, %struct.stat* %25, i32 0, i32 0
%125 = load i32, i32* %124
store i32 %125, i32* %11
%126 = getelementptr inbounds %struct.stat, %struct.stat* %25, i32 0, i32 1
%127 = load i32, i32* %126
store i32 %127, i32* %12
%128 = getelementptr inbounds %struct.stat, %struct.stat* %25, i32 0, i32 2
%129 = load i32, i32* %128
store i32 %129, i32* %13
%130 = getelementptr inbounds [80 x i8], [80 x i8]* %24, i64 0, i64 0
%131 = load i32, i32* %11
%132 = load i32, i32* %12
%133 = load i32, i32* %13
%134 = call i32 @sprintf(i8* %130, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %131, i32 %132, i32 %133)
%135 = load i32, i32* %6
%136 = getelementptr inbounds [80 x i8], [80 x i8]* %24, i64 0, i64 0
%137 = getelementptr inbounds [80 x i8], [80 x i8]* %24, i64 0, i64 0
%138 = call i32 @strlen(i8* %137)
%139 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr*
%140 = load i32, i32* %18
%141 = call i32 @sendto(i32 %135, i8* %136, i32 %138, i32 0, %struct.sockaddr* %139, i32 %140)
br label %142
142: ; preds = %123, %121
br label %158
143: ; preds = %86
%144 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%145 = load i8, i8* %144
%146 = sext i8 %145 to i32
%147 = icmp eq i32 %146, 113
br i1 %147, label %148, label %157
148: ; preds = %143
%149 = load i32, i32* %6
%150 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr*
%151 = load i32, i32* %18
%152 = call i32 @sendto(i32 %149, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 20, i32 0, %struct.sockaddr* %150, i32 %151)
%153 = load %struct.addrinfo*, %struct.addrinfo** %9
%154 = call i32 @freeaddrinfo(%struct.addrinfo* %153)
%155 = load i32, i32* %6
%156 = call i32 @close(i32 %155)
store i32 0, i32* %3
store i32 1, i32* %26
br label %159
157: ; preds = %143
br label %158
158: ; preds = %157, %142
store i32 0, i32* %26
br label %159
159: ; preds = %158, %148
%160 = load i8*, i8** %19
%161 = load i32, i32* %26
switch i32 %161, label %190 [
i32 0, label %162
i32 1, label %188
]
162: ; preds = %159
br label %86
163: ; preds = %82
br label %164
164: ; preds = %163, %80
br label %165
165: ; preds = %164
%166 = load i32, i32* %15
%167 = add nsw i32 %166, 1
store i32 %167, i32* %15
br label %69
168: ; preds = %69
store i32 0, i32* %15
br label %169
169: ; preds = %172, %168
%170 = load i32, i32* %15
%171 = icmp slt i32 %170, 2
br i1 %171, label %172, label %183
172: ; preds = %169
%173 = call i32 @wait(i32* %27)
%174 = load i32, i32* %15
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 %175
%177 = load i32, i32* %176
%178 = load i32, i32* %27
%179 = call i32 @WEXITSTATUS(i32 %178)
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %177, i32 %179)
%181 = load i32, i32* %15
%182 = add nsw i32 %181, 1
store i32 %182, i32* %15
br label %169
183: ; preds = %169
%184 = load %struct.addrinfo*, %struct.addrinfo** %9
%185 = call i32 @freeaddrinfo(%struct.addrinfo* %184)
%186 = load i32, i32* %6
%187 = call i32 @close(i32 %186)
store i32 0, i32* %3
br label %188
188: ; preds = %183, %159, %46
%189 = load i32, i32* %3
ret i32 %189
190: ; preds = %159
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i64, i64, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.stat = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [22 x i8] c"Error de argumentos.\0A\00"
@.str.1 = [3 x i8] c"::\00"
@EINVAL = global i32 0
@.str.2 = [13 x i8] c"Error fork.\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.3 = [22 x i8] c"Host: %s, Puerto: %s\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [16 x i8] c"Error de stat.\0A\00"
@.str.6 = [27 x i8] c"UID: %i, GID: %i, INO: %i\0A\00"
@.str.7 = [21 x i8] c"CERRANDO CONEXION..\0A\00"
@.str.8 = [38 x i8] c"Fin proceso %i, c\C3\B3digo de salida %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [80 x i8]
%6 = alloca %struct.sockaddr_storage
%7 = alloca i32
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca %struct.stat
%11 = alloca i32
%12 = bitcast %struct.addrinfo* %3 to i8*
%13 = bitcast %struct.addrinfo** %4 to i8*
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%15 = load i32, i32* @AI_PASSIVE
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %15, i32* %16
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_DGRAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %19, i32* %20
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i64 0, i64* %21
%22 = icmp slt i32 %0, 2
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %2
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27, %struct.addrinfo* %3, %struct.addrinfo** %4)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* @EINVAL
%32 = sub nsw i32 0, %31
br label %122
33: ; preds = %25
%34 = load %struct.addrinfo*, %struct.addrinfo** %4
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 4
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 3
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 2
%40 = load i64, i64* %39
%41 = call i32 @socket(i32 %36, i32 %38, i64 %40)
%42 = load %struct.addrinfo*, %struct.addrinfo** %4
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 1
%44 = load i64, i64* %43
%45 = inttoptr i64 %44 to %struct.sockaddr*
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 0
%47 = load i32, i32* %46
%48 = call i32 @bind(i32 %41, %struct.sockaddr* %45, i32 %47)
%49 = call i32 (...) @fork()
switch i32 %49, label %105 [
i32 -1, label %61
i32 0, label %50
]
50: ; preds = %105, %33
%51 = bitcast %struct.sockaddr_storage* %6 to i8*
%52 = bitcast i32* %7 to i8*
%53 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 2
%57 = bitcast %struct.stat* %10 to i8*
%58 = getelementptr inbounds %struct.stat, %struct.stat* %10, i64 0, i32 0
%59 = getelementptr inbounds %struct.stat, %struct.stat* %10, i64 0, i32 1
%60 = getelementptr inbounds %struct.stat, %struct.stat* %10, i64 0, i32 2
br label %63
61: ; preds = %33
%62 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %105
63: ; preds = %50, %104
store i32 4, i32* %7
%64 = load i32, i32* @NI_MAXHOST
%65 = zext i32 %64 to i64
%66 = call i8* @llvm.stacksave()
%67 = alloca i8, i64 %65
%68 = load i32, i32* @NI_MAXSERV
%69 = zext i32 %68 to i64
%70 = alloca i8, i64 %69
%71 = call i32 @recvfrom(i32 %41, i8* %14, i32 80, i32 0, %struct.sockaddr* %53, i32* %7)
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %72
store i8 0, i8* %73
%74 = load i32, i32* %7
%75 = load i32, i32* @NI_MAXHOST
%76 = load i32, i32* @NI_MAXSERV
%77 = load i32, i32* @NI_NUMERICHOST
%78 = load i32, i32* @NI_NUMERICSERV
%79 = or i32 %78, %77
%80 = call i32 @getnameinfo(%struct.sockaddr* %53, i32 %74, i8* %67, i32 %75, i8* %70, i32 %76, i32 %79)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %70)
%82 = load i8, i8* %14
switch i8 %82, label %104 [
i8 105, label %83
i8 113, label %98
]
83: ; preds = %63
%84 = call i32 @sscanf(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%85 = call i32 @stat(i8* %54, %struct.stat* %10)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %97
89: ; preds = %83
%90 = load i32, i32* %58
%91 = load i32, i32* %59
%92 = load i32, i32* %60
%93 = call i32 @sprintf(i8* %55, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %90, i32 %91, i32 %92)
%94 = call i32 @strlen(i8* %55)
%95 = load i32, i32* %7
%96 = call i32 @sendto(i32 %41, i8* %55, i32 %94, i32 0, %struct.sockaddr* %53, i32 %95)
br label %97
97: ; preds = %89, %87
br label %104
98: ; preds = %63
%99 = load i32, i32* %7
%100 = call i32 @sendto(i32 %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 20, i32 0, %struct.sockaddr* %53, i32 %99)
%101 = load %struct.addrinfo*, %struct.addrinfo** %4
%102 = call i32 @freeaddrinfo(%struct.addrinfo* %101)
%103 = call i32 @close(i32 %41)
br label %122
104: ; preds = %97, %63
br label %63
105: ; preds = %33, %61
%106 = call i32 (...) @fork()
switch i32 %106, label %109 [
i32 -1, label %107
i32 0, label %50
]
107: ; preds = %105
%108 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %109
109: ; preds = %107, %105
%110 = bitcast i32* %11 to i8*
%111 = call i32 @wait(i32* %11)
%112 = load i32, i32* %11
%113 = call i32 @WEXITSTATUS(i32 %112)
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %49, i32 %113)
%115 = call i32 @wait(i32* %11)
%116 = load i32, i32* %11
%117 = call i32 @WEXITSTATUS(i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %106, i32 %117)
%119 = load %struct.addrinfo*, %struct.addrinfo** %4
%120 = call i32 @freeaddrinfo(%struct.addrinfo* %119)
%121 = call i32 @close(i32 %41)
br label %122
122: ; preds = %109, %98, %30
%123 = phi i32 [ %32, %30 ], [ 0, %98 ], [ 0, %109 ]
ret i32 %123
}