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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char const *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ sendto(int, char const *, size_t, int /*<<< orphan*/,
                  struct sockaddr *, int);
int multicast_send(int socket_descriptor, const char *address, int port,
                   const char *data, size_t datasize) {
  struct sockaddr_in group_socket;
  memset((char *)&group_socket, 0, sizeof(group_socket));
  group_socket.sin_family = AF_INET;
  group_socket.sin_addr.s_addr = inet_addr(address);
  group_socket.sin_port = htons(port);
  if (sendto(socket_descriptor, data, datasize, 0,
             (struct sockaddr *)&group_socket, sizeof(group_socket)) < 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<multicast_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
cmp    $0x0,%rax
jge    11bf <multicast_send+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <multicast_send+0x86>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multicast_send>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r12d
lea    0x8(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %rbx,%rdi
call   1060 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %r13,%r8
mov    $0xc,%r9d
call   1050 <sendto@plt>
shr    $0x3f,%rax
xor    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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
define i32 @multicast_send(i32 %0, i8* %1, i32 %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca %struct.sockaddr_in
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%13 = bitcast %struct.sockaddr_in* %12 to i8*
%14 = call i32 @memset(i8* %13, i32 0, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %15, i32* %16
%17 = load i8*, i8** %8
%18 = call i32 @inet_addr(i8* %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i32 0, i32 0
store i32 %18, i32* %20
%21 = load i32, i32* %9
%22 = call i32 @htons(i32 %21)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i32 %22, i32* %23
%24 = load i32, i32* %7
%25 = load i8*, i8** %10
%26 = load i64, i64* %11
%27 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%28 = call i64 @sendto(i32 %24, i8* %25, i64 %26, i32 0, %struct.sockaddr* %27, i32 12)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %5
store i32 0, i32* %6
br label %32
31: ; preds = %5
store i32 1, i32* %6
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %6
ret i32 %33
}

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
define i32 @multicast_send(i32 %0, i8* %1, i32 %2, i8* %3, i64 %4) {
%6 = alloca %struct.sockaddr_in
%7 = bitcast %struct.sockaddr_in* %6 to i8*
%8 = call i32 @memset(i8* %7, i32 0, i32 12)
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %9, i32* %10
%11 = call i32 @inet_addr(i8* %1)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %11, i32* %12
%13 = call i32 @htons(i32 %2)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i32 %13, i32* %14
%15 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%16 = call i64 @sendto(i32 %0, i8* %3, i64 %4, i32 0, %struct.sockaddr* %15, i32 12)
%17 = lshr i64 %16, 63
%18 = trunc i64 %17 to i32
%19 = xor i32 %18, 1
ret i32 %19
}