#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*/ zerb_helb;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  scalar_t__ sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ bez_helb;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
scalar_t__ htons(int);
int /*<<< orphan*/ inet_aton(char *, TYPE_1__ *);
int /*<<< orphan*/ printf(char *, char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  char buf[1024];
  int sock;
  int n = 0;
  struct sockaddr_in zerb_helb, bez_helb;
  if (argc != 2) {
    fprintf(stderr, "ARGUMENTUA FALTA, IP HELBIDE BAT SARTU BEHAR DA!!!!",
            argv[0]);
    exit(1);
  }
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  bez_helb.sin_family = AF_INET;
  bez_helb.sin_port = 0;
  bez_helb.sin_addr.s_addr = htonl(INADDR_ANY);
  zerb_helb.sin_family = AF_INET;
  zerb_helb.sin_port = htons(50001);
  inet_aton(argv[1], &zerb_helb.sin_addr);
  bind(sock, (struct sockaddr *)&bez_helb, sizeof(bez_helb));
  while (fgets(buf, 1024, stdin) != NULL) {
    sendto(sock, buf, strlen(buf), 0, (struct sockaddr *)&zerb_helb,
           sizeof(zerb_helb));
    n = recvfrom(sock, buf, 1024, 0, NULL, NULL);
    buf[n] = 0;
    printf("Zerbitzaritik jasotako textua : %s", buf);
  }
  close(sock);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x418(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1223 <main+0x53>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdec(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x414(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x438(%rbp)
movq   $0x0,-0x440(%rbp)
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x448(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x420(%rbp)
mov    $0xc351,%edi
call   1040 <htons@plt>
mov    %rax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x430(%rbp),%rsi
call   10b0 <inet_aton@plt>
mov    -0x414(%rbp),%edi
lea    -0x448(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <bind@plt>
lea    -0x410(%rbp),%rdi
mov    0x2d12(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     137b <main+0x1ab>
mov    -0x414(%rbp),%eax
mov    %eax,-0x454(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x454(%rbp),%edi
mov    -0x450(%rbp),%rsi
mov    %eax,%edx
lea    -0x430(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1070 <sendto@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10c0 <recvfrom@plt>
mov    %eax,-0x418(%rbp)
movslq -0x418(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xcc3(%rip),%rdi
call   1050 <printf@plt>
jmp    12c0 <main+0xf0>
mov    -0x414(%rbp),%edi
call   1080 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x430,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1307 <main+0x137>
mov    0x2df6(%rip),%rbx
mov    (%rbx),%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,%ebp
mov    (%rbx),%rbx
mov    %rbx,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,(%rsp)
mov    %rbx,0x28(%rsp)
mov    $0xc351,%edi
call   1040 <htons@plt>
mov    %rax,0x20(%rsp)
mov    0x8(%r14),%rdi
lea    0x18(%rsp),%rsi
call   10b0 <inet_aton@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10d0 <bind@plt>
mov    0x2d7f(%rip),%r12
mov    (%r12),%edx
lea    0x30(%rsp),%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     12ee <main+0x11e>
lea    0x30(%rsp),%rbx
lea    0x18(%rsp),%r14
lea    0xdaa(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x18,%r9d
call   1070 <sendto@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10c0 <recvfrom@plt>
cltq
movb   $0x0,0x30(%rsp,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
test   %rax,%rax
jne    1290 <main+0xc0>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xce6(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i64, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [52 x i8] c"ARGUMENTUA FALTA, IP HELBIDE BAT SARTU BEHAR DA!!!!\00"
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@stdin = global i32 0
@.str.1 = [35 x i8] c"Zerbitzaritik jasotako textua : %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8*, i8** @AF_INET
%22 = load i32, i32* @SOCK_DGRAM
%23 = call i32 @socket(i8* %21, i32 %22, i32 0)
store i32 %23, i32* %7
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i8* %24, i8** %25
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i64 0, i64* %26
%27 = load i32, i32* @INADDR_ANY
%28 = call i32 @htonl(i32 %27)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 0
store i32 %28, i32* %30
%31 = load i8*, i8** @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i8* %31, i8** %32
%33 = call i64 @htons(i32 50001)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i64 %33, i64* %34
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%39 = call i32 @inet_aton(i8* %37, %struct.TYPE_2__* %38)
%40 = load i32, i32* %7
%41 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%42 = call i32 @bind(i32 %40, %struct.sockaddr* %41, i32 24)
br label %43
43: ; preds = %48, %20
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%45 = load i32, i32* @stdin
%46 = call i32* @fgets(i8* %44, i32 1024, i32 %45)
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %63
48: ; preds = %43
%49 = load i32, i32* %7
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%54 = call i32 @sendto(i32 %49, i8* %50, i32 %52, i32 0, %struct.sockaddr* %53, i32 24)
%55 = load i32, i32* %7
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%57 = call i32 @recvfrom(i32 %55, i8* %56, i32 1024, i32 0, i32* null, i32* null)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %59
store i8 0, i8* %60
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%62 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %61)
br label %43
63: ; preds = %43
%64 = load i32, i32* %7
%65 = call i32 @close(i32 %64)
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i64, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [52 x i8] c"ARGUMENTUA FALTA, IP HELBIDE BAT SARTU BEHAR DA!!!!\00"
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@stdin = global i32 0
@.str.1 = [35 x i8] c"Zerbitzaritik jasotako textua : %s\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 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast %struct.sockaddr_in* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8*, i8** @AF_INET
%17 = load i32, i32* @SOCK_DGRAM
%18 = tail call i32 @socket(i8* %16, i32 %17, i32 0)
%19 = load i8*, i8** @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i8* %19, i8** %20
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i64 0, i64* %21
%22 = load i32, i32* @INADDR_ANY
%23 = tail call i32 @htonl(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %23, i32* %24
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %19, i8** %25
%26 = tail call i64 @htons(i32 50001)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i64 %26, i64* %27
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%31 = call i32 @inet_aton(i8* %29, %struct.TYPE_2__* %30)
%32 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%33 = call i32 @bind(i32 %18, %struct.sockaddr* %32, i32 24)
%34 = load i32, i32* @stdin
%35 = call i32* @fgets(i8* %6, i32 1024, i32 %34)
%36 = icmp eq i32* %35, null
br i1 %36, label %49, label %37
37: ; preds = %15
%38 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %39
39: ; preds = %37, %39
%40 = call i32 @strlen(i8* %6)
%41 = call i32 @sendto(i32 %18, i8* %6, i32 %40, i32 0, %struct.sockaddr* %38, i32 24)
%42 = call i32 @recvfrom(i32 %18, i8* %6, i32 1024, i32 0, i32* null, i32* null)
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %43
store i8 0, i8* %44
%45 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%46 = load i32, i32* @stdin
%47 = call i32* @fgets(i8* %6, i32 1024, i32 %46)
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %39
49: ; preds = %39, %15
%50 = call i32 @close(i32 %18)
ret i32 0
}