#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 {
  int dummy;
};

/* Variables and functions */
int AF_INET6;
int aeron_find_interface(char *, struct sockaddr_storage *, unsigned int *);
int aeron_find_multicast_interface(int family, const char *interface_str,
                                   struct sockaddr_storage *interface_addr,
                                   unsigned int *interface_index) {
  char *wildcard_str = (AF_INET6 == family) ? "[0::]/0" : "0.0.0.0/0";
  return aeron_find_interface((NULL == interface_str) ? wildcard_str
                                                      : interface_str,
                              interface_addr, interface_index);
}


x86 assembly (clang, -O0):
<aeron_find_multicast_interface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%edx
mov    -0x4(%rbp),%esi
lea    0xece(%rip),%rax
lea    0xebf(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1164 <aeron_find_multicast_interface+0x54>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    116c <aeron_find_multicast_interface+0x5c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <aeron_find_interface@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aeron_find_multicast_interface>:
mov    0x2ed1(%rip),%rax
cmp    %edi,(%rax)
lea    0xee0(%rip),%rax
lea    0xee1(%rip),%rdi
cmove  %rax,%rdi
test   %rsi,%rsi
cmovne %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1030 <aeron_find_interface@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
@AF_INET6 = global i32 0
@.str = [8 x i8] c"[0::]/0\00"
@.str.1 = [10 x i8] c"0.0.0.0/0\00"
define i32 @aeron_find_multicast_interface(i32 %0, i8* %1, %struct.sockaddr_storage* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.sockaddr_storage*
%8 = alloca i32*
%9 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store %struct.sockaddr_storage* %2, %struct.sockaddr_storage** %7
store i32* %3, i32** %8
%10 = load i32, i32* @AF_INET6
%11 = load i32, i32* %5
%12 = icmp eq i32 %10, %11
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
store i8* %14, i8** %9
%15 = load i8*, i8** %6
%16 = icmp eq i8* null, %15
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load i8*, i8** %9
br label %21
19: ; preds = %4
%20 = load i8*, i8** %6
br label %21
21: ; preds = %19, %17
%22 = phi i8* [ %18, %17 ], [ %20, %19 ]
%23 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %7
%24 = load i32*, i32** %8
%25 = call i32 @aeron_find_interface(i8* %22, %struct.sockaddr_storage* %23, i32* %24)
ret i32 %25
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
@AF_INET6 = global i32 0
@.str = [8 x i8] c"[0::]/0\00"
@.str.1 = [10 x i8] c"0.0.0.0/0\00"
define i32 @aeron_find_multicast_interface(i32 %0, i8* %1, %struct.sockaddr_storage* %2, i32* %3) {
%5 = load i32, i32* @AF_INET6
%6 = icmp eq i32 %5, %0
%7 = select i1 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
%8 = icmp eq i8* %1, null
%9 = select i1 %8, i8* %7, i8* %1
%10 = tail call i32 @aeron_find_interface(i8* %9, %struct.sockaddr_storage* %2, i32* %3)
ret i32 %10
}