#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 */

/* Variables and functions */
int PF_INET;
int PF_INET6;
int PF_UNIX;
scalar_t__ strcmp(char *, char *);
int lookup_family(char *name) {
  if (strcmp("PF_UNIX", name) == 0) {
    return (PF_UNIX);
  } else if (strcmp("PF_INET", name) == 0) {
    return (PF_INET);
  } else if (strcmp("PF_INET6", name) == 0) {
    return (PF_INET6);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<lookup_family>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1147 <lookup_family+0x37>
mov    0x2ebb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <lookup_family+0x9e>
mov    -0x10(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1172 <lookup_family+0x62>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <lookup_family+0x9e>
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119d <lookup_family+0x8d>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <lookup_family+0x9e>
jmp    11a2 <lookup_family+0x92>
jmp    11a7 <lookup_family+0x97>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup_family>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115b <lookup_family+0x4b>
lea    0xed9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1164 <lookup_family+0x54>
lea    0xecd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    0x2e8e(%rip),%rcx
neg    %rax
sbb    %eax,%eax
or     (%rcx),%eax
pop    %rbx
ret
mov    0x2e96(%rip),%rax
jmp    116b <lookup_family+0x5b>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PF_UNIX\00"
@PF_UNIX = global i32 0
@.str.1 = [8 x i8] c"PF_INET\00"
@PF_INET = global i32 0
@.str.2 = [9 x i8] c"PF_INET6\00"
@PF_INET6 = global i32 0
define i32 @lookup_family(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @PF_UNIX
store i32 %8, i32* %2
br label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @PF_INET
store i32 %14, i32* %2
br label %24
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* @PF_INET6
store i32 %20, i32* %2
br label %24
21: ; preds = %15
br label %22
22: ; preds = %21
br label %23
23: ; preds = %22
store i32 -1, i32* %2
br label %24
24: ; preds = %23, %19, %13, %7
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [8 x i8] c"PF_UNIX\00"
@PF_UNIX = global i32 0
@.str.1 = [8 x i8] c"PF_INET\00"
@PF_INET = global i32 0
@.str.2 = [9 x i8] c"PF_INET6\00"
@PF_INET6 = global i32 0
define i32 @lookup_family(i8* %0) {
%2 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load i32, i32* @PF_UNIX
br label %16
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i32, i32* @PF_INET
br label %16
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = icmp eq i64 %12, 0
%14 = load i32, i32* @PF_INET6
%15 = select i1 %13, i32 %14, i32 -1
br label %16
16: ; preds = %11, %9, %4
%17 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %15, %11 ]
ret i32 %17
}