#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 scalar_t__ ulong;
struct TYPE_2__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  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 *);
scalar_t__ htonl(int /*<<< orphan*/);
void *htons(int);
scalar_t__ 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(60011);
  do {
    gets(linha);
    sendto(sock, linha, 81, 0, (struct sockaddr *)&target, adl);
    recvfrom(sock, linha, 81, 0, (struct sockaddr *)&target, &adl);
    if (!ip1)
      ip1 = target.sin_addr.s_addr;
    else
      while (target.sin_addr.s_addr != ip1)
        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
movq   $0x0,-0x98(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%rdi
mov    0x2dd9(%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    0x2dcd(%rip),%rax
mov    (%rax),%esi
mov    0x2da4(%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    0x2d98(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %rax,-0x18(%rbp)
xor    %edi,%edi
call   1050 <htons@plt>
mov    %rax,-0x10(%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    0x2d52(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xd64(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %rax,-0x30(%rbp)
mov    $0xea6b,%edi
call   1050 <htons@plt>
mov    %rax,-0x28(%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>
cmpq   $0x0,-0x98(%rbp)
jne    1319 <main+0x149>
mov    -0x30(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    1357 <main+0x187>
jmp    131e <main+0x14e>
mov    -0x30(%rbp),%rax
cmp    -0x98(%rbp),%rax
je     1352 <main+0x182>
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>
jmp    131e <main+0x14e>
jmp    1357 <main+0x187>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12b3 <main+0xe3>
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   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2df8(%rip),%r15
mov    (%r15),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
xor    %ebp,%ebp
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,%r13d
movl   $0x18,0x8(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r13d,%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    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %rax,0x28(%rsp)
xor    %edi,%edi
call   1050 <htons@plt>
mov    %rax,0x30(%rsp)
mov    %r13d,%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    0xd61(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %rax,0x10(%rsp)
mov    $0xea6b,%edi
call   1050 <htons@plt>
mov    %rax,0x18(%rsp)
lea    0x40(%rsp),%rbx
lea    0x8(%rsp),%r15
jmp    12f2 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%r12
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0xd2b(%rip),%rsi
call   10a0 <strcmp@plt>
mov    %r12,%rbp
test   %rax,%rax
je     1364 <main+0x194>
mov    %rbx,%rdi
call   10b0 <gets@plt>
mov    0x8(%rsp),%r9d
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   1070 <sendto@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   10c0 <recvfrom@plt>
mov    0x10(%rsp),%r12
test   %rbp,%rbp
je     12d3 <main+0x103>
cmp    %rbp,%r12
je     12d0 <main+0x100>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x51,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   10c0 <recvfrom@plt>
cmp    %rbp,0x10(%rsp)
jne    1340 <main+0x170>
jmp    12d0 <main+0x100>
mov    %r13d,%edi
call   1080 <close@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i64 }
%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 i64
store i64 0, i64* %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 i64 @htonl(i32 %20)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
store i64 %21, i64* %23
%24 = call i8* @htons(i32 0)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 1
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 i64 @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 0
%37 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i32 0, i32 0
store i64 %35, i64* %37
%38 = call i8* @htons(i32 60011)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
store i8* %38, i8** %39
br label %40
40: ; preds = %74, %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 = load i64, i64* %7
%53 = icmp ne i64 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %40
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
%57 = load i64, i64* %56
store i64 %57, i64* %7
br label %71
58: ; preds = %40
br label %59
59: ; preds = %65, %58
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = load i64, i64* %7
%64 = icmp ne i64 %62, %63
br i1 %64, label %65, label %70
65: ; preds = %59
%66 = load i32, i32* %3
%67 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%68 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%69 = call i32 @recvfrom(i32 %66, i8* %67, i32 81, i32 0, %struct.sockaddr* %68, i32* %4)
br label %59
70: ; preds = %59
br label %71
71: ; preds = %70, %54
%72 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%73 = call i32 @puts(i8* %72)
br label %74
74: ; preds = %71
%75 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%77 = icmp ne i64 %76, 0
br i1 %77, label %40, label %78
78: ; preds = %74
%79 = load i32, i32* %3
%80 = call i32 @close(i32 %79)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i64 }
%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 i64 @htonl(i32 %20)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i64 %21, i64* %22
%23 = call i8* @htons(i32 0)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
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 i64 @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 0, i32 0
store i64 %30, i64* %31
%32 = call i8* @htons(i32 60011)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i8* %32, i8** %33
%34 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %35
35: ; preds = %49, %0
%36 = phi i64 [ 0, %0 ], [ %50, %49 ]
%37 = call i32 @gets(i8* %10)
%38 = load i32, i32* %3
%39 = call i32 @sendto(i32 %13, i8* %10, i32 81, i32 0, %struct.sockaddr* %34, i32 %38)
%40 = call i32 @recvfrom(i32 %13, i8* %10, i32 81, i32 0, %struct.sockaddr* %34, i32* %3)
%41 = icmp eq i64 %36, 0
%42 = load i64, i64* %31
br i1 %41, label %49, label %43
43: ; preds = %35
%44 = icmp eq i64 %42, %36
br i1 %44, label %49, label %45
45: ; preds = %43, %45
%46 = call i32 @recvfrom(i32 %13, i8* %10, i32 81, i32 0, %struct.sockaddr* %34, i32* %3)
%47 = load i64, i64* %31
%48 = icmp eq i64 %47, %36
br i1 %48, label %49, label %45
49: ; preds = %45, %35, %43
%50 = phi i64 [ %36, %43 ], [ %42, %35 ], [ %36, %45 ]
%51 = call i32 @puts(i8* %10)
%52 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %35
54: ; preds = %49
%55 = call i32 @close(i32 %13)
ret void
}