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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ recvfrom(int, char *, int, int /*<<< orphan*/,
                            struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
void main(void) {
  struct sockaddr_in me, from;
  int sock, adl;
  char linha[81];
  adl = sizeof(me);
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  bzero((char *)&me, adl);
  me.sin_family = AF_INET;
  me.sin_addr.s_addr = htonl(INADDR_ANY);
  me.sin_port = htons(7013);
  if (-1 == bind(sock, (struct sockaddr *)&me, adl)) {
    puts("Porta Ocupada");
    close(sock);
    exit(1);
  }
  do {
    recvfrom(sock, linha, 81, 0, (struct sockaddr *)&from, &adl);
    puts(linha);
  } while (strcmp(linha, "exit"));
  close(sock);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0xc,-0x28(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x24(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10a0 <bzero@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1b65,%edi
call   1040 <htons@plt>
mov    %eax,-0x10(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1090 <bind@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1240 <main+0xa0>
lea    0xdd7(%rip),%rdi
call   1030 <puts@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1245 <main+0xa5>
mov    -0x24(%rbp),%edi
lea    -0x80(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    $0x51,%edx
xor    %ecx,%ecx
lea    -0x28(%rbp),%r9
call   1080 <recvfrom@plt>
lea    -0x80(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x80(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <main+0xa5>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
movl   $0xc,0xc(%rsp)
mov    0x2e2a(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   10a0 <bzero@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    $0x1b65,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
cmp    $0xffffffff,%eax
je     1286 <main+0xe6>
lea    0x30(%rsp),%rbx
lea    0x20(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0xdda(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1080 <recvfrom@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0xa0>
mov    %ebp,%edi
call   1060 <close@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd73(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

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

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