#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 /*<<< orphan*/ cliente;

/* 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_STREAM;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int fork();
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ getnameinfo(struct sockaddr *, int, char *, int, char *, int,
                               int);
int getpid();
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int stat(char *, struct stat *);
char *strerror(int);
int strlen(char *);
int main(int argc, char **argv) {
  int sd, info;
  struct addrinfo hints;
  struct addrinfo *res;
  char buffer[80];
  int sdC = 0;
  int r = 0;
  int uid = 0, gid = 0, ino = 0;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = 0;
  if (argc < 2) {
    perror("Error de argumentos.\n");
  }
  getaddrinfo("0.0.0.0", argv[1], &hints, &res);
  printf("Creando socket.\n");
  sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  printf("Bind\n");
  bind(sd, (struct sockaddr *)res->ai_addr, res->ai_addrlen);
  struct sockaddr_storage cliente;
  socklen_t cliente_len = sizeof(cliente);
  char host[NI_MAXHOST];
  char serv[NI_MAXSERV];
  struct stat sb;
  int status;
  int i = 0;
  int pid;
  int num_pid[80];
  for (;;) {
    printf("Listen\n");
    if (listen(sd, 10)) {
      return -1;
    }
    printf("Accept\n");
    sdC = accept(sd, (struct sockaddr *)&cliente, &cliente_len);
    pid = fork();
    if (pid == -1) {
      perror("Error de fork.\n");
    } else if (pid == 0) {
      close(sd);
      for (;;) {
        printf("Recibiendo.\n");
        r = recv(sdC, buffer, 80, 0);
        buffer[r] = '\0';
        getnameinfo((struct sockaddr *)&cliente, cliente_len, host, NI_MAXHOST,
                    serv, NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
        printf("[%d] Host: %s,  Puerto: %s\n", getpid(), host, serv);
        if (buffer[0] == 'i') {
          char ruta[80];
          char msg[80];
          sscanf(&buffer[2], "%s", ruta);
          if (stat(ruta, &sb) == -1) {
            int errno;
            char *st = strerror(errno);
            send(sdC, st, strlen(st), 0);
          } else {
            uid = sb.st_uid;
            gid = sb.st_gid;
            ino = sb.st_ino;
            sprintf(msg, "[PID: %d] UID: %i, GID: %i, INO: %i\n", getpid(), uid,
                    gid, ino);
            send(sdC, msg, strlen(msg), 0);
          }
        } else if (buffer[0] == 'q') {
          send(sdC, "CERRANDO CONEXION..\n", 20, 0);
          freeaddrinfo(res);
          close(sd);
          return 0;
        }
      }
    }
  }
  close(sdC);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%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)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    12bd <main+0x8d>
lea    0xd48(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd4a(%rip),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1110 <getaddrinfo@plt>
lea    0xd3e(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x311(%rbp)
call   1070 <printf@plt>
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1150 <socket@plt>
mov    %eax,%ecx
mov    -0x311(%rbp),%al
mov    %ecx,-0x14(%rbp)
lea    0xd1d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
call   10d0 <bind@plt>
movl   $0x4,-0xbc(%rbp)
mov    0x2c76(%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,-0x310(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd0(%rbp)
mov    0x2c61(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x308(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0xf0(%rbp)
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
je     13d8 <main+0x1a8>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x244(%rbp)
jmp    1698 <main+0x468>
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0xb8(%rbp),%rsi
lea    -0xbc(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0xa4(%rbp)
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0xffffffff,-0xf4(%rbp)
jne    142d <main+0x1fd>
lea    0xc22(%rip),%rdi
call   10e0 <perror@plt>
jmp    1693 <main+0x463>
cmpl   $0x0,-0xf4(%rbp)
jne    168e <main+0x45e>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
lea    0xc0c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x310(%rbp),%rdx
mov    -0x308(%rbp),%r8
mov    %eax,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xb8(%rbp),%rdi
mov    -0xbc(%rbp),%esi
mov    0x2b10(%rip),%rax
mov    (%rax),%ecx
mov    0x2b27(%rip),%rax
mov    (%rax),%r9d
mov    0x2b05(%rip),%rax
mov    (%rax),%eax
mov    0x2b2c(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x310(%rbp),%rdx
mov    -0x308(%rbp),%rcx
mov    %eax,%esi
lea    0xb75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x69,%eax
jne    1634 <main+0x404>
lea    -0xa0(%rbp),%rdi
add    $0x2,%rdi
lea    -0x2a0(%rbp),%rdx
lea    0xb61(%rip),%rsi
call   10c0 <sscanf@plt>
lea    -0x2a0(%rbp),%rdi
lea    -0xe8(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1591 <main+0x361>
mov    -0x2f4(%rbp),%edi
call   1120 <strerror@plt>
mov    %rax,-0x300(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0x324(%rbp)
mov    -0x300(%rbp),%rax
mov    %rax,-0x320(%rbp)
mov    -0x300(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x324(%rbp),%edi
mov    -0x320(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
jmp    162f <main+0x3ff>
mov    -0xe8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0xe0(%rbp),%eax
mov    %eax,-0xb4(%rbp)
lea    -0x2f0(%rbp),%rax
mov    %rax,-0x340(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x340(%rbp),%rdi
mov    %eax,%edx
mov    -0xac(%rbp),%ecx
mov    -0xb0(%rbp),%r8d
mov    -0xb4(%rbp),%r9d
lea    0xa93(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0x334(%rbp)
lea    -0x2f0(%rbp),%rax
mov    %rax,-0x330(%rbp)
lea    -0x2f0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x334(%rbp),%edi
mov    -0x330(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
jmp    1689 <main+0x459>
movsbl -0xa0(%rbp),%eax
cmp    $0x71,%eax
jne    1684 <main+0x454>
mov    -0xa4(%rbp),%edi
lea    0xa55(%rip),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x244(%rbp)
jmp    1698 <main+0x468>
jmp    1689 <main+0x459>
jmp    1442 <main+0x212>
jmp    1693 <main+0x463>
jmp    139d <main+0x16d>
mov    -0xc8(%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    $0x168,%rsp
mov    %rsi,%rbx
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
cmp    $0x1,%edi
jle    157f <main+0x33f>
mov    0x8(%rbx),%rsi
lea    0xd7c(%rip),%rdi
lea    -0x98(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   1120 <getaddrinfo@plt>
lea    0xdd6(%rip),%rdi
call   1040 <puts@plt>
mov    -0x50(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1160 <socket@plt>
mov    %eax,%r13d
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %r13d,%edi
call   10e0 <bind@plt>
mov    %rsp,%r14
movl   $0x4,-0x34(%rbp)
mov    0x2cb5(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xd68(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,-0x2c(%rbp)
mov    %r13d,%edi
mov    $0xa,%esi
call   10c0 <listen@plt>
mov    $0xffffffff,%r12d
test   %rax,%rax
jne    156a <main+0x32a>
mov    %rbx,-0x40(%rbp)
mov    %r14,-0x58(%rbp)
lea    0xd3b(%rip),%rbx
lea    0xd2d(%rip),%r13
mov    0x2c5a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    -0x2c(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
call   1140 <fork@plt>
cmp    $0xffffffff,%eax
je     13ca <main+0x18a>
test   %eax,%eax
je     13d8 <main+0x198>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    -0x2c(%rbp),%edi
mov    $0xa,%esi
call   10c0 <listen@plt>
test   %rax,%rax
je     1380 <main+0x140>
jmp    1566 <main+0x326>
lea    0xc4d(%rip),%rdi
call   10f0 <perror@plt>
jmp    13ab <main+0x16b>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%r12
mov    -0x30(%rbp),%r13d
jmp    13f8 <main+0x1b8>
nopw   0x0(%rax,%rax,1)
cmp    $0x71,%al
je     153c <main+0x2fc>
lea    0xcab(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,%edi
lea    -0xf0(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,-0xf0(%rbp,%rax,1)
mov    -0x34(%rbp),%esi
mov    (%r15),%ecx
mov    (%r14),%r9d
mov    0x2bb4(%rip),%rax
mov    (%rax),%eax
mov    0x2b7b(%rip),%rdx
or     (%rdx),%eax
sub    $0x8,%rsp
lea    -0x48(%rbp),%rdi
mov    -0x70(%rbp),%rbx
mov    %rbx,%rdx
mov    %r12,%r8
push   %rax
call   10a0 <getnameinfo@plt>
add    $0x10,%rsp
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xbc5(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
movzbl -0xf0(%rbp),%eax
cmp    $0x69,%al
jne    13f0 <main+0x1b0>
lea    -0xee(%rbp),%rdi
lea    0xbb5(%rip),%rsi
lea    -0x190(%rbp),%rbx
mov    %rbx,%rdx
call   10d0 <sscanf@plt>
mov    %rbx,%rdi
lea    -0x68(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     1510 <main+0x2d0>
mov    -0x68(%rbp),%ebx
mov    -0x64(%rbp),%r13d
mov    %r15,%r14
mov    -0x60(%rbp),%r15d
xor    %eax,%eax
call   1050 <getpid@plt>
lea    -0x140(%rbp),%rdi
lea    0xb75(%rip),%rsi
mov    %eax,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    -0x30(%rbp),%r13d
mov    -0x40(%rbp),%r12
mov    %r15d,%r9d
mov    %r14,%r15
mov    0x2adc(%rip),%r14
call   1110 <sprintf@plt>
lea    -0x140(%rbp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
jmp    152e <main+0x2ee>
call   1130 <strerror@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <strlen@plt>
mov    -0x30(%rbp),%edi
mov    %r13,%rsi
mov    -0x30(%rbp),%r13d
mov    -0x40(%rbp),%r12
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    13f8 <main+0x1b8>
lea    0xb2f(%rip),%rsi
xor    %r12d,%r12d
mov    %r13d,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x50(%rbp),%rdi
call   1150 <freeaddrinfo@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    -0x58(%rbp),%r14
mov    %r14,%rsp
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa7a(%rip),%rdi
call   10f0 <perror@plt>
jmp    128f <main+0x4f>

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_STREAM = global i32 0
@.str = [22 x i8] c"Error de argumentos.\0A\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@.str.2 = [17 x i8] c"Creando socket.\0A\00"
@.str.3 = [6 x i8] c"Bind\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@.str.4 = [8 x i8] c"Listen\0A\00"
@.str.5 = [8 x i8] c"Accept\0A\00"
@.str.6 = [16 x i8] c"Error de fork.\0A\00"
@.str.7 = [13 x i8] c"Recibiendo.\0A\00"
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.8 = [28 x i8] c"[%d] Host: %s, Puerto: %s\0A\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [37 x i8] c"[PID: %d] UID: %i, GID: %i, INO: %i\0A\00"
@.str.11 = [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 %struct.stat
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca [80 x i32]
%26 = alloca i32
%27 = alloca [80 x i8]
%28 = alloca [80 x i8]
%29 = alloca i32
%30 = alloca i8*
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
store i32 0, i32* %14
store i32 0, i32* %15
%31 = load i32, i32* @AI_PASSIVE
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %31, i32* %32
%33 = load i32, i32* @AF_UNSPEC
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %33, i32* %34
%35 = load i32, i32* @SOCK_STREAM
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 2
store i64 0, i64* %37
%38 = load i32, i32* %4
%39 = icmp slt i32 %38, 2
br i1 %39, label %40, label %42
40: ; preds = %2
%41 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %42
42: ; preds = %40, %2
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @getaddrinfo(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %45, %struct.addrinfo* %8, %struct.addrinfo** %9)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%48 = load %struct.addrinfo*, %struct.addrinfo** %9
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 4
%50 = load i32, i32* %49
%51 = load %struct.addrinfo*, %struct.addrinfo** %9
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 3
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %9
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 2
%56 = load i64, i64* %55
%57 = call i32 @socket(i32 %50, i32 %53, i64 %56)
store i32 %57, i32* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%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 4, i32* %17
%68 = load i32, i32* @NI_MAXHOST
%69 = zext i32 %68 to i64
%70 = call i8* @llvm.stacksave()
store i8* %70, i8** %18
%71 = alloca i8, i64 %69
store i64 %69, i64* %19
%72 = load i32, i32* @NI_MAXSERV
%73 = zext i32 %72 to i64
%74 = alloca i8, i64 %73
store i64 %73, i64* %20
store i32 0, i32* %23
br label %75
75: ; preds = %168, %42
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* %6
%78 = call i64 @listen(i32 %77, i32 10)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %75
store i32 -1, i32* %3
store i32 1, i32* %26
br label %169
81: ; preds = %75
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%83 = load i32, i32* %6
%84 = bitcast %struct.sockaddr_storage* %16 to %struct.sockaddr*
%85 = call i32 @accept(i32 %83, %struct.sockaddr* %84, i32* %17)
store i32 %85, i32* %11
%86 = call i32 (...) @fork()
store i32 %86, i32* %24
%87 = load i32, i32* %24
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %81
%90 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %168
91: ; preds = %81
%92 = load i32, i32* %24
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %167
94: ; preds = %91
%95 = load i32, i32* %6
%96 = call i32 @close(i32 %95)
br label %97
97: ; preds = %166, %94
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%99 = load i32, i32* %11
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%101 = call i32 @recv(i32 %99, i8* %100, i32 80, i32 0)
store i32 %101, i32* %12
%102 = load i32, i32* %12
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %103
store i8 0, i8* %104
%105 = bitcast %struct.sockaddr_storage* %16 to %struct.sockaddr*
%106 = load i32, i32* %17
%107 = load i32, i32* @NI_MAXHOST
%108 = load i32, i32* @NI_MAXSERV
%109 = load i32, i32* @NI_NUMERICHOST
%110 = load i32, i32* @NI_NUMERICSERV
%111 = or i32 %109, %110
%112 = call i32 @getnameinfo(%struct.sockaddr* %105, i32 %106, i8* %71, i32 %107, i8* %74, i32 %108, i32 %111)
%113 = call i32 (...) @getpid()
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %113, i8* %71, i8* %74)
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 105
br i1 %118, label %119, label %153
119: ; preds = %97
%120 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 2
%121 = getelementptr inbounds [80 x i8], [80 x i8]* %27, i64 0, i64 0
%122 = call i32 @sscanf(i8* %120, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %121)
%123 = getelementptr inbounds [80 x i8], [80 x i8]* %27, i64 0, i64 0
%124 = call i32 @stat(i8* %123, %struct.stat* %21)
%125 = icmp eq i32 %124, -1
br i1 %125, label %126, label %134
126: ; preds = %119
%127 = load i32, i32* %29
%128 = call i8* @strerror(i32 %127)
store i8* %128, i8** %30
%129 = load i32, i32* %11
%130 = load i8*, i8** %30
%131 = load i8*, i8** %30
%132 = call i32 @strlen(i8* %131)
%133 = call i32 @send(i32 %129, i8* %130, i32 %132, i32 0)
br label %152
134: ; preds = %119
%135 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 0
%136 = load i32, i32* %135
store i32 %136, i32* %13
%137 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 1
%138 = load i32, i32* %137
store i32 %138, i32* %14
%139 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 2
%140 = load i32, i32* %139
store i32 %140, i32* %15
%141 = getelementptr inbounds [80 x i8], [80 x i8]* %28, i64 0, i64 0
%142 = call i32 (...) @getpid()
%143 = load i32, i32* %13
%144 = load i32, i32* %14
%145 = load i32, i32* %15
%146 = call i32 @sprintf(i8* %141, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32 %142, i32 %143, i32 %144, i32 %145)
%147 = load i32, i32* %11
%148 = getelementptr inbounds [80 x i8], [80 x i8]* %28, i64 0, i64 0
%149 = getelementptr inbounds [80 x i8], [80 x i8]* %28, i64 0, i64 0
%150 = call i32 @strlen(i8* %149)
%151 = call i32 @send(i32 %147, i8* %148, i32 %150, i32 0)
br label %152
152: ; preds = %134, %126
br label %166
153: ; preds = %97
%154 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%155 = load i8, i8* %154
%156 = sext i8 %155 to i32
%157 = icmp eq i32 %156, 113
br i1 %157, label %158, label %165
158: ; preds = %153
%159 = load i32, i32* %11
%160 = call i32 @send(i32 %159, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 20, i32 0)
%161 = load %struct.addrinfo*, %struct.addrinfo** %9
%162 = call i32 @freeaddrinfo(%struct.addrinfo* %161)
%163 = load i32, i32* %6
%164 = call i32 @close(i32 %163)
store i32 0, i32* %3
store i32 1, i32* %26
br label %169
165: ; preds = %153
br label %166
166: ; preds = %165, %152
br label %97
167: ; preds = %91
br label %168
168: ; preds = %167, %89
br label %75
169: ; preds = %158, %80
%170 = load i8*, i8** %18
%171 = load i32, i32* %3
ret i32 %171
}

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