#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 sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sock;
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, int /*<<< orphan*/, 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 getpid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int, 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__);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  struct addrinfo hints;
  struct addrinfo *res;
  int info, sd;
  int nread;
  char buf[256];
  char host[NI_MAXHOST];
  char serv[NI_MAXSERV];
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_protocol = 0;
  if (argc < 1)
    perror("Error de argumentos.\n");
  info = getaddrinfo("::", argv[1], &hints, &res);
  if (info != 0)
    perror("Error getaddrinfo.\n");
  sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  bind(sd, res->ai_addr, res->ai_addrlen);
  int i;
  for (i = 0; i < 2; i++) {
    pid_t pid = fork();
    if (pid == -1)
      perror("Error de pid.\n");
    else if (pid == 0) {
      while (1) {
        struct sockaddr_storage sock;
        socklen_t sock_len = sizeof(sock);
        nread = recvfrom(sd, buf, 256, 0, (struct sockaddr *)&sock, &sock_len);
        buf[nread] = '\0';
        getnameinfo((struct sockaddr *)&sock, sock_len, host, NI_MAXHOST, serv,
                    NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
        if (strcmp(buf, "a") == 0 || strcmp(buf, "a\n") == 0) {
          sendto(sd, host, strlen(host), 0, (struct sockaddr *)&sock, sock_len);
        } else if (strcmp(buf, "p") == 0 || strcmp(buf, "p\n") == 0) {
          sendto(sd, serv, strlen(serv), 0, (struct sockaddr *)&sock, sock_len);
        } else if (strcmp(buf, "q") == 0 || strcmp(buf, "q\n") == 0) {
          sendto(sd, "ADIÓS\n", 6, 0, (struct sockaddr *)&sock, sock_len);
          freeaddrinfo(res);
          close(sd);
          return 0;
        }
        printf("[H: %d,%d] Host: %s     Puerto: %s\n", getpid(), i + 1, host,
               serv);
      }
    }
  }
  i = 0;
  while (i < 2) {
    int status;
    wait(&status);
    i++;
  }
  freeaddrinfo(res);
  close(sd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x158(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x198(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x160(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x190(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x168(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    12ab <main+0xbb>
lea    0xd5a(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd5c(%rip),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     12e0 <main+0xf0>
lea    0xd3e(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x38(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bind@plt>
movl   $0x0,-0x16c(%rbp)
cmpl   $0x2,-0x16c(%rbp)
jge    15c8 <main+0x3d8>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x170(%rbp)
cmpl   $0xffffffff,-0x170(%rbp)
jne    1355 <main+0x165>
lea    0xce2(%rip),%rdi
call   10c0 <perror@plt>
jmp    15af <main+0x3bf>
cmpl   $0x0,-0x170(%rbp)
jne    15aa <main+0x3ba>
jmp    1367 <main+0x177>
jmp    136c <main+0x17c>
movl   $0x4,-0x17c(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x150(%rbp),%rsi
lea    -0x178(%rbp),%r8
mov    $0x100,%edx
xor    %ecx,%ecx
lea    -0x17c(%rbp),%r9
call   10a0 <recvfrom@plt>
mov    -0x198(%rbp),%rdx
mov    -0x190(%rbp),%r8
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
lea    -0x178(%rbp),%rdi
mov    -0x17c(%rbp),%esi
mov    0x2be5(%rip),%rax
mov    (%rax),%ecx
mov    0x2bfc(%rip),%rax
mov    (%rax),%r9d
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    0x2c01(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1080 <getnameinfo@plt>
add    $0x10,%rsp
lea    -0x150(%rbp),%rdi
lea    0xc34(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1434 <main+0x244>
lea    -0x150(%rbp),%rdi
lea    0xc19(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1472 <main+0x282>
mov    -0x198(%rbp),%rdi
mov    -0x40(%rbp),%eax
mov    %eax,-0x19c(%rbp)
call   1040 <strlen@plt>
mov    -0x19c(%rbp),%edi
mov    -0x198(%rbp),%rsi
mov    %eax,%edx
lea    -0x178(%rbp),%r8
mov    -0x17c(%rbp),%r9d
xor    %ecx,%ecx
call   1060 <sendto@plt>
jmp    1579 <main+0x389>
lea    -0x150(%rbp),%rdi
lea    0xbc1(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     14ac <main+0x2bc>
lea    -0x150(%rbp),%rdi
lea    0xba6(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    14ea <main+0x2fa>
mov    -0x190(%rbp),%rdi
mov    -0x40(%rbp),%eax
mov    %eax,-0x1a0(%rbp)
call   1040 <strlen@plt>
mov    -0x1a0(%rbp),%edi
mov    -0x190(%rbp),%rsi
mov    %eax,%edx
lea    -0x178(%rbp),%r8
mov    -0x17c(%rbp),%r9d
xor    %ecx,%ecx
call   1060 <sendto@plt>
jmp    1574 <main+0x384>
lea    -0x150(%rbp),%rdi
lea    0xb4e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1524 <main+0x334>
lea    -0x150(%rbp),%rdi
lea    0xb33(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    156f <main+0x37f>
mov    -0x40(%rbp),%edi
lea    -0x178(%rbp),%r8
mov    -0x17c(%rbp),%r9d
lea    0xb0f(%rip),%rsi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1060 <sendto@plt>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x180(%rbp)
jmp    1621 <main+0x431>
jmp    1574 <main+0x384>
jmp    1579 <main+0x389>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x198(%rbp),%rcx
mov    -0x190(%rbp),%r8
mov    %eax,%esi
mov    -0x16c(%rbp),%edx
add    $0x1,%edx
lea    0xab3(%rip),%rdi
call   1050 <printf@plt>
jmp    1367 <main+0x177>
jmp    15af <main+0x3bf>
jmp    15b4 <main+0x3c4>
mov    -0x16c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x16c(%rbp)
jmp    131d <main+0x12d>
movl   $0x0,-0x16c(%rbp)
cmpl   $0x2,-0x16c(%rbp)
jge    15ff <main+0x40f>
lea    -0x184(%rbp),%rdi
call   10e0 <wait@plt>
mov    -0x16c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x16c(%rbp)
jmp    15d2 <main+0x3e2>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x180(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,%rsp
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,%r15
mov    %rsp,%r12
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movq   $0x0,-0x68(%rbp)
test   %edi,%edi
jle    14be <main+0x2ce>
mov    0x8(%r15),%rsi
lea    0xd99(%rip),%rdi
lea    -0x70(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
test   %eax,%eax
jne    14cf <main+0x2df>
mov    -0x38(%rbp),%rax
mov    0x14(%rax),%edi
mov    0x10(%rax),%esi
mov    0x8(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,%r15d
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r15d,%edi
call   10b0 <bind@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    $0x1,%ecx
test   %eax,%eax
je     1318 <main+0x128>
cmp    $0xffffffff,%eax
je     14e0 <main+0x2f0>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    $0x2,%ecx
test   %eax,%eax
je     1318 <main+0x128>
cmp    $0xffffffff,%eax
je     14f1 <main+0x301>
lea    -0x170(%rbp),%rbx
mov    %rbx,%rdi
call   10e0 <wait@plt>
mov    %rbx,%rdi
call   10e0 <wait@plt>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    %r15d,%edi
call   1070 <close@plt>
jmp    14aa <main+0x2ba>
mov    %ecx,-0x44(%rbp)
mov    %r12,-0x50(%rbp)
lea    -0x170(%rbp),%r13
lea    -0x40(%rbp),%r12
jmp    136c <main+0x17c>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%r9d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1060 <sendto@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xcf7(%rip),%rdi
mov    %eax,%esi
mov    -0x44(%rbp),%edx
mov    %rbx,%rcx
mov    %r14,%r8
call   1050 <printf@plt>
movl   $0x4,-0x2c(%rbp)
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
mov    %r12,%r8
lea    -0x2c(%rbp),%r9
call   10a0 <recvfrom@plt>
cltq
movb   $0x0,-0x170(%rbp,%rax,1)
mov    -0x2c(%rbp),%esi
mov    0x2c10(%rip),%rax
mov    (%rax),%ecx
mov    0x2c27(%rip),%rax
mov    (%rax),%r9d
mov    0x2c35(%rip),%rax
mov    (%rax),%eax
mov    0x2bfc(%rip),%rdx
or     (%rdx),%eax
sub    $0x8,%rsp
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r14,%r8
push   %rax
call   1080 <getnameinfo@plt>
add    $0x10,%rsp
mov    %r13,%rdi
lea    0xc5d(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1330 <main+0x140>
mov    %r13,%rdi
lea    0xc47(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1330 <main+0x140>
mov    %r13,%rdi
lea    0xc32(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1460 <main+0x270>
mov    %r13,%rdi
lea    0xc20(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1460 <main+0x270>
mov    %r13,%rdi
lea    0xc0f(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1477 <main+0x287>
mov    %r13,%rdi
lea    0xbfd(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    134e <main+0x15e>
jmp    1477 <main+0x287>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%r9d
mov    %r15d,%edi
mov    %r14,%rsi
jmp    1342 <main+0x152>
mov    -0x2c(%rbp),%r9d
lea    0xbc9(%rip),%rsi
lea    -0x40(%rbp),%r8
mov    %r15d,%edi
mov    $0x6,%edx
xor    %ecx,%ecx
call   1060 <sendto@plt>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    -0x50(%rbp),%r12
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb3b(%rip),%rdi
call   10c0 <perror@plt>
jmp    1272 <main+0x82>
lea    0xb43(%rip),%rdi
call   10c0 <perror@plt>
jmp    1292 <main+0xa2>
lea    0xb46(%rip),%rdi
call   10c0 <perror@plt>
jmp    12d2 <main+0xe2>
lea    0xb35(%rip),%rdi
call   10c0 <perror@plt>
jmp    12eb <main+0xfb>

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

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