#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 */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
char *makeAddress(char *, int /*<<< orphan*/);
int makeBroadcastSendInterface(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void sendBroadcast(char *buf, char *prefix, uint8_t i) {
  char *address = makeAddress(prefix, i);
  int sock = makeBroadcastSendInterface(address, 8888);
  if (sock > 0) {
    send(sock, buf, strlen(buf), 0);
  } else {
    perror("could not send to broker");
  }
  close(sock);
  free(address);
  return;
}


x86 assembly (clang, -O0):
<sendBroadcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <makeAddress@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x22b8,%esi
call   1040 <makeBroadcastSendInterface@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11da <sendBroadcast+0x6a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
jmp    11e6 <sendBroadcast+0x76>
lea    0xe1f(%rip),%rdi
call   1090 <perror@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendBroadcast>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   1080 <makeAddress@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x22b8,%esi
call   1040 <makeBroadcastSendInterface@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11c0 <sendBroadcast+0x50>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>
lea    0xe39(%rip),%rdi
call   1090 <perror@plt>
jmp    11ad <sendBroadcast+0x3d>

LLVM IR (-O0):
@.str = [25 x i8] c"could not send to broker\00"
define void @sendBroadcast(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i8* @makeAddress(i8* %9, i32 %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i32 @makeBroadcastSendInterface(i8* %12, i32 8888)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i32, i32* %8
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @send(i32 %17, i8* %18, i32 %20, i32 0)
br label %24
22: ; preds = %3
%23 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = load i32, i32* %8
%26 = call i32 @close(i32 %25)
%27 = load i8*, i8** %7
%28 = call i32 @free(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"could not send to broker\00"
define void @sendBroadcast(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @makeAddress(i8* %1, i32 %2)
%5 = tail call i32 @makeBroadcastSendInterface(i8* %4, i32 8888)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %0)
%9 = tail call i32 @send(i32 %5, i8* %0, i32 %8, i32 0)
br label %12
10: ; preds = %3
%11 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = tail call i32 @close(i32 %5)
%14 = tail call i32 @free(i8* %4)
ret void
}