#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uno;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(void *, char, int);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sockfd, newsockfd, portno;
  socklen_t clilen;
  char buffer[20];
  char salir[6] = "salir", ok[2] = "OK";
  struct sockaddr_in serv_addr, cli_addr;
  int n, arch;
  int uno = 1, i = 0;
  FILE *f;
  f = fopen("puntajes", "a+");
  if (argc < 2) {
    fprintf(stderr, "ERROR, no port provided\n");
    exit(1);
  }
  while (salir) {
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
      error("ERROR opening socket");
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void *)&uno,
                   (socklen_t)(sizeof(uno))))
      error("error opciones de socket");
    portno = atoi(argv[1]);
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);
    memset((void *)&(serv_addr.sin_zero), '\0', 8);
    if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
      error("ERROR on binding");
    listen(sockfd, 5);
    clilen = sizeof(cli_addr);
    printf("Esperando conexiones...\n");
    newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
    if (newsockfd < 0)
      error("ERROR on accept");
    memset((void *)buffer, '\0', 20);
    n = read(newsockfd, buffer, 20);
    if (strncmp("-1;a", buffer, 4) != 0) {
      if (n < 0)
        error("ERROR reading from socket");
      fputs(buffer, f);
      fputs("\n", f);
    }
    rewind(f);
    while (!feof(f)) {
      fgets(buffer, 20, f);
      n = write(newsockfd, buffer, strlen(buffer));
      if (n < 0)
        error("ERROR writing to socket");
      n = read(newsockfd, ok, 2);
      if (strncmp("OK", ok, 2) != 0)
        fprintf(stderr, "error\n\n");
    }
    n = write(newsockfd, salir, strlen(salir));
    sleep(2);
  }
  close(newsockfd);
  close(sockfd);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xd61(%rip),%eax
