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

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
void main(void) {
  struct sockaddr_in me, target;
  int sock;
  char linha[81];
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  bzero((char *)&me, sizeof(me));
  me.sin_family = AF_INET;
  me.sin_addr.s_addr = htonl(INADDR_ANY);
  me.sin_port = htons(0);
  bind(sock, (struct sockaddr *)&me, sizeof(me));
  bzero((char *)&target, sizeof(target));
  target.sin_family = AF_INET;
  target.sin_addr.s_addr = inet_addr("193.136.62.38");
  target.sin_port = htons(7013);
  do {
    gets(linha);
    sendto(sock, linha, 81, 0, (struct sockaddr *)&target, sizeof(target));
  } while (strcmp(linha, "exit"));
  close(sock);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x2e36(%rip),%rax
mov    (%rax),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x34(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x18,%esi
call   10b0 <bzero@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
call   1030 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x18,%edx
call   10a0 <bind@plt>
lea    -0x30(%rbp),%rdi
mov    $0x18,%esi
call   10b0 <bzero@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xdcc(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x28(%rbp)
mov    $0x1b65,%edi
call   1030 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    -0x90(%rbp),%rdi
call   1090 <gets@plt>
mov    -0x34(%rbp),%edi
lea    -0x90(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x51,%edx
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1050 <sendto@plt>
lea    -0x90(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    124a <main+0xaa>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    0x2e34(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%r15d
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x18,%esi
call   10b0 <bzero@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x28(%rsp)
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x20(%rsp)
xor    %edi,%edi
call   1030 <htons@plt>
mov    %rax,0x18(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10a0 <bind@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x18,%esi
call   10b0 <bzero@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x10(%rsp)
lea    0xdcc(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0x8(%rsp)
mov    $0x1b65,%edi
call   1030 <htons@plt>
mov    %rax,(%rsp)
lea    0x30(%rsp),%rbx
lea    0xdb7(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <gets@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x18,%r9d
call   1050 <sendto@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1260 <main+0xc0>
mov    %r15d,%edi
call   1060 <close@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [14 x i8] c"193.136.62.38\00"
@.str.1 = [5 x i8] c"exit\00"
define void @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca [81 x i8]
%5 = load i8*, i8** @AF_INET
%6 = load i32, i32* @SOCK_DGRAM
%7 = call i32 @socket(i8* %5, i32 %6, i32 0)
store i32 %7, i32* %3
%8 = bitcast %struct.sockaddr_in* %1 to i8*
%9 = call i32 @bzero(i8* %8, i32 24)
%10 = load i8*, i8** @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 2
store i8* %10, i8** %11
%12 = load i32, i32* @INADDR_ANY
%13 = call i32 @htonl(i32 %12)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
store i32 %13, i32* %15
%16 = call i8* @htons(i32 0)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
store i8* %16, i8** %17
%18 = load i32, i32* %3
%19 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%20 = call i32 @bind(i32 %18, %struct.sockaddr* %19, i32 24)
%21 = bitcast %struct.sockaddr_in* %2 to i8*
%22 = call i32 @bzero(i8* %21, i32 24)
%23 = load i8*, i8** @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i8* %23, i8** %24
%25 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = call i8* @htons(i32 7013)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
store i8* %28, i8** %29
br label %30
30: ; preds = %37, %0
%31 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%32 = call i32 @gets(i8* %31)
%33 = load i32, i32* %3
%34 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%35 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%36 = call i32 @sendto(i32 %33, i8* %34, i32 81, i32 0, %struct.sockaddr* %35, i32 24)
br label %37
37: ; preds = %30
%38 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %30, label %41
41: ; preds = %37
%42 = load i32, i32* %3
%43 = call i32 @close(i32 %42)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [14 x i8] c"193.136.62.38\00"
@.str.1 = [5 x i8] c"exit\00"
define void @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca [81 x i8]
%4 = bitcast %struct.sockaddr_in* %1 to i8*
%5 = bitcast %struct.sockaddr_in* %2 to i8*
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = tail call i32 @socket(i8* %7, i32 %8, i32 0)
%10 = call i32 @bzero(i8* %4, i32 24)
%11 = load i8*, i8** @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i8* %11, i8** %12
%13 = load i32, i32* @INADDR_ANY
%14 = tail call i32 @htonl(i32 %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %14, i32* %15
%16 = tail call i8* @htons(i32 0)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i8* %16, i8** %17
%18 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%19 = call i32 @bind(i32 %9, %struct.sockaddr* %18, i32 24)
%20 = call i32 @bzero(i8* %5, i32 24)
%21 = load i8*, i8** @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i8* %21, i8** %22
%23 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %23, i32* %24
%25 = call i8* @htons(i32 7013)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i8* %25, i8** %26
%27 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %28
28: ; preds = %28, %0
%29 = call i32 @gets(i8* %6)
%30 = call i32 @sendto(i32 %9, i8* %6, i32 81, i32 0, %struct.sockaddr* %27, i32 24)
%31 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %28
33: ; preds = %28
%34 = call i32 @close(i32 %9)
ret void
}