#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_af(struct addrinfo *aip) {
  if (aip == (struct addrinfo *)0)
    return;
  printf("family ");
  switch (aip->ai_family) {
  case AF_INET:
    printf("inet ");
    break;
  case AF_INET6:
    printf("inet6 ");
    break;
  case AF_UNSPEC:
    printf("unspecific");
    break;
  case AF_UNIX:
    printf("unix");
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<print_af>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <print_af+0x1c>
jmp    11a8 <print_af+0x98>
lea    0xedd(%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     11a3 <print_af+0x93>
mov    -0x10(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <print_af+0x93>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <print_af+0x93>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <print_af+0x93>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <print_af+0x98>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_af>:
push   %rbx
test   %rdi,%rdi
je     1145 <print_af+0x35>
mov    %rdi,%rbx
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     1145 <print_af+0x35>
cltq
lea    0xef0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <printf@plt>
pop    %rbx
ret

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

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