#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_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET6;
size_t aeron_ipv4_netmask_to_prefixlen(int /*<<< orphan*/ *);
size_t aeron_ipv6_netmask_to_prefixlen(int /*<<< orphan*/ *);
size_t aeron_ip_netmask_to_prefixlen(struct sockaddr *netmask) {
  return (AF_INET6 == netmask->sa_family)
             ? aeron_ipv6_netmask_to_prefixlen(
                   &((struct sockaddr_in6 *)netmask)->sin6_addr)
             : aeron_ipv4_netmask_to_prefixlen(
                   &((struct sockaddr_in *)netmask)->sin_addr);
}


x86 assembly (clang, -O0):
<aeron_ip_netmask_to_prefixlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jne    1155 <aeron_ip_netmask_to_prefixlen+0x35>
mov    -0x8(%rbp),%rdi
call   1040 <aeron_ipv6_netmask_to_prefixlen@plt>
mov    %rax,-0x10(%rbp)
jmp    1162 <aeron_ip_netmask_to_prefixlen+0x42>
mov    -0x8(%rbp),%rdi
call   1030 <aeron_ipv4_netmask_to_prefixlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aeron_ip_netmask_to_prefixlen>:
mov    0x2ec1(%rip),%rax
mov    (%rax),%rax
cmp    (%rdi),%rax
jne    1134 <aeron_ip_netmask_to_prefixlen+0x14>
jmp    1040 <aeron_ipv6_netmask_to_prefixlen@plt>
jmp    1030 <aeron_ipv4_netmask_to_prefixlen@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i64 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@AF_INET6 = global i64 0
define i64 @aeron_ip_netmask_to_prefixlen(%struct.sockaddr* %0) {
%2 = alloca %struct.sockaddr*
store %struct.sockaddr* %0, %struct.sockaddr** %2
%3 = load i64, i64* @AF_INET6
%4 = load %struct.sockaddr*, %struct.sockaddr** %2
%5 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %4, i32 0, i32 0
%6 = load i64, i64* %5
%7 = icmp eq i64 %3, %6
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load %struct.sockaddr*, %struct.sockaddr** %2
%10 = bitcast %struct.sockaddr* %9 to %struct.sockaddr_in6*
%11 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %10, i32 0, i32 0
%12 = call i64 @aeron_ipv6_netmask_to_prefixlen(i32* %11)
br label %18
13: ; preds = %1
%14 = load %struct.sockaddr*, %struct.sockaddr** %2
%15 = bitcast %struct.sockaddr* %14 to %struct.sockaddr_in*
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%17 = call i64 @aeron_ipv4_netmask_to_prefixlen(i32* %16)
br label %18
18: ; preds = %13, %8
%19 = phi i64 [ %12, %8 ], [ %17, %13 ]
ret i64 %19
}

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
@AF_INET6 = global i64 0
define i64 @aeron_ip_netmask_to_prefixlen(%struct.sockaddr* %0) {
%2 = load i64, i64* @AF_INET6
%3 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%4 = load i64, i64* %3
%5 = icmp eq i64 %2, %4
%6 = bitcast %struct.sockaddr* %0 to i32*
br i1 %5, label %7, label %9
7: ; preds = %1
%8 = tail call i64 @aeron_ipv6_netmask_to_prefixlen(i32* %6)
br label %11
9: ; preds = %1
%10 = tail call i64 @aeron_ipv4_netmask_to_prefixlen(i32* %6)
br label %11
11: ; preds = %9, %7
%12 = phi i64 [ %8, %7 ], [ %10, %9 ]
ret i64 %12
}