#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 addrinfo {
  int ai_family;
};

/* Variables and functions */
#define AF_INET 131
#define AF_INET6 130
#define AF_UNIX 129
#define AF_UNSPEC 128
int /*<<< orphan*/ printf(char *);
void print_family(struct addrinfo *aip) {
  printf(" family ");
  switch (aip->ai_family) {
  case AF_INET:
    printf("inet");
    break;
  case AF_INET6:
    printf("inet6");
    break;
  case AF_UNIX:
    printf("unix");
    break;
  case AF_UNSPEC:
    printf("unspecified");
    break;
  default:
    printf("unknown");
  }
}


x86 assembly (clang, -O0):
<print_family>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1198 <print_family+0x88>
mov    -0x10(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <print_family+0x94>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <print_family+0x94>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <print_family+0x94>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <print_family+0x94>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_family>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     1140 <print_family+0x30>
cltq
lea    0xefd(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <printf@plt>
lea    0xede(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [9 x i8] c" family \00"
@.str.1 = [5 x i8] c"inet\00"
@.str.2 = [6 x i8] c"inet6\00"
@.str.3 = [5 x i8] c"unix\00"
@.str.4 = [12 x i8] c"unspecified\00"
@.str.5 = [8 x i8] c"unknown\00"
define void @print_family(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
store %struct.addrinfo* %0, %struct.addrinfo** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = load %struct.addrinfo*, %struct.addrinfo** %2
%5 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i32 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %15 [
i32 131, label %7
i32 130, label %9
i32 129, label %11
i32 128, label %13
]
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %17
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %17
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %17
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11, %9, %7
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [9 x i8] c" family \00"
@.str.1 = [5 x i8] c"inet\00"
@.str.2 = [6 x i8] c"inet6\00"
@.str.3 = [5 x i8] c"unix\00"
@.str.4 = [12 x i8] c"unspecified\00"
@.str.5 = [8 x i8] c"unknown\00"
@reltable.print_family = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_family to i64)) to i32)]
define void @print_family(%struct.addrinfo* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = add i32 %4, -128
%6 = icmp ult i32 %5, 4
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.print_family to i8*), i64 %9)
br label %11
11: ; preds = %1, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %1 ]
%13 = tail call i32 @printf(i8* dereferenceable(1) %12)
ret void
}