mov    %eax,-0x46(%rbp)
mov    0xd5b(%rip),%ax
mov    %ax,-0x42(%rbp)
mov    0xe21(%rip),%ax
mov    %ax,-0x48(%rbp)
movl   $0x1,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xd39(%rip),%rdi
lea    0xd3b(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x80(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1306 <main+0x86>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
jmp    130b <main+0x8b>
lea    -0x46(%rbp),%rax
cmp    $0x0,%rax
je     15c1 <main+0x341>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
mov    0x2c97(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11a0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    134b <main+0xcb>
lea    0xce5(%rip),%rdi
call   1140 <error@plt>
mov    -0x14(%rbp),%edi
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
mov    0x2c5a(%rip),%rax
mov    (%rax),%edx
lea    -0x74(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
je     1385 <main+0x105>
lea    0xcc0(%rip),%rdi
call   1140 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1170 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2c44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <htons@plt>
mov    %eax,-0x54(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x10,%edx
call   1130 <bind@plt>
cmp    $0x0,%rax
jge    13ef <main+0x16f>
lea    0xc6f(%rip),%rdi
call   1140 <error@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1120 <listen@plt>
movl   $0x10,-0x20(%rbp)
lea    0xc60(%rip),%rdi
call   1090 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x68(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1160 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1438 <main+0x1b8>
lea    0xc50(%rip),%rdi
call   1140 <error@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   10c0 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x14,%edx
call   10e0 <read@plt>
mov    %eax,-0x6c(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xc2c(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     14ae <main+0x22e>
cmpl   $0x0,-0x6c(%rbp)
jge    1491 <main+0x211>
lea    0xc0c(%rip),%rdi
call   1140 <error@plt>
lea    -0x40(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   10b0 <fputs@plt>
mov    -0x80(%rbp),%rsi
lea    0xc2a(%rip),%rdi
call   10b0 <fputs@plt>
mov    -0x80(%rbp),%rdi
call   10a0 <rewind@plt>
mov    -0x80(%rbp),%rdi
call   1110 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14d5 <main+0x255>
jmp    157e <main+0x2fe>
lea    -0x40(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0x14,%esi
call   10f0 <fgets@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1531 <main+0x2b1>
lea    0xb86(%rip),%rdi
call   1140 <error@plt>
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x2,%edx
call   10e0 <read@plt>
mov    %eax,-0x6c(%rbp)
lea    -0x48(%rbp),%rsi
lea    0xb7a(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1579 <main+0x2f9>
mov    0x2a5d(%rip),%rax
mov    (%rax),%edi
lea    0xb59(%rip),%rsi
call   1100 <fprintf@plt>
jmp    14b7 <main+0x237>
mov    -0x18(%rbp),%eax
mov    %eax,-0x9c(%rbp)
lea    -0x46(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x46(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x6c(%rbp)
mov    $0x2,%edi
call   1190 <sleep@plt>
jmp    130b <main+0x8b>
mov    -0x18(%rbp),%edi
call   10d0 <close@plt>
mov    -0x14(%rbp),%edi
call   10d0 <close@plt>
mov    -0x80(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,0x18(%rsp)
mov    %edi,%ebp
movw   $0x72,0x10(%rsp)
movl   $0x696c6173,0xc(%rsp)
69
movw   $0x4b4f,0x6(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xd5c(%rip),%rdi
lea    0xd5e(%rip),%rsi
call   1140 <fopen@plt>
cmp    $0x2,%ebp
jl     150d <main+0x29d>
mov    %rax,%rbx
mov    0x2d17(%rip),%r12
lea    0x40(%rsp),%r15
lea    0x6(%rsp),%r13
lea    0xdd7(%rip),%r14
jmp    130b <main+0x9b>
nopl   0x0(%rax)
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    $0x2,%edi
call   1180 <sleep@plt>
mov    0x2cd5(%rip),%r12
mov    (%r12),%edi
mov    0x2caa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1190 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1331 <main+0xc1>
lea    0xcff(%rip),%rdi
call   1130 <error@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
mov    0x2c77(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
je     1366 <main+0xf6>
lea    0xcdf(%rip),%rdi
call   1130 <error@plt>
mov    0x18(%rsp),%rax
mov    0x8(%rax),%rdi
call   1160 <atoi@plt>
mov    (%r12),%ecx
mov    %ecx,0x2c(%rsp)
mov    0x2c55(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x28(%rsp)
mov    %eax,%edi
call   1080 <htons@plt>
mov    %eax,0x24(%rsp)
lea    0x20(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x10,%edx
call   1120 <bind@plt>
test   %rax,%rax
jns    13c8 <main+0x158>
lea    0xc96(%rip),%rdi
call   1130 <error@plt>
mov    %ebp,%edi
mov    $0x5,%esi
call   1110 <listen@plt>
movl   $0x10,0x14(%rsp)
lea    0xcd9(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
lea    0x30(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1150 <accept@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    140c <main+0x19c>
lea    0xc63(%rip),%rdi
call   1130 <error@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   10b0 <memset@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x14,%edx
call   10d0 <read@plt>
mov    %eax,%ebp
lea    0xc46(%rip),%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     146e <main+0x1fe>
test   %ebp,%ebp
jns    1456 <main+0x1e6>
lea    0xc2e(%rip),%rdi
call   1130 <error@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <fputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   10c0 <fputc@plt>
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %rbx,%rdi
call   1100 <feof@plt>
test   %eax,%eax
lea    0xc12(%rip),%rbp
jne    12e0 <main+0x70>
jmp    14a0 <main+0x230>
nop
mov    %rbx,%rdi
call   1100 <feof@plt>
test   %eax,%eax
jne    12e0 <main+0x70>
mov    %r15,%rdi
mov    $0x14,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
jns    14d1 <main+0x261>
mov    %rbp,%rdi
call   1130 <error@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   10d0 <read@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1490 <main+0x220>
mov    0x2acb(%rip),%rax
mov    (%rax),%edi
lea    0xbae(%rip),%rsi
call   10f0 <fprintf@plt>
jmp    1490 <main+0x220>
mov    0x2ab4(%rip),%rax
mov    (%rax),%edi
lea    0xaf5(%rip),%rsi
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.salir = [6 x i8] c"salir\00"
@__const.main.ok = [2 x i8] c"OK"
@.str = [9 x i8] c"puntajes\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"ERROR, no port provided\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [25 x i8] c"error opciones de socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"ERROR on binding\00"
@.str.6 = [25 x i8] c"Esperando conexiones...\0A\00"
@.str.7 = [16 x i8] c"ERROR on accept\00"
@.str.8 = [5 x i8] c"-1;a\00"
@.str.9 = [26 x i8] c"ERROR reading from socket\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [24 x i8] c"ERROR writing to socket\00"
@.str.12 = [3 x i8] c"OK\00"
@.str.13 = [8 x i8] c"error\0A\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 i32
%9 = alloca i32
%10 = alloca [20 x i8]
%11 = alloca [6 x i8]
%12 = alloca [2 x i8]
%13 = alloca %struct.sockaddr_in
%14 = alloca %struct.sockaddr_in
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = bitcast [6 x i8]* %11 to i8*
%21 = bitcast [2 x i8]* %12 to i8*
store i32 1, i32* %17
store i32 0, i32* %18
%22 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
br label %30
30: ; preds = %135, %29
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %142
33: ; preds = %30
%34 = load i32, i32* @AF_INET
%35 = load i32, i32* @SOCK_STREAM
%36 = call i32 @socket(i32 %34, i32 %35, i32 0)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
%42 = load i32, i32* %6
%43 = load i32, i32* @SOL_SOCKET
%44 = load i32, i32* @SO_REUSEADDR
%45 = bitcast i32* %17 to i8*
%46 = call i64 @setsockopt(i32 %42, i32 %43, i32 %44, i8* %45, i32 4)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %41
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %8
%55 = load i32, i32* @AF_INET
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 3
store i32 %55, i32* %56
%57 = load i32, i32* @INADDR_ANY
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
store i32 %57, i32* %59
%60 = load i32, i32* %8
%61 = call i32 @htons(i32 %60)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
store i32 %61, i32* %62
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%64 = bitcast i32* %63 to i8*
%65 = call i32 @memset(i8* %64, i8 signext 0, i32 8)
%66 = load i32, i32* %6
%67 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%68 = call i64 @bind(i32 %66, %struct.sockaddr* %67, i32 16)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %50
%71 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %72
72: ; preds = %70, %50
%73 = load i32, i32* %6
%74 = call i32 @listen(i32 %73, i32 5)
store i32 16, i32* %9
%75 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%76 = load i32, i32* %6
%77 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%78 = call i32 @accept(i32 %76, %struct.sockaddr* %77, i32* %9)
store i32 %78, i32* %7
%79 = load i32, i32* %7
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %72
%82 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %83
83: ; preds = %81, %72
%84 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%85 = call i32 @memset(i8* %84, i8 signext 0, i32 20)
%86 = load i32, i32* %7
%87 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%88 = call i32 @read(i32 %86, i8* %87, i32 20)
store i32 %88, i32* %15
%89 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%90 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %89, i32 4)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %103
92: ; preds = %83
%93 = load i32, i32* %15
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %97
97: ; preds = %95, %92
%98 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%99 = load i32*, i32** %19
%100 = call i32 @fputs(i8* %98, i32* %99)
%101 = load i32*, i32** %19
%102 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %101)
br label %103
103: ; preds = %97, %83
%104 = load i32*, i32** %19
%105 = call i32 @rewind(i32* %104)
br label %106
106: ; preds = %134, %103
%107 = load i32*, i32** %19
%108 = call i32 @feof(i32* %107)
%109 = icmp ne i32 %108, 0
%110 = xor i1 %109, true
br i1 %110, label %111, label %135
111: ; preds = %106
%112 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%113 = load i32*, i32** %19
%114 = call i32 @fgets(i8* %112, i32 20, i32* %113)
%115 = load i32, i32* %7
%116 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%117 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%118 = call i32 @strlen(i8* %117)
%119 = call i32 @write(i32 %115, i8* %116, i32 %118)
store i32 %119, i32* %15
%120 = load i32, i32* %15
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %111
%123 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %124
124: ; preds = %122, %111
%125 = load i32, i32* %7
%126 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%127 = call i32 @read(i32 %125, i8* %126, i32 2)
store i32 %127, i32* %15
%128 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%129 = call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %128, i32 2)
%130 = icmp ne i64 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %124
%132 = load i32, i32* @stderr
%133 = call i32 @fprintf(i32 %132, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %134
134: ; preds = %131, %124
br label %106
135: ; preds = %106
%136 = load i32, i32* %7
%137 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
%138 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
%139 = call i32 @strlen(i8* %138)
%140 = call i32 @write(i32 %136, i8* %137, i32 %139)
store i32 %140, i32* %15
%141 = call i32 @sleep(i32 2)
br label %30
142: ; preds = %30
%143 = load i32, i32* %7
%144 = call i32 @close(i32 %143)
%145 = load i32, i32* %6
%146 = call i32 @close(i32 %145)
%147 = load i32*, i32** %19
%148 = call i32 @fclose(i32* %147)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.salir = [6 x i8] c"salir\00"
@.str = [9 x i8] c"puntajes\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"ERROR, no port provided\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [25 x i8] c"error opciones de socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [17 x i8] c"ERROR on binding\00"
@.str.7 = [16 x i8] c"ERROR on accept\00"
@.str.8 = [5 x i8] c"-1;a\00"
@.str.9 = [26 x i8] c"ERROR reading from socket\00"
@.str.11 = [24 x i8] c"ERROR writing to socket\00"
@.str.12 = [3 x i8] c"OK\00"
@.str.13 = [8 x i8] c"error\0A\0A\00"
@str = [24 x i8] c"Esperando conexiones...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca [6 x i8]
%6 = alloca i16
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = bitcast i32* %3 to i8*
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%13 = bitcast i16* %6 to i8*
store i16 19279, i16* %6
%14 = bitcast %struct.sockaddr_in* %7 to i8*
%15 = bitcast %struct.sockaddr_in* %8 to i8*
%16 = bitcast i32* %9 to i8*
store i32 1, i32* %9
%17 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp slt i32 %0, 2
br i1 %18, label %26, label %19
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 3
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2, i32 0
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1
%24 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%25 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
br label %30
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %19, %95
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = call i32 @socket(i32 %31, i32 %32, i32 0)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_REUSEADDR
%40 = call i64 @setsockopt(i32 %33, i32 %38, i32 %39, i8* %16, i32 4)
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
%45 = load i8*, i8** %20
%46 = call i32 @atoi(i8* %45)
%47 = load i32, i32* @AF_INET
store i32 %47, i32* %21
%48 = load i32, i32* @INADDR_ANY
store i32 %48, i32* %22
%49 = call i32 @htons(i32 %46)
store i32 %49, i32* %23
%50 = call i32 @memset(i8* %14, i8 signext 0, i32 8)
%51 = call i64 @bind(i32 %33, %struct.sockaddr* %24, i32 16)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %44
%54 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %44
%56 = call i32 @listen(i32 %33, i32 5)
store i32 16, i32* %3
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%58 = call i32 @accept(i32 %33, %struct.sockaddr* %25, i32* %3)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %62
62: ; preds = %60, %55
%63 = call i32 @memset(i8* %11, i8 signext 0, i32 20)
%64 = call i32 @read(i32 %58, i8* %11, i32 20)
%65 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %11, i32 4)
%66 = icmp eq i64 %65, 0
br i1 %66, label %74, label %67
67: ; preds = %62
%68 = icmp slt i32 %64, 0
br i1 %68, label %69, label %71
69: ; preds = %67
%70 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %71
71: ; preds = %69, %67
%72 = call i32 @fputs(i8* %11, i32* %17)
%73 = call i32 @fputc(i32 10, i32* %17)
br label %74
74: ; preds = %71, %62
%75 = call i32 @rewind(i32* %17)
%76 = call i32 @feof(i32* %17)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %95
78: ; preds = %74, %92
%79 = call i32 @fgets(i8* %11, i32 20, i32* %17)
%80 = call i32 @strlen(i8* %11)
%81 = call i32 @write(i32 %58, i8* %11, i32 %80)
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %85
85: ; preds = %83, %78
%86 = call i32 @read(i32 %58, i8* %13, i32 2)
%87 = call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %13, i32 2)
%88 = icmp eq i64 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %92
92: ; preds = %89, %85
%93 = call i32 @feof(i32* %17)
%94 = icmp eq i32 %93, 0
br i1 %94, label %78, label %95
95: ; preds = %92, %74
%96 = call i32 @strlen(i8* %12)
%97 = call i32 @write(i32 %58, i8* %12, i32 %96)
%98 = call i32 @sleep(i32 2)
br label %30
}