#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 int u_char;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, char *, char *);
void dump_func_id(u_char *p) {
  static const char *id[] = {"Multifunction card",  "Memory card",
                             "Serial port/modem",   "Parallel port",
                             "Fixed disk card",     "Video adapter",
                             "Network/LAN adapter", "AIMS",
                             "SCSI card",           "Security"};
  printf("\t%s%s%s\n", (*p <= 9) ? id[*p] : "Unknown function",
         (p[1] & 1) ? " - POST initialize" : "",
         (p[1] & 2) ? " - Card has ROM" : "");
}


x86 assembly (clang, -O0):
<dump_func_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x9,(%rax)
jg     1144 <dump_func_id+0x34>
mov    -0x8(%rbp),%rax
movslq (%rax),%rcx
lea    0x2ef9(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <dump_func_id+0x44>
lea    0xf47(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <dump_func_id+0x44>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0x1,%ecx
lea    0xf28(%rip),%rdx
lea    0xf33(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
and    $0x2,%edi
lea    0xf09(%rip),%rcx
lea    0xf27(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_func_id>:
movslq (%rdi),%rax
cmp    $0x9,%rax
jg     1129 <dump_func_id+0x19>
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1130 <dump_func_id+0x20>
lea    0xf8a(%rip),%rsi
mov    0x4(%rdi),%eax
test   $0x1,%al
lea    0xf7d(%rip),%rdi
lea    0xf88(%rip),%rdx
cmove  %rdi,%rdx
test   $0x2,%al
lea    0xf8e(%rip),%rcx
cmove  %rdi,%rcx
lea    0xf56(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@dump_func_id.id = internal global [10 x i8*] [i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0)]
@.str = [19 x i8] c"Multifunction card\00"
@.str.1 = [12 x i8] c"Memory card\00"
@.str.2 = [18 x i8] c"Serial port/modem\00"
@.str.3 = [14 x i8] c"Parallel port\00"
@.str.4 = [16 x i8] c"Fixed disk card\00"
@.str.5 = [14 x i8] c"Video adapter\00"
@.str.6 = [20 x i8] c"Network/LAN adapter\00"
@.str.7 = [5 x i8] c"AIMS\00"
@.str.8 = [10 x i8] c"SCSI card\00"
@.str.9 = [9 x i8] c"Security\00"
@.str.10 = [9 x i8] c"\09%s%s%s\0A\00"
@.str.11 = [17 x i8] c"Unknown function\00"
@.str.12 = [19 x i8] c" - POST initialize\00"
@.str.13 = [1 x i8] zeroinitializer
@.str.14 = [16 x i8] c" - Card has ROM\00"
define void @dump_func_id(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = icmp sle i32 %4, 9
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32*, i32** %2
%8 = load i32, i32* %7
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* @dump_func_id.id, i64 0, i64 %9
%11 = load i8*, i8** %10
br label %13
12: ; preds = %1
br label %13
13: ; preds = %12, %6
%14 = phi i8* [ %11, %6 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), %12 ]
%15 = load i32*, i32** %2
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i64 1
%24 = load i32, i32* %23
%25 = and i32 %24, 2
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0)
%29 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %14, i8* %21, i8* %28)
ret void
}

LLVM IR (-O2):
@reltable.dump_func_id = internal unnamed_addr constant [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.dump_func_id to i64)) to i32)]
@.str = [19 x i8] c"Multifunction card\00"
@.str.1 = [12 x i8] c"Memory card\00"
@.str.2 = [18 x i8] c"Serial port/modem\00"
@.str.3 = [14 x i8] c"Parallel port\00"
@.str.4 = [16 x i8] c"Fixed disk card\00"
@.str.5 = [14 x i8] c"Video adapter\00"
@.str.6 = [20 x i8] c"Network/LAN adapter\00"
@.str.7 = [5 x i8] c"AIMS\00"
@.str.8 = [10 x i8] c"SCSI card\00"
@.str.9 = [9 x i8] c"Security\00"
@.str.10 = [9 x i8] c"\09%s%s%s\0A\00"
@.str.11 = [17 x i8] c"Unknown function\00"
@.str.12 = [19 x i8] c" - POST initialize\00"
@.str.13 = [1 x i8] zeroinitializer
@.str.14 = [16 x i8] c" - Card has ROM\00"
define void @dump_func_id(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp slt i32 %2, 10
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.dump_func_id to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), %1 ]
%10 = getelementptr inbounds i32, i32* %0, i64 1
%11 = load i32, i32* %10
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0)
%15 = and i32 %11, 2
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %9, i8* %14, i8* %17)
ret void
}