#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 dummy;
};
struct ipv6_mreq {
  int ipv6mr_interface;
  struct in6_addr ipv6mr_multiaddr;
};
typedef int /*<<< orphan*/ mreq;

/* Variables and functions */
int /*<<< orphan*/ IPPROTO_IPV6;
int /*<<< orphan*/ IPV6_JOIN_GROUP;
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int join_group(int sock, int ifindex, struct in6_addr *group) {
  struct ipv6_mreq mreq;
  mreq.ipv6mr_multiaddr = *group;
  mreq.ipv6mr_interface = ifindex;
  return setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq,
                    sizeof(mreq));
}


x86 assembly (clang, -O0):
<join_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea5(%rip),%rax
mov    (%rax),%esi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join_group>:
push   %rax
mov    (%rdx),%eax
mov    %eax,0x4(%rsp)
mov    %esi,(%rsp)
mov    0x2ebf(%rip),%rax
mov    (%rax),%esi
mov    0x2eae(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
%struct.ipv6_mreq = type { i32, %struct.in6_addr }
@IPPROTO_IPV6 = global i32 0
@IPV6_JOIN_GROUP = global i32 0
define i32 @join_group(i32 %0, i32 %1, %struct.in6_addr* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.in6_addr*
%7 = alloca %struct.ipv6_mreq
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.in6_addr* %2, %struct.in6_addr** %6
%8 = getelementptr inbounds %struct.ipv6_mreq, %struct.ipv6_mreq* %7, i32 0, i32 1
%9 = load %struct.in6_addr*, %struct.in6_addr** %6
%10 = bitcast %struct.in6_addr* %8 to i8*
%11 = bitcast %struct.in6_addr* %9 to i8*
%12 = load i32, i32* %5
%13 = getelementptr inbounds %struct.ipv6_mreq, %struct.ipv6_mreq* %7, i32 0, i32 0
store i32 %12, i32* %13
%14 = load i32, i32* %4
%15 = load i32, i32* @IPPROTO_IPV6
%16 = load i32, i32* @IPV6_JOIN_GROUP
%17 = bitcast %struct.ipv6_mreq* %7 to i8*
%18 = call i32 @setsockopt(i32 %14, i32 %15, i32 %16, i8* %17, i32 8)
ret i32 %18
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
%struct.ipv6_mreq = type { i32, %struct.in6_addr }
@IPPROTO_IPV6 = global i32 0
@IPV6_JOIN_GROUP = global i32 0
define i32 @join_group(i32 %0, i32 %1, %struct.in6_addr* nocapture %2) {
%4 = alloca %struct.ipv6_mreq
%5 = bitcast %struct.ipv6_mreq* %4 to i8*
%6 = getelementptr %struct.in6_addr, %struct.in6_addr* %2, i64 0, i32 0
%7 = getelementptr inbounds %struct.ipv6_mreq, %struct.ipv6_mreq* %4, i64 0, i32 1, i32 0
%8 = load i32, i32* %6
store i32 %8, i32* %7
%9 = getelementptr inbounds %struct.ipv6_mreq, %struct.ipv6_mreq* %4, i64 0, i32 0
store i32 %1, i32* %9
%10 = load i32, i32* @IPPROTO_IPV6
%11 = load i32, i32* @IPV6_JOIN_GROUP
%12 = call i32 @setsockopt(i32 %0, i32 %10, i32 %11, i8* %5, i32 8)
ret i32 %12
}