#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 unsigned short sa_family_t;

/* Variables and functions */
unsigned short AF_INET;
unsigned short AF_INET6;
unsigned short AF_UNSPEC;
int /*<<< orphan*/ printf(char *, unsigned short);
sa_family_t darwin_convert_family_to_native(unsigned short family) {
  if (family == 0)
    return AF_UNSPEC;
  if (family == 2)
    return AF_INET;
  if (family == 10)
    return AF_INET6;
  printf("darwin_convert_family_to_native: unsupported family %i\n", family);
  return family;
}


x86 assembly (clang, -O0):
<darwin_convert_family_to_native>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
cmp    $0x0,%eax
jne    113f <darwin_convert_family_to_native+0x2f>
mov    0x2ead(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1197 <darwin_convert_family_to_native+0x87>
movzwl -0x4(%rbp),%eax
cmp    $0x2,%eax
jne    115f <darwin_convert_family_to_native+0x4f>
mov    0x2e95(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1197 <darwin_convert_family_to_native+0x87>
movzwl -0x4(%rbp),%eax
cmp    $0xa,%eax
jne    117f <darwin_convert_family_to_native+0x6f>
mov    0x2e65(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1197 <darwin_convert_family_to_native+0x87>
lea    0xe7a(%rip),%rdi
movzwl -0x4(%rbp),%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<darwin_convert_family_to_native>:
push   %rbx
mov    %edi,%ebx
cmp    $0xa,%bx
je     1130 <darwin_convert_family_to_native+0x20>
cmp    $0x2,%bx
je     113c <darwin_convert_family_to_native+0x2c>
test   %bx,%bx
jne    1148 <darwin_convert_family_to_native+0x38>
mov    0x2eb5(%rip),%rax
movzwl (%rax),%ebx
jmp    1157 <darwin_convert_family_to_native+0x47>
mov    0x2ea1(%rip),%rax
movzwl (%rax),%ebx
jmp    1157 <darwin_convert_family_to_native+0x47>
mov    0x2ea5(%rip),%rax
movzwl (%rax),%ebx
jmp    1157 <darwin_convert_family_to_native+0x47>
movzwl %bx,%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@AF_UNSPEC = global i16 0
@AF_INET = global i16 0
@AF_INET6 = global i16 0
@.str = [56 x i8] c"darwin_convert_family_to_native: unsupported family %i\0A\00"
define zeroext i16 @darwin_convert_family_to_native(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i16, i16* @AF_UNSPEC
store i16 %8, i16* %2
br label %25
9: ; preds = %1
%10 = load i16, i16* %3
%11 = zext i16 %10 to i32
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i16, i16* @AF_INET
store i16 %14, i16* %2
br label %25
15: ; preds = %9
%16 = load i16, i16* %3
%17 = zext i16 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i16, i16* @AF_INET6
store i16 %20, i16* %2
br label %25
21: ; preds = %15
%22 = load i16, i16* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i16 zeroext %22)
%24 = load i16, i16* %3
store i16 %24, i16* %2
br label %25
25: ; preds = %21, %19, %13, %7
%26 = load i16, i16* %2
ret i16 %26
}

LLVM IR (-O2):
@AF_UNSPEC = global i16 0
@AF_INET = global i16 0
@AF_INET6 = global i16 0
@.str = [56 x i8] c"darwin_convert_family_to_native: unsupported family %i\0A\00"
define zeroext i16 @darwin_convert_family_to_native(i16 zeroext %0) {
switch i16 %0, label %8 [
i16 0, label %2
i16 2, label %4
i16 10, label %6
]
2: ; preds = %1
%3 = load i16, i16* @AF_UNSPEC
br label %10
4: ; preds = %1
%5 = load i16, i16* @AF_INET
br label %10
6: ; preds = %1
%7 = load i16, i16* @AF_INET6
br label %10
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i16 zeroext %0)
br label %10
10: ; preds = %8, %6, %4, %2
%11 = phi i16 [ %3, %2 ], [ %5, %4 ], [ %7, %6 ], [ %0, %8 ]
ret i16 %11
}