#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 /*<<< 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 *, char *, 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;
  for (i = 0; i < 2; i++) {
    pid = fork();
    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);
    i++;
  }
  freeaddrinfo(res);
  close(udp_socket);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%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    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1279 <main+0x79>
lea    0xd8c(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd8e(%rip),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12b5 <main+0xb5>
xor    %eax,%eax
mov    0x2d05(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    163a <main+0x43a>
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   1120 <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    15eb <main+0x3eb>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %eax,-0xb0(%rbp)
cmpl   $0xffffffff,-0xb0(%rbp)
jne    132b <main+0x12b>
lea    0xcf8(%rip),%rdi
call   10c0 <perror@plt>
jmp    15d2 <main+0x3d2>
cmpl   $0x0,-0xb0(%rbp)
jne    15cd <main+0x3cd>
jmp    133d <main+0x13d>
movl   $0x4,-0xbc(%rbp)
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0xc8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1a8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd0(%rbp)
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1a0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0xb8(%rbp),%r8
mov    $0x50,%edx
xor    %ecx,%ecx
lea    -0xbc(%rbp),%r9
call   1090 <recvfrom@plt>
mov    -0x1a8(%rbp),%rdx
mov    -0x1a0(%rbp),%r8
mov    %eax,-0xdc(%rbp)
movslq -0xdc(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xb8(%rbp),%rdi
mov    -0xbc(%rbp),%esi
mov    0x2ba6(%rip),%rax
mov    (%rax),%ecx
mov    0x2bc5(%rip),%rax
mov    (%rax),%r9d
mov    0x2ba3(%rip),%rax
mov    (%rax),%eax
mov    0x2bca(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <getnameinfo@plt>
mov    -0x1a8(%rbp),%rsi
mov    -0x1a0(%rbp),%rdx
add    $0x10,%rsp
lea    0xbe0(%rip),%rdi
call   1040 <printf@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x69,%eax
jne    153c <main+0x33c>
lea    -0xa0(%rbp),%rdi
add    $0x2,%rdi
lea    -0x130(%rbp),%rdx
lea    0xbc8(%rip),%rsi
call   10a0 <sscanf@plt>
lea    -0x130(%rbp),%rdi
lea    -0x190(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    14a6 <main+0x2a6>
lea    0xba3(%rip),%rdi
call   10c0 <perror@plt>
jmp    1537 <main+0x337>
mov    -0x190(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18c(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x188(%rbp),%eax
mov    %eax,-0xac(%rbp)
lea    -0x180(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0xa8(%rbp),%ecx
mov    -0xac(%rbp),%r8d
lea    0xb64(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
lea    -0x180(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
lea    -0x180(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1b4(%rbp),%edi
mov    -0x1b0(%rbp),%rsi
mov    %eax,%edx
lea    -0xb8(%rbp),%r8
mov    -0xbc(%rbp),%r9d
xor    %ecx,%ecx
call   1050 <sendto@plt>
jmp    159c <main+0x39c>
movsbl -0xa0(%rbp),%eax
cmp    $0x71,%eax
jne    1597 <main+0x397>
mov    -0x14(%rbp),%edi
lea    -0xb8(%rbp),%r8
mov    -0xbc(%rbp),%r9d
lea    0xb06(%rip),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <sendto@plt>
mov    -0x48(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x194(%rbp)
jmp    15a6 <main+0x3a6>
jmp    159c <main+0x39c>
movl   $0x0,-0x194(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,%rsp
mov    -0x194(%rbp),%eax
test   %eax,%eax
je     15c8 <main+0x3c8>
jmp    15c3 <main+0x3c3>
jmp    163a <main+0x43a>
jmp    133d <main+0x13d>
jmp    15d2 <main+0x3d2>
jmp    15d7 <main+0x3d7>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    12f3 <main+0xf3>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2,-0xb4(%rbp)
jge    1622 <main+0x422>
lea    -0x198(%rbp),%rdi
call   10f0 <wait@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    15f5 <main+0x3f5>
mov    -0x48(%rbp),%rdi
call   1110 <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    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
cmp    $0x1,%edi
jle    149a <main+0x29a>
mov    0x8(%rbx),%rsi
lea    0xdbf(%rip),%rdi
lea    -0x80(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
js     147e <main+0x27e>
mov    -0x40(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1120 <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   1100 <fork@plt>
test   %eax,%eax
je     12fc <main+0xfc>
cmp    $0xffffffff,%eax
je     14ab <main+0x2ab>
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
je     12fc <main+0xfc>
cmp    $0xffffffff,%eax
je     14bc <main+0x2bc>
lea    -0xd0(%rbp),%rbx
mov    %rbx,%rdi
call   10f0 <wait@plt>
mov    %rbx,%rdi
call   10f0 <wait@plt>
mov    -0x40(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
xor    %ebx,%ebx
jmp    1489 <main+0x289>
nopw   0x0(%rax,%rax,1)
cmp    $0x71,%al
je     1443 <main+0x243>
mov    -0x48(%rbp),%rsp
mov    %rsp,-0x48(%rbp)
movl   $0x4,-0x30(%rbp)
mov    0x2c9a(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2ca6(%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    0x2c6f(%rip),%rax
mov    (%rax),%eax
mov    0x2c36(%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    0xc84(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
movzbl -0xd0(%rbp),%eax
cmp    $0x69,%al
jne    12f0 <main+0xf0>
lea    -0xce(%rbp),%rdi
lea    0xc72(%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     142e <main+0x22e>
mov    -0x58(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x50(%rbp),%r8d
lea    -0x120(%rbp),%rbx
mov    %rbx,%rdi
lea    0xc4a(%rip),%rsi
call   10d0 <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    12f8 <main+0xf8>
lea    0xc0a(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x48(%rbp),%rsp
jmp    12fc <main+0xfc>
mov    -0x30(%rbp),%r9d
lea    0xc1c(%rip),%rsi
xor    %ebx,%ebx
lea    -0x38(%rbp),%r8
mov    -0x2c(%rbp),%r12d
mov    %r12d,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <sendto@plt>
mov    -0x40(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    %r12d,%edi
call   1060 <close@plt>
mov    -0x48(%rbp),%rsp
jmp    1489 <main+0x289>
mov    0x2b2b(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb5f(%rip),%rdi
call   10c0 <perror@plt>
jmp    124c <main+0x4c>
lea    0xb67(%rip),%rdi
call   10c0 <perror@plt>
jmp    12a7 <main+0xa7>
lea    0xb56(%rip),%rdi
call   10c0 <perror@plt>
jmp    12bb <main+0xbb>

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