#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 scalar_t__ sa_family_t;

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


x86 assembly (clang, -O0):
<darwin_convert_family_from_native>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2eb9(%rip),%rcx
cmp    (%rcx),%rax
jne    113b <darwin_convert_family_from_native+0x2b>
movw   $0x0,-0x2(%rbp)
jmp    1191 <darwin_convert_family_from_native+0x81>
mov    -0x10(%rbp),%rax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
jne    115a <darwin_convert_family_from_native+0x4a>
movw   $0x2,-0x2(%rbp)
jmp    1191 <darwin_convert_family_from_native+0x81>
mov    -0x10(%rbp),%rax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <darwin_convert_family_from_native+0x69>
movw   $0xa,-0x2(%rbp)
jmp    1191 <darwin_convert_family_from_native+0x81>
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<darwin_convert_family_from_native>:
push   %rbx
mov    0x2ec8(%rip),%rax
cmp    %rdi,(%rax)
jne    1121 <darwin_convert_family_from_native+0x11>
xor    %eax,%eax
pop    %rbx
ret
mov    %rdi,%rbx
mov    0x2ebd(%rip),%rcx
mov    $0x2,%ax
cmp    %rdi,(%rcx)
je     111f <darwin_convert_family_from_native+0xf>
mov    0x2e9d(%rip),%rcx
mov    $0xa,%ax
cmp    %rbx,(%rcx)
je     111f <darwin_convert_family_from_native+0xf>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

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