#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 */
typedef int /*<<< orphan*/ sa_family_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ AF_UNSPEC;
sa_family_t address_family_to_sa_family(unsigned short int address_family) {
  switch (address_family) {
  case 1:
    return AF_UNIX;
  case 2:
    return AF_INET;
  case 23:
    return AF_INET6;
  default:
    return AF_UNSPEC;
  }
}


x86 assembly (clang, -O0):
<address_family_to_sa_family>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1142 <address_family_to_sa_family+0x42>
jmp    1120 <address_family_to_sa_family+0x20>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1153 <address_family_to_sa_family+0x53>
jmp    1131 <address_family_to_sa_family+0x31>
mov    -0xc(%rbp),%eax
sub    $0x17,%eax
je     1164 <address_family_to_sa_family+0x64>
jmp    1175 <address_family_to_sa_family+0x75>
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <address_family_to_sa_family+0x81>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <address_family_to_sa_family+0x81>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <address_family_to_sa_family+0x81>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<address_family_to_sa_family>:
cmp    $0x1,%di
je     111c <address_family_to_sa_family+0x1c>
cmp    $0x17,%di
je     1126 <address_family_to_sa_family+0x26>
cmp    $0x2,%di
jne    1130 <address_family_to_sa_family+0x30>
mov    0x2ecf(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@AF_UNIX = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@AF_UNSPEC = global i32 0
define i32 @address_family_to_sa_family(i16 zeroext %0) {
%2 = alloca i32
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
switch i32 %5, label %12 [
i32 1, label %6
i32 2, label %8
i32 23, label %10
]
6: ; preds = %1
%7 = load i32, i32* @AF_UNIX
store i32 %7, i32* %2
br label %14
8: ; preds = %1
%9 = load i32, i32* @AF_INET
store i32 %9, i32* %2
br label %14
10: ; preds = %1
%11 = load i32, i32* @AF_INET6
store i32 %11, i32* %2
br label %14
12: ; preds = %1
%13 = load i32, i32* @AF_UNSPEC
store i32 %13, i32* %2
br label %14
14: ; preds = %12, %10, %8, %6
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@AF_UNSPEC = global i32 0
define i32 @address_family_to_sa_family(i16 zeroext %0) {
switch i16 %0, label %4 [
i16 1, label %5
i16 2, label %2
i16 23, label %3
]
2: ; preds = %1
br label %5
3: ; preds = %1
br label %5
4: ; preds = %1
br label %5
5: ; preds = %1, %4, %3, %2
%6 = phi i32* [ @AF_UNSPEC, %4 ], [ @AF_INET6, %3 ], [ @AF_INET, %2 ], [ @AF_UNIX, %1 ]
%7 = load i32, i32* %6
ret i32 %7
}