#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;
  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);
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*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ unlink(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 i;
  int uid = 0, gid = 0, ino = 0;
  int estado = 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("::1", 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];
  for (;;) {
    printf("Listen.\n");
    if (listen(sd, 10)) {
      return -1;
    }
    printf("Accept.\n");
    sdC = accept(sd, (struct sockaddr *)&cliente, &cliente_len);
    int pid;
    pid = fork();
    int num_pid[2];
    if (pid == -1) {
      perror("Error de fork.\n");
    } else if (pid == 0) {
      close(sd);
      for (;;) {
        close(sd);
        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("Host: %s, Puerto: %s\n", host, serv);
        if (buffer[0] == 'r') {
          char ruta[80];
          sscanf(&buffer[2], "%s", ruta);
          unlink(ruta);
          send(sdC, "Eliminado archivo\n", 18, 0);
        } else if (buffer[0] == 'q') {
          send(sdC, "CERRANDO CONEXION..\n", 20, 0);
          freeaddrinfo(res);
          close(sd);
          return 0;
        }
      }
    }
    close(sdC);
  }
  freeaddrinfo(res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xbc(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1287 <main+0x97>
lea    0xd7e(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd80(%rip),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
lea    0xd70(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x151(%rbp)
call   1060 <printf@plt>
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,%ecx
mov    -0x151(%rbp),%al
mov    %ecx,-0x14(%rbp)
lea    0xd4f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
call   10b0 <bind@plt>
movl   $0x4,-0xc4(%rbp)
mov    0x2cac(%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,-0x150(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x148(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xe0(%rbp)
lea    0xcce(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1090 <listen@plt>
cmp    $0x0,%rax
je     1398 <main+0x1a8>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xe4(%rbp)
jmp    157a <main+0x38a>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0xc0(%rbp),%rsi
lea    -0xc4(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0xa4(%rbp)
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0xe8(%rbp)
cmpl   $0xffffffff,-0xe8(%rbp)
jne    13ed <main+0x1fd>
lea    0xc61(%rip),%rdi
call   10c0 <perror@plt>
jmp    156a <main+0x37a>
cmpl   $0x0,-0xe8(%rbp)
jne    1565 <main+0x375>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
lea    0xc43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x150(%rbp),%rdx
mov    -0x148(%rbp),%r8
mov    %eax,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xc0(%rbp),%rdi
mov    -0xc4(%rbp),%esi
mov    0x2b48(%rip),%rax
mov    (%rax),%ecx
mov    0x2b5f(%rip),%rax
mov    (%rax),%r9d
mov    0x2b3d(%rip),%rax
mov    (%rax),%eax
mov    0x2b64(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1080 <getnameinfo@plt>
mov    -0x150(%rbp),%rsi
mov    -0x148(%rbp),%rdx
add    $0x10,%rsp
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x72,%eax
jne    150b <main+0x31b>
lea    -0xa0(%rbp),%rdi
add    $0x2,%rdi
lea    -0x140(%rbp),%rdx
lea    0xb9b(%rip),%rsi
call   10a0 <sscanf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0xa4(%rbp),%edi
lea    0xb80(%rip),%rsi
mov    $0x12,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    1560 <main+0x370>
movsbl -0xa0(%rbp),%eax
cmp    $0x71,%eax
jne    155b <main+0x36b>
mov    -0xa4(%rbp),%edi
lea    0xb65(%rip),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x48(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xe4(%rbp)
jmp    157a <main+0x38a>
jmp    1560 <main+0x370>
jmp    1402 <main+0x212>
jmp    156a <main+0x37a>
mov    -0xa4(%rbp),%edi
call   1070 <close@plt>
jmp    135d <main+0x16d>
mov    -0xd0(%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    $0xe8,%rsp
mov    %rsi,%rbx
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmp    $0x1,%edi
jle    14bf <main+0x2bf>
mov    0x8(%rbx),%rsi
lea    0xdbf(%rip),%rdi
lea    -0x68(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
lea    0xe00(%rip),%rdi
call   1050 <puts@plt>
mov    -0x38(%rbp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   1120 <socket@plt>
mov    %eax,%r14d
lea    0xdee(%rip),%rdi
call   1050 <puts@plt>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %r14d,%edi
call   10c0 <bind@plt>
mov    %rsp,%rbx
movl   $0x4,-0x2c(%rbp)
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xd98(%rip),%rdi
call   1050 <puts@plt>
mov    %r14d,%edi
mov    $0xa,%esi
call   10a0 <listen@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
jne    14aa <main+0x2aa>
mov    %rbx,-0x40(%rbp)
lea    0xd6c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd62(%rip),%rdi
call   1050 <puts@plt>
mov    %r14d,%edi
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10e0 <accept@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1100 <fork@plt>
cmp    $0xffffffff,%eax
je     1374 <main+0x174>
test   %eax,%eax
je     1382 <main+0x182>
mov    %ebx,%edi
call   1080 <close@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %r14d,%edi
mov    $0xa,%esi
call   10a0 <listen@plt>
test   %rax,%rax
je     1320 <main+0x120>
jmp    14a0 <main+0x2a0>
lea    0xc9f(%rip),%rdi
call   10d0 <perror@plt>
jmp    134e <main+0x14e>
mov    %r14d,%edi
call   1080 <close@plt>
lea    -0x110(%rbp),%r13
jmp    13d3 <main+0x1d3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0xbe(%rbp),%rdi
lea    0xc92(%rip),%rsi
mov    %r13,%rdx
call   10b0 <sscanf@plt>
mov    %r13,%rdi
call   1040 <unlink@plt>
mov    %ebx,%edi
lea    0xc7c(%rip),%rsi
mov    $0x12,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %r14d,%edi
call   1080 <close@plt>
lea    0xcaf(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,%edi
lea    -0xc0(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,-0xc0(%rbp,%rax,1)
mov    -0x2c(%rbp),%esi
mov    0x2ba0(%rip),%rax
mov    (%rax),%ecx
mov    0x2bb7(%rip),%rax
mov    (%rax),%r9d
mov    0x2bc5(%rip),%rax
mov    (%rax),%eax
mov    0x2b8c(%rip),%rdx
or     (%rdx),%eax
sub    $0x8,%rsp
lea    -0x30(%rbp),%rdi
mov    %r15,%rdx
mov    %r12,%r8
push   %rax
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
lea    0xbdd(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
movzbl -0xc0(%rbp),%eax
cmp    $0x72,%al
je     13a0 <main+0x1a0>
cmp    $0x71,%al
jne    13d3 <main+0x1d3>
lea    0xbde(%rip),%rsi
xor    %r13d,%r13d
mov    %ebx,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x38(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    -0x40(%rbp),%rbx
jmp    14aa <main+0x2aa>
mov    -0x40(%rbp),%rbx
mov    $0xffffffff,%r13d
mov    %rbx,%rsp
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb3a(%rip),%rdi
call   10d0 <perror@plt>
jmp    124c <main+0x4c>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i64, i32, i32, i32 }
%struct.sockaddr_storage = type { 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 = [4 x i8] c"::1\00"
@.str.2 = [17 x i8] c"Creando socket.\0A\00"
@.str.3 = [7 x i8] c"Bind.\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@.str.4 = [9 x i8] c"Listen.\0A\00"
@.str.5 = [9 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 = [22 x i8] c"Host: %s, Puerto: %s\0A\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [19 x i8] c"Eliminado archivo\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 i32
%17 = alloca i32
%18 = alloca %struct.sockaddr_storage
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca [2 x i32]
%26 = alloca [80 x 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* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
%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_STREAM
%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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41, %struct.addrinfo* %8, %struct.addrinfo** %9)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%44 = load %struct.addrinfo*, %struct.addrinfo** %9
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 4
%46 = load i32, i32* %45
%47 = load %struct.addrinfo*, %struct.addrinfo** %9
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 3
%49 = load i32, i32* %48
%50 = load %struct.addrinfo*, %struct.addrinfo** %9
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 2
%52 = load i64, i64* %51
%53 = call i32 @socket(i32 %46, i32 %49, i64 %52)
store i32 %53, i32* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* %6
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 1
%58 = load i64, i64* %57
%59 = inttoptr i64 %58 to %struct.sockaddr*
%60 = load %struct.addrinfo*, %struct.addrinfo** %9
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = call i32 @bind(i32 %55, %struct.sockaddr* %59, i32 %62)
store i32 4, i32* %19
%64 = load i32, i32* @NI_MAXHOST
%65 = zext i32 %64 to i64
%66 = call i8* @llvm.stacksave()
store i8* %66, i8** %20
%67 = alloca i8, i64 %65
store i64 %65, i64* %21
%68 = load i32, i32* @NI_MAXSERV
%69 = zext i32 %68 to i64
%70 = alloca i8, i64 %69
store i64 %69, i64* %22
br label %71
71: ; preds = %139, %38
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%73 = load i32, i32* %6
%74 = call i64 @listen(i32 %73, i32 10)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %71
store i32 -1, i32* %3
store i32 1, i32* %23
br label %142
77: ; preds = %71
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%79 = load i32, i32* %6
%80 = bitcast %struct.sockaddr_storage* %18 to %struct.sockaddr*
%81 = call i32 @accept(i32 %79, %struct.sockaddr* %80, i32* %19)
store i32 %81, i32* %11
%82 = call i32 (...) @fork()
store i32 %82, i32* %24
%83 = load i32, i32* %24
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %87
85: ; preds = %77
%86 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %139
87: ; preds = %77
%88 = load i32, i32* %24
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %138
90: ; preds = %87
%91 = load i32, i32* %6
%92 = call i32 @close(i32 %91)
br label %93
93: ; preds = %137, %90
%94 = load i32, i32* %6
%95 = call i32 @close(i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%97 = load i32, i32* %11
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%99 = call i32 @recv(i32 %97, i8* %98, i32 80, i32 0)
store i32 %99, i32* %12
%100 = load i32, i32* %12
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %101
store i8 0, i8* %102
%103 = bitcast %struct.sockaddr_storage* %18 to %struct.sockaddr*
%104 = load i32, i32* %19
%105 = load i32, i32* @NI_MAXHOST
%106 = load i32, i32* @NI_MAXSERV
%107 = load i32, i32* @NI_NUMERICHOST
%108 = load i32, i32* @NI_NUMERICSERV
%109 = or i32 %107, %108
%110 = call i32 @getnameinfo(%struct.sockaddr* %103, i32 %104, i8* %67, i32 %105, i8* %70, i32 %106, i32 %109)
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %67, i8* %70)
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 114
br i1 %115, label %116, label %124
116: ; preds = %93
%117 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 2
%118 = getelementptr inbounds [80 x i8], [80 x i8]* %26, i64 0, i64 0
%119 = call i32 @sscanf(i8* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %118)
%120 = getelementptr inbounds [80 x i8], [80 x i8]* %26, i64 0, i64 0
%121 = call i32 @unlink(i8* %120)
%122 = load i32, i32* %11
%123 = call i32 @send(i32 %122, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 18, i32 0)
br label %137
124: ; preds = %93
%125 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%126 = load i8, i8* %125
%127 = sext i8 %126 to i32
%128 = icmp eq i32 %127, 113
br i1 %128, label %129, label %136
129: ; preds = %124
%130 = load i32, i32* %11
%131 = call i32 @send(i32 %130, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 20, i32 0)
%132 = load %struct.addrinfo*, %struct.addrinfo** %9
%133 = call i32 @freeaddrinfo(%struct.addrinfo* %132)
%134 = load i32, i32* %6
%135 = call i32 @close(i32 %134)
store i32 0, i32* %3
store i32 1, i32* %23
br label %142
136: ; preds = %124
br label %137
137: ; preds = %136, %116
br label %93
138: ; preds = %87
br label %139
139: ; preds = %138, %85
%140 = load i32, i32* %11
%141 = call i32 @close(i32 %140)
br label %71
142: ; preds = %129, %76
%143 = load i8*, i8** %20
%144 = load i32, i32* %3
ret i32 %144
}

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