#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 sockaddr_storage {
  scalar_t__ ss_family;
};
struct sockaddr_in6 {
  int dummy;
};
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int /*<<< orphan*/ EINVAL;
int aeron_ipv4_multicast_control_address(struct sockaddr_in *,
                                         struct sockaddr_in *);
int aeron_ipv6_multicast_control_address(struct sockaddr_in6 *,
                                         struct sockaddr_in6 *);
int /*<<< orphan*/ aeron_set_err(int /*<<< orphan*/, char *, scalar_t__);
int aeron_multicast_control_address(struct sockaddr_storage *data_addr,
                                    struct sockaddr_storage *control_addr) {
  if (AF_INET6 == data_addr->ss_family) {
    return aeron_ipv6_multicast_control_address(
        (struct sockaddr_in6 *)data_addr, (struct sockaddr_in6 *)control_addr);
  } else if (AF_INET == data_addr->ss_family) {
    return aeron_ipv4_multicast_control_address(
        (struct sockaddr_in *)data_addr, (struct sockaddr_in *)control_addr);
  }
  aeron_set_err(EINVAL, "unknown address family: %d", data_addr->ss_family);
  return -1;
}


x86 assembly (clang, -O0):
<aeron_multicast_control_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    116c <aeron_multicast_control_address+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <aeron_ipv6_multicast_control_address@plt>
mov    %eax,-0x4(%rbp)
jmp    11c0 <aeron_multicast_control_address+0x90>
mov    0x2e75(%rip),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1198 <aeron_multicast_control_address+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <aeron_ipv4_multicast_control_address@plt>
mov    %eax,-0x4(%rbp)
jmp    11c0 <aeron_multicast_control_address+0x90>
jmp    119d <aeron_multicast_control_address+0x6d>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
call   1030 <aeron_set_err@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aeron_multicast_control_address>:
push   %rax
mov    0x2ea8(%rip),%rax
mov    (%rdi),%rdx
cmp    %rdx,(%rax)
jne    1146 <aeron_multicast_control_address+0x16>
pop    %rax
jmp    1050 <aeron_ipv6_multicast_control_address@plt>
mov    0x2e9b(%rip),%rax
cmp    %rdx,(%rax)
jne    1158 <aeron_multicast_control_address+0x28>
pop    %rax
jmp    1040 <aeron_ipv4_multicast_control_address@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1030 <aeron_set_err@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i64 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@AF_INET6 = global i64 0
@AF_INET = global i64 0
@EINVAL = global i32 0
@.str = [27 x i8] c"unknown address family: %d\00"
define i32 @aeron_multicast_control_address(%struct.sockaddr_storage* %0, %struct.sockaddr_storage* %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_storage*
%5 = alloca %struct.sockaddr_storage*
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %4
store %struct.sockaddr_storage* %1, %struct.sockaddr_storage** %5
%6 = load i64, i64* @AF_INET6
%7 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%8 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = icmp eq i64 %6, %9
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%13 = bitcast %struct.sockaddr_storage* %12 to %struct.sockaddr_in6*
%14 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%15 = bitcast %struct.sockaddr_storage* %14 to %struct.sockaddr_in6*
%16 = call i32 @aeron_ipv6_multicast_control_address(%struct.sockaddr_in6* %13, %struct.sockaddr_in6* %15)
store i32 %16, i32* %3
br label %36
17: ; preds = %2
%18 = load i64, i64* @AF_INET
%19 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%20 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = icmp eq i64 %18, %21
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%25 = bitcast %struct.sockaddr_storage* %24 to %struct.sockaddr_in*
%26 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%27 = bitcast %struct.sockaddr_storage* %26 to %struct.sockaddr_in*
%28 = call i32 @aeron_ipv4_multicast_control_address(%struct.sockaddr_in* %25, %struct.sockaddr_in* %27)
store i32 %28, i32* %3
br label %36
29: ; preds = %17
br label %30
30: ; preds = %29
%31 = load i32, i32* @EINVAL
%32 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%33 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = call i32 @aeron_set_err(i32 %31, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %34)
store i32 -1, i32* %3
br label %36
36: ; preds = %30, %23, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i64 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@AF_INET6 = global i64 0
@AF_INET = global i64 0
@EINVAL = global i32 0
@.str = [27 x i8] c"unknown address family: %d\00"
define i32 @aeron_multicast_control_address(%struct.sockaddr_storage* %0, %struct.sockaddr_storage* %1) {
%3 = load i64, i64* @AF_INET6
%4 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = icmp eq i64 %3, %5
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = bitcast %struct.sockaddr_storage* %0 to %struct.sockaddr_in6*
%9 = bitcast %struct.sockaddr_storage* %1 to %struct.sockaddr_in6*
%10 = tail call i32 @aeron_ipv6_multicast_control_address(%struct.sockaddr_in6* %8, %struct.sockaddr_in6* %9)
br label %21
11: ; preds = %2
%12 = load i64, i64* @AF_INET
%13 = icmp eq i64 %12, %5
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = bitcast %struct.sockaddr_storage* %0 to %struct.sockaddr_in*
%16 = bitcast %struct.sockaddr_storage* %1 to %struct.sockaddr_in*
%17 = tail call i32 @aeron_ipv4_multicast_control_address(%struct.sockaddr_in* %15, %struct.sockaddr_in* %16)
br label %21
18: ; preds = %11
%19 = load i32, i32* @EINVAL
%20 = tail call i32 @aeron_set_err(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %5)
br label %21
21: ; preds = %18, %14, %7
%22 = phi i32 [ %10, %7 ], [ %17, %14 ], [ -1, %18 ]
ret i32 %22
}