#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_2;
typedef int /*<<< orphan*/ zerb_helb;
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;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
scalar_t__ 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*/ herror(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 recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int sock, n;
  char buf[1024];
  struct sockaddr_in zerb_helb, zerb_helb_2;
  struct hostent *hp;
  socklen_t helb_tam;
  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(50005);
  if ((hp = gethostbyname(argv[1])) == NULL) {
    herror("Errorea zerbitzariaren izena ebaztean");
    exit(1);
  }
  memcpy(&zerb_helb.sin_addr, hp->h_addr, hp->h_length);
  helb_tam = sizeof(zerb_helb_2);
  if (fgets(buf, 1024, stdin) == NULL) {
    printf("errorea irakurtzean");
  }
  if (sendto(sock, buf, strlen(buf), 0, (struct sockaddr *)&zerb_helb,
             sizeof(zerb_helb)) == -1) {
    printf("errorea mezua socketari bidaltzean");
    exit(1);
  }
  if ((n = recvfrom(sock, buf, 1024, 0, (struct sockaddr *)&zerb_helb_2,
                    &helb_tam)) == -1) {
    printf("errorea mezua jasotzean");
    exit(1);
  }
  buf[n] = 0;
  printf("%s", buf);
  if (connect(sock, (struct sockaddr *)&zerb_helb_2, sizeof(zerb_helb_2)) < 0) {
    perror("Error zerbitzariarekin konektatzean");
    exit(1);
  }
  while (fgets(buf, 1024, stdin) != NULL) {
    if (write(sock, buf, strlen(buf)) < strlen(buf)) {
      perror("Errorea datuak bidaltzean");
      exit(1);
    }
    if ((n = read(sock, buf, 1024)) < 0) {
      perror("Errorea datuak jasotzean");
      exit(1);
    }
    buf[n] = 0;
    printf("%s", buf);
  }
  if (write(sock, NULL, 0) == -1) {
    printf("errorea mezu hutsa bidaltzean");
    exit(1);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     1269 <main+0x49>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda6(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12a4 <main+0x84>
lea    0xd9d(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    $0xc355,%edi
call   1050 <htons@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x448(%rbp)
cmp    $0x0,%rax
jne    130a <main+0xea>
lea    0xd50(%rip),%rdi
call   10f0 <herror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x430(%rbp),%rdi
mov    -0x448(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x448(%rbp),%rax
mov    (%rax),%edx
call   10e0 <memcpy@plt>
movl   $0xc,-0x44c(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
jne    1365 <main+0x145>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
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
lea    -0x430(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
jne    13cc <main+0x1ac>
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
lea    -0x440(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
lea    -0x44c(%rbp),%r9
call   1100 <recvfrom@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1414 <main+0x1f4>
lea    0xca5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0x0,%rax
jge    1469 <main+0x249>
lea    0xc69(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    146e <main+0x24e>
lea    -0x420(%rbp),%rdi
mov    0x2b64(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     155d <main+0x33d>
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,-0x460(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x460(%rbp),%eax
cmp    %ecx,%eax
jge    1501 <main+0x2e1>
lea    0xbf5(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1537 <main+0x317>
lea    0xbd9(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xb6f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    146e <main+0x24e>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    158c <main+0x36c>
lea    0xb9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
xor    %edi,%edi
call   1120 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x430,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    126b <main+0x4b>
mov    0x2daa(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
jns    128d <main+0x6d>
lea    0xdd6(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd82(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %eax,%r15d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    $0xc355,%edi
call   1050 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rbx),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
jne    12da <main+0xba>
lea    0xd80(%rip),%rdi
call   10f0 <herror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    (%rax),%edx
mov    0x4(%rax),%esi
lea    0x10(%rsp),%rdi
call   10e0 <memcpy@plt>
movl   $0xc,0xc(%rsp)
mov    0x2ce8(%rip),%r12
mov    (%r12),%edx
lea    0x30(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
jne    131e <main+0xfe>
lea    0xd5a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x10(%rsp),%r8
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1353 <main+0x133>
lea    0xd34(%rip),%rdi
jmp    137d <main+0x15d>
lea    0x30(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %r15d,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1100 <recvfrom@plt>
cmp    $0xffffffff,%eax
jne    138e <main+0x16e>
lea    0xd2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
cltq
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd24(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r15d,%edi
mov    $0xc,%edx
call   1130 <connect@plt>
test   %rax,%rax
jns    13cb <main+0x1ab>
lea    0xcfd(%rip),%rdi
jmp    125c <main+0x3c>
mov    (%r12),%edx
lea    0x30(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
je     1451 <main+0x231>
lea    0x30(%rsp),%rbx
lea    0xcd1(%rip),%r14
nop
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jl     147d <main+0x25d>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
test   %eax,%eax
js     1489 <main+0x269>
mov    %eax,%eax
movb   $0x0,0x30(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
jne    13f0 <main+0x1d0>
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    146e <main+0x24e>
lea    0xcb1(%rip),%rdi
jmp    137d <main+0x15d>
mov    %r15d,%edi
call   1090 <close@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    0xc63(%rip),%rdi
jmp    125c <main+0x3c>
lea    0xc71(%rip),%rdi
jmp    125c <main+0x3c>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%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 = [38 x i8] c"Errorea zerbitzariaren izena ebaztean\00"
@stdin = global i32 0
@.str.3 = [20 x i8] c"errorea irakurtzean\00"
@.str.4 = [35 x i8] c"errorea mezua socketari bidaltzean\00"
@.str.5 = [24 x i8] c"errorea mezua jasotzean\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [36 x i8] c"Error zerbitzariarekin konektatzean\00"
@.str.8 = [26 x i8] c"Errorea datuak bidaltzean\00"
@.str.9 = [25 x i8] c"Errorea datuak jasotzean\00"
@.str.10 = [30 x i8] c"errorea mezu hutsa bidaltzean\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 [1024 x i8]
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* @SOCK_DGRAM
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %22
%31 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %32, i32* %33
%34 = call i32 @htons(i32 50005)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %34, i32* %35
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call %struct.hostent* @gethostbyname(i8* %38)
store %struct.hostent* %39, %struct.hostent** %11
%40 = icmp eq %struct.hostent* %39, null
br i1 %40, label %41, label %44
41: ; preds = %30
%42 = call i32 @herror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %30
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%46 = load %struct.hostent*, %struct.hostent** %11
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %46, i32 0, i32 1
%48 = load i32, i32* %47
%49 = load %struct.hostent*, %struct.hostent** %11
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @memcpy(i32* %45, i32 %48, i32 %51)
store i32 12, i32* %12
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%54 = load i32, i32* @stdin
%55 = call i32* @fgets(i8* %53, i32 1024, i32 %54)
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %44
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %59
59: ; preds = %57, %44
%60 = load i32, i32* %6
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%65 = call i32 @sendto(i32 %60, i8* %61, i32 %63, i32 0, %struct.sockaddr* %64, i32 12)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %59
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %59
%71 = load i32, i32* %6
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%73 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%74 = call i32 @recvfrom(i32 %71, i8* %72, i32 1024, i32 0, %struct.sockaddr* %73, i32* %12)
store i32 %74, i32* %7
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %79
76: ; preds = %70
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %70
%80 = load i32, i32* %7
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %81
store i8 0, i8* %82
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %6
%86 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%87 = call i64 @connect(i32 %85, %struct.sockaddr* %86, i32 12)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %79
%90 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %79
br label %93
93: ; preds = %118, %92
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%95 = load i32, i32* @stdin
%96 = call i32* @fgets(i8* %94, i32 1024, i32 %95)
%97 = icmp ne i32* %96, null
br i1 %97, label %98, label %124
98: ; preds = %93
%99 = load i32, i32* %6
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%102 = call i32 @strlen(i8* %101)
%103 = call i32 @write(i32 %99, i8* %100, i32 %102)
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%105 = call i32 @strlen(i8* %104)
%106 = icmp slt i32 %103, %105
br i1 %106, label %107, label %110
107: ; preds = %98
%108 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %98
%111 = load i32, i32* %6
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%113 = call i32 @read(i32 %111, i8* %112, i32 1024)
store i32 %113, i32* %7
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %110
%116 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %110
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %120
store i8 0, i8* %121
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %122)
br label %93
124: ; preds = %93
%125 = load i32, i32* %6
%126 = call i32 @write(i32 %125, i8* null, i32 0)
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %131
128: ; preds = %124
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%130 = call i32 @exit(i32 1)
unreachable
131: ; preds = %124
%132 = load i32, i32* %6
%133 = call i32 @close(i32 %132)
%134 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%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 = [38 x i8] c"Errorea zerbitzariaren izena ebaztean\00"
@stdin = global i32 0
@.str.3 = [20 x i8] c"errorea irakurtzean\00"
@.str.4 = [35 x i8] c"errorea mezua socketari bidaltzean\00"
@.str.5 = [24 x i8] c"errorea mezua jasotzean\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [36 x i8] c"Error zerbitzariarekin konektatzean\00"
@.str.8 = [26 x i8] c"Errorea datuak bidaltzean\00"
@.str.9 = [25 x i8] c"Errorea datuak jasotzean\00"
@.str.10 = [30 x i8] c"errorea mezu hutsa bidaltzean\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast %struct.sockaddr_in* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_DGRAM
%20 = tail call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = call i32 @htons(i32 50005)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %29, i32* %30
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = call %struct.hostent* @gethostbyname(i8* %32)
%34 = icmp eq %struct.hostent* %33, null
br i1 %34, label %35, label %38
35: ; preds = %25
%36 = call i32 @herror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %25
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i64 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i64 0, i32 0
%43 = load i32, i32* %42
%44 = call i32 @memcpy(i32* %39, i32 %41, i32 %43)
store i32 12, i32* %6
%45 = load i32, i32* @stdin
%46 = call i32* @fgets(i8* %7, i32 1024, i32 %45)
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %50
48: ; preds = %38
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %38
%51 = call i32 @strlen(i8* %7)
%52 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%53 = call i32 @sendto(i32 %20, i8* %7, i32 %51, i32 0, %struct.sockaddr* %52, i32 12)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %50
%59 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%60 = call i32 @recvfrom(i32 %20, i8* %7, i32 1024, i32 0, %struct.sockaddr* %59, i32* %6)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %58
%66 = sext i32 %60 to i64
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %66
store i8 0, i8* %67
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%69 = call i64 @connect(i32 %20, %struct.sockaddr* %59, i32 12)
%70 = icmp slt i64 %69, 0
br i1 %70, label %75, label %71
71: ; preds = %65
%72 = load i32, i32* @stdin
%73 = call i32* @fgets(i8* %7, i32 1024, i32 %72)
%74 = icmp eq i32* %73, null
br i1 %74, label %99, label %78
75: ; preds = %65
%76 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %71, %92
%79 = call i32 @strlen(i8* %7)
%80 = call i32 @write(i32 %20, i8* %7, i32 %79)
%81 = call i32 @strlen(i8* %7)
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %86
83: ; preds = %78
%84 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %78
%87 = call i32 @read(i32 %20, i8* %7, i32 1024)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %86
%93 = zext i32 %87 to i64
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %93
store i8 0, i8* %94
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%96 = load i32, i32* @stdin
%97 = call i32* @fgets(i8* %7, i32 1024, i32 %96)
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %78
99: ; preds = %92, %71
%100 = call i32 @write(i32 %20, i8* null, i32 0)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %99
%106 = call i32 @close(i32 %20)
%107 = call i32 @exit(i32 0)
unreachable
}