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

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ addr_mask_ipv4(struct sockaddr_in *, size_t);
int /*<<< orphan*/ addr_mask_ipv6(struct sockaddr_in6 *, size_t);
void addr_mask(struct sockaddr_storage *addr, size_t n) {
  switch (addr->ss_family) {
  case AF_INET:
    addr_mask_ipv4((struct sockaddr_in *)addr, n);
    break;
  case AF_INET6:
    addr_mask_ipv6((struct sockaddr_in6 *)addr, n);
    break;
  }
}


x86 assembly (clang, -O0):
<addr_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     116e <addr_mask+0x4e>
jmp    1149 <addr_mask+0x29>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
jne    117b <addr_mask+0x5b>
jmp    115c <addr_mask+0x3c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <addr_mask_ipv4@plt>
jmp    117b <addr_mask+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <addr_mask_ipv6@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr_mask>:
mov    (%rdi),%eax
cmp    $0x80,%eax
je     1135 <addr_mask+0x15>
cmp    $0x81,%eax
jne    113a <addr_mask+0x1a>
jmp    1030 <addr_mask_ipv4@plt>
jmp    1040 <addr_mask_ipv6@plt>
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
define void @addr_mask(%struct.sockaddr_storage* %0, i64 %1) {
%3 = alloca %struct.sockaddr_storage*
%4 = alloca i64
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %3
store i64 %1, i64* %4
%5 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%6 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i32 0, i32 0
%7 = load i32, i32* %6
switch i32 %7, label %18 [
i32 129, label %8
i32 128, label %13
]
8: ; preds = %2
%9 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%10 = bitcast %struct.sockaddr_storage* %9 to %struct.sockaddr_in*
%11 = load i64, i64* %4
%12 = call i32 @addr_mask_ipv4(%struct.sockaddr_in* %10, i64 %11)
br label %18
13: ; preds = %2
%14 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%15 = bitcast %struct.sockaddr_storage* %14 to %struct.sockaddr_in6*
%16 = load i64, i64* %4
%17 = call i32 @addr_mask_ipv6(%struct.sockaddr_in6* %15, i64 %16)
br label %18
18: ; preds = %2, %13, %8
ret void
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
define void @addr_mask(%struct.sockaddr_storage* %0, i64 %1) {
%3 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 129, label %5
i32 128, label %8
]
5: ; preds = %2
%6 = bitcast %struct.sockaddr_storage* %0 to %struct.sockaddr_in*
%7 = tail call i32 @addr_mask_ipv4(%struct.sockaddr_in* %6, i64 %1)
br label %11
8: ; preds = %2
%9 = bitcast %struct.sockaddr_storage* %0 to %struct.sockaddr_in6*
%10 = tail call i32 @addr_mask_ipv6(%struct.sockaddr_in6* %9, i64 %1)
br label %11
11: ; preds = %2, %8, %5
ret void
}