#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 nd_router_solicit {
  scalar_t__ nd_rs_reserved;
  scalar_t__ nd_rs_cksum;
  scalar_t__ nd_rs_code;
  int /*<<< orphan*/ nd_rs_type;
};
struct in6_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ ND_ROUTER_SOLICIT;
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, struct in6_addr *);
int send_probe(int, int /*<<< orphan*/ *, struct in6_addr *, int, int);
int send_ra_solicit(int sock, uint8_t *buf) {
  int err;
  struct in6_addr addr;
  inet_pton(AF_INET6, "ff02::02", &addr);
  struct nd_router_solicit *solicit;
  solicit = (struct nd_router_solicit *)buf;
  solicit->nd_rs_type = ND_ROUTER_SOLICIT;
  solicit->nd_rs_code = 0;
  solicit->nd_rs_cksum = 0;
  solicit->nd_rs_reserved = 0;
  uint8_t *p = (uint8_t *)buf + sizeof(struct nd_router_solicit);
  err = send_probe(sock, buf, &addr, p - buf, 255);
  return err;
}


x86 assembly (clang, -O0):
<send_ra_solicit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <inet_pton@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,%ecx
lea    -0x18(%rbp),%rdx
mov    $0xff,%r8d
call   1040 <send_probe@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_ra_solicit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdx
call   1030 <inet_pton@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,(%rbx)
movq   $0x0,0x10(%rbx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x20,%ecx
mov    $0xff,%r8d
call   1040 <send_probe@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
%struct.nd_router_solicit = type { i64, i64, i64, i32 }
@AF_INET6 = global i32 0
@.str = [9 x i8] c"ff02::02\00"
@ND_ROUTER_SOLICIT = global i32 0
define i32 @send_ra_solicit(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.in6_addr
%7 = alloca %struct.nd_router_solicit*
%8 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%9 = load i32, i32* @AF_INET6
%10 = call i32 @inet_pton(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.in6_addr* %6)
%11 = load i32*, i32** %4
%12 = bitcast i32* %11 to %struct.nd_router_solicit*
store %struct.nd_router_solicit* %12, %struct.nd_router_solicit** %7
%13 = load i32, i32* @ND_ROUTER_SOLICIT
%14 = load %struct.nd_router_solicit*, %struct.nd_router_solicit** %7
%15 = getelementptr inbounds %struct.nd_router_solicit, %struct.nd_router_solicit* %14, i32 0, i32 3
store i32 %13, i32* %15
%16 = load %struct.nd_router_solicit*, %struct.nd_router_solicit** %7
%17 = getelementptr inbounds %struct.nd_router_solicit, %struct.nd_router_solicit* %16, i32 0, i32 2
store i64 0, i64* %17
%18 = load %struct.nd_router_solicit*, %struct.nd_router_solicit** %7
%19 = getelementptr inbounds %struct.nd_router_solicit, %struct.nd_router_solicit* %18, i32 0, i32 1
store i64 0, i64* %19
%20 = load %struct.nd_router_solicit*, %struct.nd_router_solicit** %7
%21 = getelementptr inbounds %struct.nd_router_solicit, %struct.nd_router_solicit* %20, i32 0, i32 0
store i64 0, i64* %21
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 32
store i32* %23, i32** %8
%24 = load i32, i32* %3
%25 = load i32*, i32** %4
%26 = load i32*, i32** %8
%27 = load i32*, i32** %4
%28 = ptrtoint i32* %26 to i64
%29 = ptrtoint i32* %27 to i64
%30 = sub i64 %28, %29
%31 = sdiv exact i64 %30, 4
%32 = trunc i64 %31 to i32
%33 = call i32 @send_probe(i32 %24, i32* %25, %struct.in6_addr* %6, i32 %32, i32 255)
store i32 %33, i32* %5
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
@AF_INET6 = global i32 0
@.str = [9 x i8] c"ff02::02\00"
@ND_ROUTER_SOLICIT = global i32 0
define i32 @send_ra_solicit(i32 %0, i32* %1) {
%3 = alloca %struct.in6_addr
%4 = bitcast %struct.in6_addr* %3 to i8*
%5 = load i32, i32* @AF_INET6
%6 = call i32 @inet_pton(i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.in6_addr* %3)
%7 = load i32, i32* @ND_ROUTER_SOLICIT
%8 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %7, i32* %8
%9 = bitcast i32* %1 to i8*
%10 = call i32 @send_probe(i32 %0, i32* %1, %struct.in6_addr* %3, i32 32, i32 255)
ret i32 %10
}