#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 */
typedef int /*<<< orphan*/ zerb_helb;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ *h_addr_list;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sock;
  int n, saiakera, bez_kop;
  char buf[1024];
  struct sockaddr_in zerb_helb;
  struct hostent *zerbitzari;
  fd_set readfds;
  struct timeval denbora;
  denbora.tv_sec = 1;
  denbora.tv_usec = 0;
  if (argc != 2) {
    fprintf(stderr, "Erabilera: %s <zerbitzari izena | IPv4 helbidea>\n",
            argv[0]);
    exit(1);
  }
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("Errorea socketa sortzean");
    exit(1);
  }
  memset(&zerb_helb, 0, sizeof(zerb_helb));
  zerb_helb.sin_family = AF_INET;
  zerb_helb.sin_port = htons(50003);
  if ((zerbitzari = gethostbyname(argv[1])) == NULL) {
    fprintf(stderr, "Errora lehenbiziko parametroan: %s\n", argv[1]);
    exit(1);
  }
  memcpy(&zerb_helb.sin_addr, zerbitzari->h_addr_list[0], zerbitzari->h_length);
  if (connect(sock, (struct sockaddr *)&zerb_helb, sizeof(zerb_helb)) == -1) {
    printf("ERROREA KONEKTATZEAN\n");
    exit(1);
  }
  while (fgets(buf, 1024, stdin) != NULL) {
    if ((n = write(sock, buf, strlen(buf))) == -1) {
      printf("ERROREA DATUAK BIDALTZEAN");
      exit(1);
    }
    saiakera = 0;
    while (saiakera++ < 3) {
      FD_ZERO(&readfds);
      FD_SET(sock, &readfds);
      denbora.tv_sec = 1;
      denbora.tv_usec = 0;
      bez_kop = select(sock + 1, &readfds, NULL, NULL, &denbora);
      if (bez_kop == -1) {
        printf("ERROREA SELECTEAN");
        exit(1);
      }
      if (bez_kop == 0) {
        printf("Itxarote denbora agortua!!!  %d  .saiakera burutua \n",
               saiakera);
        if ((n = write(sock, buf, strlen(buf))) == -1) {
          printf("ERROREA BIDALKETAN");
          exit(1);
        }
      } else
        break;
    }
    if (saiakera == 4) {
      printf(
          "\n Saiakera kopurua agortuta, honenbestez programa amaituko da \n");
      exit(1);
    }
    if (read(sock, buf, n) == -1) {
      printf("ERROREA DATUAK JASOTZEAN");
      exit(1);
    }
    buf[n] = 0;
    printf("%s", buf);
  }
  close(sock);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x450(%rbp)
