#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;
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_port;
  int /*<<< orphan*/ sin6_addr;
  int /*<<< orphan*/ sin6_family;
};
struct sockaddr {
  int dummy;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ command;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ sendto(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                  struct sockaddr *, int);
int send_command(int fd, uint8_t command) {
  struct sockaddr_in6 addr;
  ssize_t result;
  memset(&addr, 0, sizeof(addr));
  addr.sin6_family = AF_INET6;
  if (!inet_pton(AF_INET6, "ff02::1", &addr.sin6_addr)) {
    perror("inet_pton");
    return 0;
  }
  addr.sin6_port = htons(30621);
  result = sendto(fd, &command, sizeof(command), 0, (struct sockaddr *)&addr,
                  sizeof(addr));
  if (result < 0) {
    perror("sendto");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<send_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rdx
add    $0x4,%rdx
lea    0xe6e(%rip),%rsi
call   1060 <inet_pton@plt>
cmp    $0x0,%eax
jne    11b8 <send_command+0x68>
lea    0xe61(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1210 <send_command+0xc0>
mov    $0x779d,%edi
call   1030 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%r8
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    1209 <send_command+0xb9>
lea    0xe1a(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1210 <send_command+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_command>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    %esi,0xc(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    %edi,0x18(%rsp)
lea    0x14(%rsp),%rdx
lea    0xe7b(%rip),%rsi
call   1060 <inet_pton@plt>
test   %eax,%eax
je     11cd <send_command+0x7d>
mov    $0x779d,%edi
call   1030 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%r8
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
js     11d6 <send_command+0x86>
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe34(%rip),%rdi
jmp    11dd <send_command+0x8d>
lea    0xe35(%rip),%rdi
call   1070 <perror@plt>
xor    %eax,%eax
jmp    11c7 <send_command+0x77>

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@.str = [8 x i8] c"ff02::1\00"
@.str.1 = [10 x i8] c"inet_pton\00"
@.str.2 = [7 x i8] c"sendto\00"
define i32 @send_command(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in6
%7 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = call i32 @memset(%struct.sockaddr_in6* %6, i32 0, i32 12)
%9 = load i32, i32* @AF_INET6
%10 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %6, i32 0, i32 2
store i32 %9, i32* %10
%11 = load i32, i32* @AF_INET6
%12 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %6, i32 0, i32 1
%13 = call i32 @inet_pton(i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %28
17: ; preds = %2
%18 = call i32 @htons(i32 30621)
%19 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %6, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i32, i32* %4
%21 = bitcast %struct.sockaddr_in6* %6 to %struct.sockaddr*
%22 = call i64 @sendto(i32 %20, i32* %5, i32 4, i32 0, %struct.sockaddr* %21, i32 12)
store i64 %22, i64* %7
%23 = load i64, i64* %7
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %28
27: ; preds = %17
store i32 1, i32* %3
br label %28
28: ; preds = %27, %25, %15
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@.str = [8 x i8] c"ff02::1\00"
@.str.1 = [10 x i8] c"inet_pton\00"
@.str.2 = [7 x i8] c"sendto\00"
define i32 @send_command(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in6
store i32 %1, i32* %3
%5 = bitcast %struct.sockaddr_in6* %4 to i8*
%6 = call i32 @memset(%struct.sockaddr_in6* %4, i32 0, i32 12)
%7 = load i32, i32* @AF_INET6
%8 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 2
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 1
%10 = call i32 @inet_pton(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %2
%13 = call i32 @htons(i32 30621)
%14 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 0
store i32 %13, i32* %14
%15 = bitcast %struct.sockaddr_in6* %4 to %struct.sockaddr*
%16 = call i64 @sendto(i32 %0, i32* %3, i32 4, i32 0, %struct.sockaddr* %15, i32 12)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12, %2
%19 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %12 ]
%20 = call i32 @perror(i8* %19)
br label %21
21: ; preds = %18, %12
%22 = phi i32 [ 1, %12 ], [ 0, %18 ]
ret i32 %22
}