#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*/ um;
typedef int /*<<< orphan*/ ulong;
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*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BROADCAST;
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*/ puts(char *);
int /*<<< orphan*/ recvfrom(int, char *, int, int /*<<< orphan*/,
                            struct sockaddr *, int *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
void main() {
  struct sockaddr_in me, target;
  int sock, adl, um;
  char linha[81];
  ulong ip1 = 0;
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  adl = sizeof(me);
  um = 1;
  setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &um, sizeof(um));
  bzero((char *)&me, adl);
  me.sin_family = AF_INET;
  me.sin_addr.s_addr = htonl(INADDR_ANY);
  me.sin_port = htons(0);
  bind(sock, (struct sockaddr *)&me, adl);
  bzero((char *)&target, adl);
  target.sin_family = AF_INET;
  target.sin_addr.s_addr = inet_addr("255.255.255.255");
  target.sin_port = htons(7004);
  do {
    gets(linha);
    sendto(sock, linha, 81, 0, (struct sockaddr *)&target, adl);
    recvfrom(sock, linha, 81, 0, (struct sockaddr *)&target, &adl);
    puts(linha);
  } while (strcmp(linha, "rias"));
  close(sock);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x94(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x34(%rbp)
movl   $0x18,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
lea    -0x3c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10e0 <bzero@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
call   1050 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   10d0 <bind@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10e0 <bzero@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xd66(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x28(%rbp)
mov    $0x1b5c,%edi
call   1050 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    -0x90(%rbp),%rdi
call   10b0 <gets@plt>
mov    -0x34(%rbp),%edi
lea    -0x90(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9d
mov    $0x51,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
mov    -0x34(%rbp),%edi
lea    -0x90(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x51,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r9
call   10c0 <recvfrom@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12b0 <main+0xe0>
mov    -0x34(%rbp),%edi
call   1080 <close@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    0x2dfa(%rip),%r15
mov    (%r15),%rdi
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,%ebp
movl   $0x18,0x8(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
mov    0x2dad(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x18,%esi
call   10e0 <bzero@plt>
mov    (%r15),%rax
mov    %rax,0x38(%rsp)
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,0x30(%rsp)
xor    %edi,%edi
call   1050 <htons@plt>
mov    %rax,0x28(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10d0 <bind@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x18,%esi
call   10e0 <bzero@plt>
mov    (%r15),%rax
mov    %rax,0x20(%rsp)
lea    0xd69(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x18(%rsp)
mov    $0x1b5c,%edi
call   1050 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0x40(%rsp),%rbx
lea    0x8(%rsp),%r15
lea    0xd50(%rip),%r12
mov    %rbx,%rdi
call   10b0 <gets@plt>
mov    0x8(%rsp),%r9d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   1070 <sendto@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   10c0 <recvfrom@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    12c0 <main+0xf0>
mov    %ebp,%edi
call   1080 <close@plt>
add    $0xa0,%rsp
pop    %rbx
pop    %r12
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
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@INADDR_ANY = global i32 0
@.str = [16 x i8] c"255.255.255.255\00"
@.str.1 = [5 x i8] c"rias\00"
define void @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [81 x i8]
%7 = alloca i32
store i32 0, i32* %7
%8 = load i8*, i8** @AF_INET
%9 = load i32, i32* @SOCK_DGRAM
%10 = call i32 @socket(i8* %8, i32 %9, i32 0)
store i32 %10, i32* %3
store i32 24, i32* %4
store i32 1, i32* %5
%11 = load i32, i32* %3
%12 = load i32, i32* @SOL_SOCKET
%13 = load i32, i32* @SO_BROADCAST
%14 = call i32 @setsockopt(i32 %11, i32 %12, i32 %13, i32* %5, i32 4)
%15 = bitcast %struct.sockaddr_in* %1 to i8*
%16 = load i32, i32* %4
%17 = call i32 @bzero(i8* %15, i32 %16)
%18 = load i8*, i8** @AF_INET
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 2
store i8* %18, i8** %19
%20 = load i32, i32* @INADDR_ANY
%21 = call i32 @htonl(i32 %20)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
store i32 %21, i32* %23
%24 = call i8* @htons(i32 0)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
store i8* %24, i8** %25
%26 = load i32, i32* %3
%27 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%28 = load i32, i32* %4
%29 = call i32 @bind(i32 %26, %struct.sockaddr* %27, i32 %28)
%30 = bitcast %struct.sockaddr_in* %2 to i8*
%31 = load i32, i32* %4
%32 = call i32 @bzero(i8* %30, i32 %31)
%33 = load i8*, i8** @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i8* %33, i8** %34
%35 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
%37 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i32 0, i32 0
store i32 %35, i32* %37
%38 = call i8* @htons(i32 7004)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
store i8* %38, i8** %39
br label %40
40: ; preds = %54, %0
%41 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%42 = call i32 @gets(i8* %41)
%43 = load i32, i32* %3
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%45 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%46 = load i32, i32* %4
%47 = call i32 @sendto(i32 %43, i8* %44, i32 81, i32 0, %struct.sockaddr* %45, i32 %46)
%48 = load i32, i32* %3
%49 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%50 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%51 = call i32 @recvfrom(i32 %48, i8* %49, i32 81, i32 0, %struct.sockaddr* %50, i32* %4)
%52 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%53 = call i32 @puts(i8* %52)
br label %54
54: ; preds = %40
%55 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %40, label %58
58: ; preds = %54
%59 = load i32, i32* %3
%60 = call i32 @close(i32 %59)
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
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@INADDR_ANY = global i32 0
@.str = [16 x i8] c"255.255.255.255\00"
@.str.1 = [5 x i8] c"rias\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]
%6 = bitcast %struct.sockaddr_in* %1 to i8*
%7 = bitcast %struct.sockaddr_in* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** @AF_INET
%12 = load i32, i32* @SOCK_DGRAM
%13 = tail call i32 @socket(i8* %11, i32 %12, i32 0)
store i32 24, i32* %3
store i32 1, i32* %4
%14 = load i32, i32* @SOL_SOCKET
%15 = load i32, i32* @SO_BROADCAST
%16 = call i32 @setsockopt(i32 %13, i32 %14, i32 %15, i32* %4, i32 4)
%17 = call i32 @bzero(i8* %6, i32 24)
%18 = load i8*, i8** @AF_INET
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i8* %18, i8** %19
%20 = load i32, i32* @INADDR_ANY
%21 = call i32 @htonl(i32 %20)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %21, i32* %22
%23 = call i8* @htons(i32 0)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i8* %23, i8** %24
%25 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%26 = call i32 @bind(i32 %13, %struct.sockaddr* %25, i32 24)
%27 = call i32 @bzero(i8* %7, i32 24)
%28 = load i8*, i8** @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i8* %28, i8** %29
%30 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %30, i32* %31
%32 = call i8* @htons(i32 7004)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i8* %32, i8** %33
%34 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %35
35: ; preds = %35, %0
%36 = call i32 @gets(i8* %10)
%37 = load i32, i32* %3
%38 = call i32 @sendto(i32 %13, i8* %10, i32 81, i32 0, %struct.sockaddr* %34, i32 %37)
%39 = call i32 @recvfrom(i32 %13, i8* %10, i32 81, i32 0, %struct.sockaddr* %34, i32* %3)
%40 = call i32 @puts(i8* %10)
%41 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %35
43: ; preds = %35
%44 = call i32 @close(i32 %13)
ret void
}