movq   $0x0,-0x448(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     127e <main+0x5e>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd91(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12b9 <main+0x99>
lea    0xd88(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    $0xc353,%edi
call   1050 <htons@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x438(%rbp)
cmp    $0x0,%rax
jne    1330 <main+0x110>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd2a(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x430(%rbp),%rdi
mov    -0x438(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    -0x438(%rbp),%rax
mov    (%rax),%edx
call   10d0 <memcpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    1387 <main+0x167>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    138c <main+0x16c>
lea    -0x420(%rbp),%rdi
mov    0x2c46(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     159b <main+0x37b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x45c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x458(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x45c(%rbp),%edi
mov    -0x458(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    140b <main+0x1eb>
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x3,%eax
jge    1520 <main+0x300>
lea    -0x43c(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x43c(%rbp),%rsi
call   1130 <FD_SET@plt>
movl   $0x1,-0x450(%rbp)
movq   $0x0,-0x448(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x43c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x450(%rbp),%r8
mov    %rcx,%rdx
call   10f0 <select@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    149b <main+0x27b>
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x20(%rbp)
jne    1516 <main+0x2f6>
mov    -0x1c(%rbp),%esi
lea    0xc02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x46c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x468(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x46c(%rbp),%edi
mov    -0x468(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1511 <main+0x2f1>
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    151b <main+0x2fb>
jmp    1520 <main+0x300>
jmp    1412 <main+0x1f2>
cmpl   $0x4,-0x1c(%rbp)
jne    1542 <main+0x322>
lea    0xbc8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
jne    1575 <main+0x355>
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138c <main+0x16c>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsi,%rbp
movl   $0x1,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    128d <main+0x5d>
mov    0x2d88(%rip),%r14
mov    (%r14),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
jns    12b0 <main+0x80>
lea    0xdb4(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd5f(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%r14),%eax
mov    %eax,0x18(%rsp)
mov    $0xc353,%edi
call   1060 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rbp),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
jne    12fc <main+0xcc>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xd51(%rip),%rsi
jmp    12a1 <main+0x71>
mov    0x8(%rax),%rcx
mov    (%rcx),%esi
mov    (%rax),%edx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   10e0 <memcpy@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0xffffffff,%eax
jne    133b <main+0x10b>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
jne    1366 <main+0x136>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    %ebx,%r14d
add    $0x1,%r14d
lea    0x20(%rsp),%rbp
lea    0x1c(%rsp),%r15
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     150f <main+0x2df>
mov    %eax,%r13d
mov    %r15,%rdi
call   10f0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1140 <FD_SET@plt>
movl   $0x1,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1100 <select@plt>
test   %eax,%eax
jne    1443 <main+0x213>
lea    0xcbc(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     155b <main+0x32b>
mov    %eax,%r13d
mov    %r15,%rdi
call   10f0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1140 <FD_SET@plt>
movl   $0x1,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1100 <select@plt>
test   %eax,%eax
je     1450 <main+0x220>
cmp    $0xffffffff,%eax
jne    14c0 <main+0x290>
jmp    1518 <main+0x2e8>
nopl   (%rax)
lea    0xc44(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     155b <main+0x32b>
mov    %eax,%r13d
mov    %r15,%rdi
call   10f0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1140 <FD_SET@plt>
movl   $0x1,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1100 <select@plt>
cmp    $0xffffffff,%eax
je     1518 <main+0x2e8>
test   %eax,%eax
je     152a <main+0x2fa>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r13d,%edx
call   10a0 <read@plt>
cmp    $0xffffffff,%eax
je     1521 <main+0x2f1>
movslq %r13d,%rax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xc1b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2aee(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
jne    1380 <main+0x150>
jmp    1358 <main+0x128>
lea    0xb59(%rip),%rdi
jmp    1562 <main+0x332>
lea    0xb6a(%rip),%rdi
jmp    1562 <main+0x332>
lea    0xbbb(%rip),%rdi
jmp    1562 <main+0x332>
lea    0xb6a(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1573 <main+0x343>
lea    0xb6e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xb85(%rip),%rdi
jmp    132c <main+0xfc>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i32* }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [50 x i8] c"Erabilera: %s <zerbitzari izena | IPv4 helbidea>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [25 x i8] c"Errorea socketa sortzean\00"
@.str.2 = [36 x i8] c"Errora lehenbiziko parametroan: %s\0A\00"
@.str.3 = [22 x i8] c"ERROREA KONEKTATZEAN\0A\00"
@stdin = global i32 0
@.str.4 = [26 x i8] c"ERROREA DATUAK BIDALTZEAN\00"
@.str.5 = [18 x i8] c"ERROREA SELECTEAN\00"
@.str.6 = [53 x i8] c"Itxarote denbora agortua!!! %d .saiakera burutua \0A\00"
@.str.7 = [19 x i8] c"ERROREA BIDALKETAN\00"
@.str.8 = [64 x i8] c"\0A Saiakera kopurua agortuta, honenbestez programa amaituko da \0A\00"
@.str.9 = [25 x i8] c"ERROREA DATUAK JASOTZEAN\00"
@.str.10 = [3 x i8] c"%s\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 [1024 x i8]
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.hostent*
%13 = alloca i32
%14 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 1, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i64 0, i64* %16
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* @AF_INET
%28 = load i32, i32* @SOCK_DGRAM
%29 = call i32 @socket(i32 %27, i32 %28, i32 0)
store i32 %29, i32* %6
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %26
%35 = call i32 @memset(%struct.sockaddr_in* %11, i32 0, i32 12)
%36 = load i32, i32* @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %36, i32* %37
%38 = call i32 @htons(i32 50003)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %38, i32* %39
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call %struct.hostent* @gethostbyname(i8* %42)
store %struct.hostent* %43, %struct.hostent** %12
%44 = icmp eq %struct.hostent* %43, null
br i1 %44, label %45, label %52
45: ; preds = %34
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %34
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%54 = load %struct.hostent*, %struct.hostent** %12
%55 = getelementptr inbounds %struct.hostent, %struct.hostent* %54, i32 0, i32 1
%56 = load i32*, i32** %55
%57 = getelementptr inbounds i32, i32* %56, i64 0
%58 = load i32, i32* %57
%59 = load %struct.hostent*, %struct.hostent** %12
%60 = getelementptr inbounds %struct.hostent, %struct.hostent* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = call i32 @memcpy(i32* %53, i32 %58, i32 %61)
%63 = load i32, i32* %6
%64 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%65 = call i32 @connect(i32 %63, %struct.sockaddr* %64, i32 12)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %52
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %52
br label %71
71: ; preds = %138, %70
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%73 = load i32, i32* @stdin
%74 = call i32* @fgets(i8* %72, i32 1024, i32 %73)
%75 = icmp ne i32* %74, null
br i1 %75, label %76, label %144
76: ; preds = %71
%77 = load i32, i32* %6
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%80 = call i32 @strlen(i8* %79)
%81 = call i32 @write(i32 %77, i8* %78, i32 %80)
store i32 %81, i32* %7
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %86
83: ; preds = %76
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %76
store i32 0, i32* %8
br label %87
87: ; preds = %122, %86
%88 = load i32, i32* %8
%89 = add nsw i32 %88, 1
store i32 %89, i32* %8
%90 = icmp slt i32 %88, 3
br i1 %90, label %91, label %123
91: ; preds = %87
%92 = call i32 @FD_ZERO(i32* %13)
%93 = load i32, i32* %6
%94 = call i32 @FD_SET(i32 %93, i32* %13)
%95 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 1, i32* %95
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i64 0, i64* %96
%97 = load i32, i32* %6
%98 = add nsw i32 %97, 1
%99 = call i32 @select(i32 %98, i32* %13, i32* null, i32* null, %struct.timeval* %14)
store i32 %99, i32* %9
%100 = load i32, i32* %9
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %91
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %91
%106 = load i32, i32* %9
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %121
108: ; preds = %105
%109 = load i32, i32* %8
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 %109)
%111 = load i32, i32* %6
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%114 = call i32 @strlen(i8* %113)
%115 = call i32 @write(i32 %111, i8* %112, i32 %114)
store i32 %115, i32* %7
%116 = icmp eq i32 %115, -1
br i1 %116, label %117, label %120
117: ; preds = %108
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %108
br label %122
121: ; preds = %105
br label %123
122: ; preds = %120
br label %87
123: ; preds = %121, %87
%124 = load i32, i32* %8
%125 = icmp eq i32 %124, 4
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %123
%130 = load i32, i32* %6
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%132 = load i32, i32* %7
%133 = call i32 @read(i32 %130, i8* %131, i32 %132)
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %138
135: ; preds = %129
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%137 = call i32 @exit(i32 1)
unreachable
138: ; preds = %129
%139 = load i32, i32* %7
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %140
store i8 0, i8* %141
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %142)
br label %71
144: ; preds = %71
%145 = load i32, i32* %6
%146 = call i32 @close(i32 %145)
%147 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i32, i64 }
%struct.hostent = type { i32, i32* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [50 x i8] c"Erabilera: %s <zerbitzari izena | IPv4 helbidea>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [25 x i8] c"Errorea socketa sortzean\00"
@.str.2 = [36 x i8] c"Errora lehenbiziko parametroan: %s\0A\00"
@stdin = global i32 0
@.str.4 = [26 x i8] c"ERROREA DATUAK BIDALTZEAN\00"
@.str.5 = [18 x i8] c"ERROREA SELECTEAN\00"
@.str.6 = [53 x i8] c"Itxarote denbora agortua!!! %d .saiakera burutua \0A\00"
@.str.7 = [19 x i8] c"ERROREA BIDALKETAN\00"
@.str.9 = [25 x i8] c"ERROREA DATUAK JASOTZEAN\00"
@.str.10 = [3 x i8] c"%s\00"
@str = [63 x i8] c"\0A Saiakera kopurua agortuta, honenbestez programa amaituko da \00"
@str.11 = [21 x i8] c"ERROREA KONEKTATZEAN\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca %struct.timeval
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast %struct.timeval* %6 to i8*
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
store i32 1, i32* %11
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
store i64 0, i64* %12
%13 = icmp eq i32 %0, 2
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_DGRAM
%22 = tail call i32 @socket(i32 %20, i32 %21, i32 0)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %19
%28 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %29, i32* %30
%31 = call i32 @htons(i32 50003)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %31, i32* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = call %struct.hostent* @gethostbyname(i8* %34)
%36 = icmp eq %struct.hostent* %35, null
br i1 %36, label %37, label %42
37: ; preds = %27
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %33
%40 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %27
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%44 = getelementptr inbounds %struct.hostent, %struct.hostent* %35, i64 0, i32 1
%45 = load i32*, i32** %44
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %35, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @memcpy(i32* %43, i32 %46, i32 %48)
%50 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%51 = call i32 @connect(i32 %22, %struct.sockaddr* %50, i32 12)
%52 = icmp eq i32 %51, -1
br i1 %52, label %59, label %53
53: ; preds = %42
%54 = load i32, i32* @stdin
%55 = call i32* @fgets(i8* %7, i32 1024, i32 %54)
%56 = icmp eq i32* %55, null
br i1 %56, label %119, label %57
57: ; preds = %53
%58 = add nuw nsw i32 %22, 1
br label %62
59: ; preds = %42
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %57, %112
%63 = call i32 @strlen(i8* %7)
%64 = call i32 @write(i32 %22, i8* %7, i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %70, label %66
66: ; preds = %62
%67 = call i32 @FD_ZERO(i32* %5)
%68 = call i32 @FD_SET(i32 %22, i32* %5)
store i32 1, i32* %11
store i64 0, i64* %12
%69 = call i32 @select(i32 %58, i32* %5, i32* null, i32* null, %struct.timeval* %6)
switch i32 %69, label %105 [
i32 -1, label %73
i32 0, label %76
]
70: ; preds = %62
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %90, %81, %66
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %66
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 1)
%78 = call i32 @strlen(i8* %7)
%79 = call i32 @write(i32 %22, i8* %7, i32 %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %99, label %81
81: ; preds = %76
%82 = call i32 @FD_ZERO(i32* %5)
%83 = call i32 @FD_SET(i32 %22, i32* %5)
store i32 1, i32* %11
store i64 0, i64* %12
%84 = call i32 @select(i32 %58, i32* %5, i32* null, i32* null, %struct.timeval* %6)
switch i32 %84, label %105 [
i32 -1, label %73
i32 0, label %85
]
85: ; preds = %81
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 2)
%87 = call i32 @strlen(i8* %7)
%88 = call i32 @write(i32 %22, i8* %7, i32 %87)
%89 = icmp eq i32 %88, -1
br i1 %89, label %99, label %90
90: ; preds = %85
%91 = call i32 @FD_ZERO(i32* %5)
%92 = call i32 @FD_SET(i32 %22, i32* %5)
store i32 1, i32* %11
store i64 0, i64* %12
%93 = call i32 @select(i32 %58, i32* %5, i32* null, i32* null, %struct.timeval* %6)
switch i32 %93, label %105 [
i32 -1, label %73
i32 0, label %94
]
94: ; preds = %90
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 3)
%96 = call i32 @strlen(i8* %7)
%97 = call i32 @write(i32 %22, i8* %7, i32 %96)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %85, %76, %94
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %94
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %66, %81, %90
%106 = phi i32 [ %64, %66 ], [ %79, %81 ], [ %88, %90 ]
%107 = call i32 @read(i32 %22, i8* %7, i32 %106)
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %112
109: ; preds = %105
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %105
%113 = sext i32 %106 to i64
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %113
store i8 0, i8* %114
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %7)
%116 = load i32, i32* @stdin
%117 = call i32* @fgets(i8* %7, i32 1024, i32 %116)
%118 = icmp eq i32* %117, null
br i1 %118, label %119, label %62
119: ; preds = %112, %53
%120 = call i32 @close(i32 %22)
%121 = call i32 @exit(i32 0)
unreachable
}