#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 */
struct in6_addr {
  int /*<<< orphan*/ *s6_addr;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/ *, int);
void ipv6_ib_mc_map(const struct in6_addr *addr, const unsigned char *broadcast,
                    char *buf) {
  unsigned char scope;
  scope = broadcast[5] & 0xF;
  buf[0] = 0;
  buf[1] = 0xff;
  buf[2] = 0xff;
  buf[3] = 0xff;
  buf[4] = 0xff;
  buf[5] = 0x10 | scope;
  buf[6] = 0x60;
  buf[7] = 0x1b;
  buf[8] = broadcast[8];
  buf[9] = broadcast[9];
  memcpy(&buf[10], &addr->s6_addr[6], 10);
}


x86 assembly (clang, -O0):
<ipv6_ib_mc_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0xf,%eax
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0xff,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0xff,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0xff,0x3(%rax)
mov    -0x18(%rbp),%rax
movb   $0xff,0x4(%rax)
movzbl -0x19(%rbp),%eax
or     $0x10,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
movb   $0x60,0x6(%rax)
mov    -0x18(%rbp),%rax
movb   $0x1b,0x7(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x9(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x9(%rax)
mov    -0x18(%rbp),%rdi
add    $0xa,%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
add    $0x18,%rsi
mov    $0xa,%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipv6_ib_mc_map>:
mov    0x5(%rsi),%al
and    $0xf,%al
movb   $0x0,(%rdx)
or     $0x10,%al
movl   $0xffffffff,0x1(%rdx)
mov    %al,0x5(%rdx)
movw   $0x1b60,0x6(%rdx)
mov    0x8(%rsi),%al
mov    %al,0x8(%rdx)
mov    0x9(%rsi),%al
mov    %al,0x9(%rdx)
lea    0xa(%rdx),%rax
mov    (%rdi),%rsi
add    $0x18,%rsi
mov    %rax,%rdi
mov    $0xa,%edx
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
%struct.in6_addr = type { i32* }
define void @ipv6_ib_mc_map(%struct.in6_addr* %0, i8* %1, i8* %2) {
%4 = alloca %struct.in6_addr*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store %struct.in6_addr* %0, %struct.in6_addr** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 5
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = and i32 %11, 15
%13 = trunc i32 %12 to i8
store i8 %13, i8* %7
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 -1, i8* %17
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8 -1, i8* %19
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 3
store i8 -1, i8* %21
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 4
store i8 -1, i8* %23
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = or i32 16, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 5
store i8 %27, i8* %29
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 6
store i8 96, i8* %31
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 7
store i8 27, i8* %33
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 8
%36 = load i8, i8* %35
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i64 8
store i8 %36, i8* %38
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i64 9
%41 = load i8, i8* %40
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i64 9
store i8 %41, i8* %43
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 10
%46 = load %struct.in6_addr*, %struct.in6_addr** %4
%47 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %46, i32 0, i32 0
%48 = load i32*, i32** %47
%49 = getelementptr inbounds i32, i32* %48, i64 6
%50 = call i32 @memcpy(i8* %45, i32* %49, i32 10)
ret void
}

LLVM IR (-O2):
%struct.in6_addr = type { i32* }
define void @ipv6_ib_mc_map(%struct.in6_addr* nocapture %0, i8* nocapture %1, i8* %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 5
%5 = load i8, i8* %4
%6 = and i8 %5, 15
store i8 0, i8* %2
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = or i8 %6, 16
%9 = getelementptr inbounds i8, i8* %2, i64 5
%10 = bitcast i8* %7 to i32*
store i32 -1, i32* %10
store i8 %8, i8* %9
%11 = getelementptr inbounds i8, i8* %2, i64 6
store i8 96, i8* %11
%12 = getelementptr inbounds i8, i8* %2, i64 7
store i8 27, i8* %12
%13 = getelementptr inbounds i8, i8* %1, i64 8
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %2, i64 8
store i8 %14, i8* %15
%16 = getelementptr inbounds i8, i8* %1, i64 9
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %2, i64 9
store i8 %17, i8* %18
%19 = getelementptr inbounds i8, i8* %2, i64 10
%20 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %0, i64 0, i32 0
%21 = load i32*, i32** %20
%22 = getelementptr inbounds i32, i32* %21, i64 6
%23 = tail call i32 @memcpy(i8* %19, i32* %22, i32 10)
ret void
}